Added some localized messages when exporting and editing decals.
This commit is contained in:
parent
9bf9e55428
commit
7db0c17c56
@ -1782,6 +1782,7 @@ DecalModel.lbl.choose = From file...
|
|||||||
! Export Decal Dialog
|
! Export Decal Dialog
|
||||||
ExportDecalDialog.title = Export Decal
|
ExportDecalDialog.title = Export Decal
|
||||||
ExportDecalDialog.decalList.lbl = Decal
|
ExportDecalDialog.decalList.lbl = Decal
|
||||||
|
ExportDecalDialog.exception = Unable to write decal to file ''{0}''
|
||||||
|
|
||||||
! Component Preset Chooser Dialog
|
! Component Preset Chooser Dialog
|
||||||
ComponentPresetChooserDialog.title = Choose component preset
|
ComponentPresetChooserDialog.title = Choose component preset
|
||||||
@ -1829,7 +1830,9 @@ EditDecalDialog.lbl.cmdline = Command Line
|
|||||||
EditDecalDialog.lbl.cmdline.help = The filename will be subsituted for ''%%''
|
EditDecalDialog.lbl.cmdline.help = The filename will be subsituted for ''%%''
|
||||||
EditDecalDialog.lbl.always = Always use these settings
|
EditDecalDialog.lbl.always = Always use these settings
|
||||||
EditDecalDialog.btn.chooser = Select Graphics Editor Program
|
EditDecalDialog.btn.chooser = Select Graphics Editor Program
|
||||||
|
EditDecalHelper.createFileException = Cannot create temporary file {0}
|
||||||
|
EditDecalHelper.launchSystemEditorException = Cannot launch system graphics editor
|
||||||
|
EditDecalHelper.launchCustomEditorException = Cannot launch graphics editor with command ''{0}''
|
||||||
|
|
||||||
MotorConfigurationPanel.lbl.motorMounts = Motor mounts:
|
MotorConfigurationPanel.lbl.motorMounts = Motor mounts:
|
||||||
MotorConfigurationPanel.lbl.motorConfiguration = Motor configurations:
|
MotorConfigurationPanel.lbl.motorConfiguration = Motor configurations:
|
||||||
|
@ -5,21 +5,23 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.MessageFormat;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import net.sf.openrocket.appearance.DecalImage;
|
import net.sf.openrocket.appearance.DecalImage;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
|
import net.sf.openrocket.gui.util.FileHelper;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.util.BugException;
|
|
||||||
|
|
||||||
public class ExportDecalDialog extends JDialog {
|
public class ExportDecalDialog extends JDialog {
|
||||||
|
|
||||||
@ -60,14 +62,16 @@ public class ExportDecalDialog extends JDialog {
|
|||||||
} else if (command.equals(JFileChooser.APPROVE_SELECTION)) {
|
} else if (command.equals(JFileChooser.APPROVE_SELECTION)) {
|
||||||
// Here we copy the bits out.
|
// Here we copy the bits out.
|
||||||
|
|
||||||
// FIXME - confirm overwrite?
|
|
||||||
DecalImage selectedDecal = (DecalImage) decalComboBox.getSelectedItem();
|
DecalImage selectedDecal = (DecalImage) decalComboBox.getSelectedItem();
|
||||||
File selectedFile = chooser.getSelectedFile();
|
File selectedFile = chooser.getSelectedFile();
|
||||||
|
|
||||||
|
if (FileHelper.confirmWrite(selectedFile, ExportDecalDialog.this)) {
|
||||||
export(selectedDecal, selectedFile);
|
export(selectedDecal, selectedFile);
|
||||||
|
// If the user doesn't confirm over write, then leave this dialog open.
|
||||||
ExportDecalDialog.this.dispose();
|
ExportDecalDialog.this.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
panel.add(chooser, "span, grow");
|
panel.add(chooser, "span, grow");
|
||||||
|
|
||||||
@ -80,8 +84,8 @@ public class ExportDecalDialog extends JDialog {
|
|||||||
try {
|
try {
|
||||||
decal.exportImage(selectedFile, false);
|
decal.exportImage(selectedFile, false);
|
||||||
} catch (IOException iex) {
|
} catch (IOException iex) {
|
||||||
// FIXME - probably want a simple user dialog here since FileIO is not really a bug.
|
String message = MessageFormat.format(trans.get("ExportDecalDialog.exception"), selectedFile.getAbsoluteFile());
|
||||||
throw new BugException(iex);
|
JOptionPane.showMessageDialog(this, message, "", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package net.sf.openrocket.gui.configdialog;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.IOException;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.EventObject;
|
import java.util.EventObject;
|
||||||
|
|
||||||
@ -13,6 +12,7 @@ import javax.swing.JColorChooser;
|
|||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JSeparator;
|
import javax.swing.JSeparator;
|
||||||
import javax.swing.JSlider;
|
import javax.swing.JSlider;
|
||||||
@ -37,6 +37,7 @@ import net.sf.openrocket.gui.components.StyledLabel.Style;
|
|||||||
import net.sf.openrocket.gui.components.UnitSelector;
|
import net.sf.openrocket.gui.components.UnitSelector;
|
||||||
import net.sf.openrocket.gui.util.ColorConversion;
|
import net.sf.openrocket.gui.util.ColorConversion;
|
||||||
import net.sf.openrocket.gui.util.EditDecalHelper;
|
import net.sf.openrocket.gui.util.EditDecalHelper;
|
||||||
|
import net.sf.openrocket.gui.util.EditDecalHelper.EditDecalHelperException;
|
||||||
import net.sf.openrocket.gui.util.SwingPreferences;
|
import net.sf.openrocket.gui.util.SwingPreferences;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
@ -44,7 +45,6 @@ import net.sf.openrocket.startup.Application;
|
|||||||
import net.sf.openrocket.unit.GeneralUnit;
|
import net.sf.openrocket.unit.GeneralUnit;
|
||||||
import net.sf.openrocket.unit.Unit;
|
import net.sf.openrocket.unit.Unit;
|
||||||
import net.sf.openrocket.unit.UnitGroup;
|
import net.sf.openrocket.unit.UnitGroup;
|
||||||
import net.sf.openrocket.util.BugException;
|
|
||||||
import net.sf.openrocket.util.LineStyle;
|
import net.sf.openrocket.util.LineStyle;
|
||||||
import net.sf.openrocket.util.StateChangeListener;
|
import net.sf.openrocket.util.StateChangeListener;
|
||||||
|
|
||||||
@ -253,8 +253,8 @@ public class AppearancePanel extends JPanel {
|
|||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
try {
|
try {
|
||||||
EditDecalHelper.editDecal(SwingUtilities.getWindowAncestor(AppearancePanel.this), document, c, ab.getImage());
|
EditDecalHelper.editDecal(SwingUtilities.getWindowAncestor(AppearancePanel.this), document, c, ab.getImage());
|
||||||
} catch (IOException ex) {
|
} catch (EditDecalHelperException ex) {
|
||||||
throw new BugException(ex);
|
JOptionPane.showMessageDialog(AppearancePanel.this, ex.getMessage(), "", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -344,5 +344,4 @@ public class AppearancePanel extends JPanel {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,28 @@ import java.awt.Desktop;
|
|||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
|
||||||
import net.sf.openrocket.appearance.AppearanceBuilder;
|
import net.sf.openrocket.appearance.AppearanceBuilder;
|
||||||
import net.sf.openrocket.appearance.DecalImage;
|
import net.sf.openrocket.appearance.DecalImage;
|
||||||
import net.sf.openrocket.document.OpenRocketDocument;
|
import net.sf.openrocket.document.OpenRocketDocument;
|
||||||
import net.sf.openrocket.gui.dialogs.EditDecalDialog;
|
import net.sf.openrocket.gui.dialogs.EditDecalDialog;
|
||||||
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
|
|
||||||
public class EditDecalHelper {
|
public class EditDecalHelper {
|
||||||
|
|
||||||
|
public static class EditDecalHelperException extends Exception {
|
||||||
|
|
||||||
|
public EditDecalHelperException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
// FIXME - need to have a specific set of localizable exceptions come out of this instead of generic IOException;
|
// FIXME - need to have a specific set of localizable exceptions come out of this instead of generic IOException;
|
||||||
// perhaps - unable to create file,
|
// perhaps - unable to create file,
|
||||||
// unable to open system editor
|
// unable to open system editor
|
||||||
@ -21,7 +33,7 @@ public class EditDecalHelper {
|
|||||||
|
|
||||||
private static final SwingPreferences prefs = ((SwingPreferences) Application.getPreferences());
|
private static final SwingPreferences prefs = ((SwingPreferences) Application.getPreferences());
|
||||||
|
|
||||||
public static void editDecal(Window parent, OpenRocketDocument doc, RocketComponent component, DecalImage decal) throws IOException {
|
public static void editDecal(Window parent, OpenRocketDocument doc, RocketComponent component, DecalImage decal) throws EditDecalHelperException {
|
||||||
|
|
||||||
boolean sysPrefSet = prefs.isDecalEditorPreferenceSet();
|
boolean sysPrefSet = prefs.isDecalEditorPreferenceSet();
|
||||||
int usageCount = doc.countDecalUsage(decal);
|
int usageCount = doc.countDecalUsage(decal);
|
||||||
@ -76,7 +88,7 @@ public class EditDecalHelper {
|
|||||||
return newImage;
|
return newImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void launchEditor(boolean useSystemEditor, String commandTemplate, DecalImage decal) throws IOException {
|
private static void launchEditor(boolean useSystemEditor, String commandTemplate, DecalImage decal) throws EditDecalHelperException {
|
||||||
|
|
||||||
String decalId = decal.getName();
|
String decalId = decal.getName();
|
||||||
// Create Temp File.
|
// Create Temp File.
|
||||||
@ -85,13 +97,29 @@ public class EditDecalHelper {
|
|||||||
if (dotlocation > 0 && dotlocation < decalId.length()) {
|
if (dotlocation > 0 && dotlocation < decalId.length()) {
|
||||||
extension = decalId.substring(dotlocation);
|
extension = decalId.substring(dotlocation);
|
||||||
}
|
}
|
||||||
File tmpFile = File.createTempFile("OR_graphics", extension);
|
File tmpFile = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
tmpFile = File.createTempFile("OR_graphics", extension);
|
||||||
|
} catch (IOException ioex) {
|
||||||
|
String message = MessageFormat.format(trans.get("EditDecalHelper.createFileException"), tmpFile.getAbsoluteFile());
|
||||||
|
throw new EditDecalHelperException(message, ioex);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
decal.exportImage(tmpFile, true);
|
decal.exportImage(tmpFile, true);
|
||||||
|
} catch (IOException ioex) {
|
||||||
|
String message = MessageFormat.format(trans.get("EditDecalHelper.createFileException"), tmpFile.getAbsoluteFile());
|
||||||
|
throw new EditDecalHelperException(message, ioex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (useSystemEditor) {
|
if (useSystemEditor) {
|
||||||
|
try {
|
||||||
Desktop.getDesktop().edit(tmpFile);
|
Desktop.getDesktop().edit(tmpFile);
|
||||||
|
} catch (IOException ioex) {
|
||||||
|
throw new EditDecalHelperException(trans.get("EditDecalHelper.launchSystemEditorException"), ioex);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
String filename = tmpFile.getAbsolutePath();
|
String filename = tmpFile.getAbsolutePath();
|
||||||
@ -103,9 +131,13 @@ public class EditDecalHelper {
|
|||||||
command = commandTemplate + " " + filename;
|
command = commandTemplate + " " + filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
Runtime.getRuntime().exec(command);
|
Runtime.getRuntime().exec(command);
|
||||||
|
} catch (IOException ioex) {
|
||||||
|
String message = MessageFormat.format(trans.get("EditDecalHelper.launchCustomEditorException"), command);
|
||||||
|
throw new EditDecalHelperException(message, ioex);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user