Merge remote-tracking branch 'upstream/master' into kruland-integration
Conflicts: core/resources/l10n/messages_fr.properties core/src/net/sf/openrocket/gui/dialogs/preferences/PreferencesDialog.java
This commit is contained in:
commit
701b8966a2
@ -1,4 +1,3 @@
|
||||
#
|
||||
# French base translation file
|
||||
# Translated by Tripoli France
|
||||
# Should you need to add new logical keys here is the proposed method
|
||||
|
File diff suppressed because it is too large
Load Diff
1576
core/resources/l10n/messages_pt.properties
Normal file
1576
core/resources/l10n/messages_pt.properties
Normal file
File diff suppressed because it is too large
Load Diff
@ -62,23 +62,23 @@ import net.sf.openrocket.util.Utils;
|
||||
|
||||
public class PreferencesDialog extends JDialog {
|
||||
private static final LogHelper log = Application.getLogger();
|
||||
|
||||
|
||||
private final List<DefaultUnitSelector> unitSelectors = new ArrayList<DefaultUnitSelector>();
|
||||
|
||||
|
||||
private File defaultDirectory = null;
|
||||
private static final Translator trans = Application.getTranslator();
|
||||
|
||||
private final SwingPreferences preferences = (SwingPreferences) Application.getPreferences();
|
||||
|
||||
|
||||
private PreferencesDialog(Window parent) {
|
||||
//// Preferences
|
||||
super(parent, trans.get("pref.dlg.title.Preferences"), Dialog.ModalityType.APPLICATION_MODAL);
|
||||
|
||||
|
||||
JPanel panel = new JPanel(new MigLayout("fill, gap unrel", "[grow]", "[grow][]"));
|
||||
|
||||
|
||||
JTabbedPane tabbedPane = new JTabbedPane();
|
||||
panel.add(tabbedPane, "grow, wrap");
|
||||
|
||||
|
||||
//// Units and Default units
|
||||
tabbedPane.addTab(trans.get("pref.dlg.tab.Units"), null, unitsPane(),
|
||||
trans.get("pref.dlg.tab.Defaultunits"));
|
||||
@ -101,26 +101,26 @@ public class PreferencesDialog extends JDialog {
|
||||
}
|
||||
});
|
||||
panel.add(close, "span, right, tag close");
|
||||
|
||||
|
||||
this.setContentPane(panel);
|
||||
pack();
|
||||
this.setLocationRelativeTo(null);
|
||||
|
||||
|
||||
this.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosed(WindowEvent e) {
|
||||
preferences.storeDefaultUnits();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
GUIUtil.setDisposableDialogOptions(this, close);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private JPanel optionsPane() {
|
||||
JPanel panel = new JPanel(new MigLayout("fillx, ins 30lp n n n"));
|
||||
|
||||
|
||||
|
||||
|
||||
//// Language selector
|
||||
Locale userLocale = null;
|
||||
{
|
||||
@ -129,11 +129,11 @@ public class PreferencesDialog extends JDialog {
|
||||
}
|
||||
List<Named<Locale>> locales = new ArrayList<Named<Locale>>();
|
||||
for (Locale l : SwingPreferences.getSupportedLocales()) {
|
||||
locales.add(new Named<Locale>(l, l.getDisplayLanguage()));
|
||||
locales.add(new Named<Locale>(l, l.getDisplayLanguage(l) + "/" + l.getDisplayLanguage()));
|
||||
}
|
||||
Collections.sort(locales);
|
||||
locales.add(0, new Named<Locale>(null, trans.get("languages.default")));
|
||||
|
||||
|
||||
final JComboBox languageCombo = new JComboBox(locales.toArray());
|
||||
for (int i = 0; i < locales.size(); i++) {
|
||||
if (Utils.equals(userLocale, locales.get(i).get())) {
|
||||
@ -151,10 +151,10 @@ public class PreferencesDialog extends JDialog {
|
||||
});
|
||||
panel.add(new JLabel(trans.get("lbl.language")), "gapright para");
|
||||
panel.add(languageCombo, "wrap rel, growx, sg combos");
|
||||
|
||||
|
||||
panel.add(new StyledLabel(trans.get("PreferencesDialog.lbl.languageEffect"), -3, Style.ITALIC), "span, wrap para*2");
|
||||
|
||||
|
||||
|
||||
|
||||
//// Position to insert new body components:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Positiontoinsert")), "gapright para");
|
||||
panel.add(new JComboBox(new PrefChoiseSelector(Preferences.BODY_COMPONENT_INSERT_POSITION_KEY,
|
||||
@ -164,7 +164,7 @@ public class PreferencesDialog extends JDialog {
|
||||
trans.get("pref.dlg.PrefChoiseSelector1"),
|
||||
trans.get("pref.dlg.PrefChoiseSelector2"),
|
||||
trans.get("pref.dlg.PrefChoiseSelector3"))), "wrap para, growx, sg combos");
|
||||
|
||||
|
||||
//// Confirm deletion of simulations:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Confirmdeletion")));
|
||||
panel.add(new JComboBox(new PrefBooleanSelector(Preferences.CONFIRM_DELETE_SIMULATION,
|
||||
@ -172,7 +172,7 @@ public class PreferencesDialog extends JDialog {
|
||||
//// Confirm
|
||||
trans.get("pref.dlg.PrefBooleanSelector1"),
|
||||
trans.get("pref.dlg.PrefBooleanSelector2"), true)), "wrap 40lp, growx, sg combos");
|
||||
|
||||
|
||||
//// User-defined thrust curves:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.User-definedthrust")), "spanx, wrap");
|
||||
final JTextField field = new JTextField();
|
||||
@ -190,17 +190,17 @@ public class PreferencesDialog extends JDialog {
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
changed();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
changed();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
changed();
|
||||
}
|
||||
|
||||
|
||||
private void changed() {
|
||||
String text = field.getText();
|
||||
List<File> list = new ArrayList<File>();
|
||||
@ -214,7 +214,7 @@ public class PreferencesDialog extends JDialog {
|
||||
}
|
||||
});
|
||||
panel.add(field, "w 100px, gapright unrel, spanx, growx, split");
|
||||
|
||||
|
||||
//// Add button
|
||||
JButton button = new JButton(trans.get("pref.dlg.but.add"));
|
||||
button.addActionListener(new ActionListener() {
|
||||
@ -241,7 +241,7 @@ public class PreferencesDialog extends JDialog {
|
||||
if (defaultDirectory != null) {
|
||||
chooser.setCurrentDirectory(defaultDirectory);
|
||||
}
|
||||
|
||||
|
||||
//// Add
|
||||
int returnVal = chooser.showDialog(PreferencesDialog.this, trans.get("pref.dlg.Add"));
|
||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||
@ -257,10 +257,10 @@ public class PreferencesDialog extends JDialog {
|
||||
}
|
||||
});
|
||||
panel.add(button, "gapright unrel");
|
||||
|
||||
|
||||
//// Reset button
|
||||
button = new JButton(trans.get("pref.dlg.but.reset"));
|
||||
|
||||
|
||||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -270,18 +270,18 @@ public class PreferencesDialog extends JDialog {
|
||||
}
|
||||
});
|
||||
panel.add(button, "wrap");
|
||||
|
||||
|
||||
//// Add directories, RASP motor files (*.eng), RockSim engine files (*.rse) or ZIP archives separated by a semicolon (;) to load external thrust curves. Changes will take effect the next time you start OpenRocket.
|
||||
DescriptionArea desc = new DescriptionArea(trans.get("pref.dlg.DescriptionArea.Adddirectories"), 3, -3, false);
|
||||
desc.setBackground(getBackground());
|
||||
panel.add(desc, "spanx, growx, wrap 40lp");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//// Check for software updates at startup
|
||||
final JCheckBox softwareUpdateBox =
|
||||
new JCheckBox(trans.get("pref.dlg.checkbox.Checkupdates"));
|
||||
softwareUpdateBox.setSelected( preferences.getCheckUpdates());
|
||||
softwareUpdateBox.setSelected(preferences.getCheckUpdates());
|
||||
softwareUpdateBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -289,7 +289,7 @@ public class PreferencesDialog extends JDialog {
|
||||
}
|
||||
});
|
||||
panel.add(softwareUpdateBox);
|
||||
|
||||
|
||||
//// Check now button
|
||||
button = new JButton(trans.get("pref.dlg.but.checknow"));
|
||||
//// Check for software updates now
|
||||
@ -301,8 +301,7 @@ public class PreferencesDialog extends JDialog {
|
||||
}
|
||||
});
|
||||
panel.add(button, "right, wrap");
|
||||
|
||||
|
||||
|
||||
final JCheckBox autoOpenDesignFile = new JCheckBox(trans.get("pref.dlg.but.openlast"));
|
||||
autoOpenDesignFile.setSelected(preferences.isAutoOpenLastDesignOnStartupEnabled());
|
||||
autoOpenDesignFile.addActionListener(new ActionListener() {
|
||||
@ -312,129 +311,129 @@ public class PreferencesDialog extends JDialog {
|
||||
}
|
||||
});
|
||||
panel.add(autoOpenDesignFile);
|
||||
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
private JPanel unitsPane() {
|
||||
JPanel panel = new JPanel(new MigLayout("", "[][]40lp[][]"));
|
||||
JComboBox combo;
|
||||
|
||||
|
||||
//// Select your preferred units:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Selectprefunits")), "span, wrap paragraph");
|
||||
|
||||
|
||||
|
||||
|
||||
//// Rocket dimensions:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Rocketdimensions")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_LENGTH));
|
||||
panel.add(combo, "sizegroup boxes");
|
||||
|
||||
|
||||
//// Line density:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Linedensity")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_DENSITY_LINE));
|
||||
panel.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
|
||||
|
||||
//// Motor dimensions:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Motordimensions")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_MOTOR_DIMENSIONS));
|
||||
panel.add(combo, "sizegroup boxes");
|
||||
|
||||
|
||||
//// Surface density:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Surfacedensity")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_DENSITY_SURFACE));
|
||||
panel.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
|
||||
|
||||
//// Distance:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Distance")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_DISTANCE));
|
||||
panel.add(combo, "sizegroup boxes");
|
||||
|
||||
|
||||
//// Bulk density::
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Bulkdensity")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_DENSITY_BULK));
|
||||
panel.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
|
||||
|
||||
//// Velocity:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Velocity")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_VELOCITY));
|
||||
panel.add(combo, "sizegroup boxes");
|
||||
|
||||
|
||||
//// Surface roughness:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Surfaceroughness")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_ROUGHNESS));
|
||||
panel.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
|
||||
|
||||
//// Acceleration:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Acceleration")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_ACCELERATION));
|
||||
panel.add(combo, "sizegroup boxes");
|
||||
|
||||
|
||||
//// Area:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Area")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_AREA));
|
||||
panel.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
|
||||
|
||||
//// Mass:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Mass")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_MASS));
|
||||
panel.add(combo, "sizegroup boxes");
|
||||
|
||||
|
||||
//// Angle:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Angle")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_ANGLE));
|
||||
panel.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
|
||||
|
||||
//// Force:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Force")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_FORCE));
|
||||
panel.add(combo, "sizegroup boxes");
|
||||
|
||||
|
||||
//// Roll rate:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Rollrate")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_ROLL));
|
||||
panel.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
|
||||
|
||||
//// Total impulse:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Totalimpulse")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_IMPULSE));
|
||||
panel.add(combo, "sizegroup boxes");
|
||||
|
||||
|
||||
//// Temperature:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Temperature")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_TEMPERATURE));
|
||||
panel.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
//// Moment of inertia:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Momentofinertia")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_INERTIA));
|
||||
panel.add(combo, "sizegroup boxes");
|
||||
|
||||
|
||||
//// Pressure:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Pressure")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_PRESSURE));
|
||||
panel.add(combo, "sizegroup boxes, wrap");
|
||||
|
||||
|
||||
|
||||
|
||||
//// Stability:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Stability")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_STABILITY));
|
||||
panel.add(combo, "sizegroup boxes");
|
||||
|
||||
|
||||
//// Windspeed:
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Windspeed")));
|
||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_WINDSPEED));
|
||||
panel.add(combo, "sizegroup boxes, wrap para");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//// Default metric button
|
||||
JButton button = new JButton(trans.get("pref.dlg.but.defaultmetric"));
|
||||
button.addActionListener(new ActionListener() {
|
||||
@ -446,7 +445,7 @@ public class PreferencesDialog extends JDialog {
|
||||
}
|
||||
});
|
||||
panel.add(button, "spanx, split 2, grow");
|
||||
|
||||
|
||||
//// Default imperial button
|
||||
button = new JButton(trans.get("pref.dlg.but.defaultimperial"));
|
||||
button.addActionListener(new ActionListener() {
|
||||
@ -458,74 +457,74 @@ public class PreferencesDialog extends JDialog {
|
||||
}
|
||||
});
|
||||
panel.add(button, "grow, wrap para");
|
||||
|
||||
|
||||
//// The effects will take place the next time you open a window.
|
||||
panel.add(new StyledLabel(
|
||||
trans.get("pref.dlg.lbl.effect1"), -2, Style.ITALIC),
|
||||
"spanx, wrap");
|
||||
|
||||
|
||||
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private JPanel decalEditorPane() {
|
||||
|
||||
|
||||
JPanel panel = new JPanel(new MigLayout("fillx, ins 30lp n n n"));
|
||||
|
||||
|
||||
ButtonGroup execGroup = new ButtonGroup();
|
||||
|
||||
|
||||
JRadioButton showPrompt = new JRadioButton(trans.get("EditDecalDialog.lbl.prompt"));
|
||||
showPrompt.setSelected(!preferences.isDecalEditorPreferenceSet());
|
||||
showPrompt.addItemListener( new ItemListener() {
|
||||
showPrompt.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if ( ((JRadioButton) e.getItem()).isSelected() ) {
|
||||
if (((JRadioButton) e.getItem()).isSelected()) {
|
||||
preferences.clearDecalEditorPreference();
|
||||
}
|
||||
}
|
||||
});
|
||||
panel.add(showPrompt,"wrap");
|
||||
panel.add(showPrompt, "wrap");
|
||||
execGroup.add(showPrompt);
|
||||
|
||||
if (Desktop.getDesktop().isSupported(Desktop.Action.EDIT) ) {
|
||||
|
||||
|
||||
if (Desktop.getDesktop().isSupported(Desktop.Action.EDIT)) {
|
||||
|
||||
JRadioButton systemRadio = new JRadioButton(trans.get("EditDecalDialog.lbl.system"));
|
||||
systemRadio.setSelected( preferences.isDecalEditorPreferenceSystem() );
|
||||
systemRadio.addItemListener( new ItemListener() {
|
||||
systemRadio.setSelected(preferences.isDecalEditorPreferenceSystem());
|
||||
systemRadio.addItemListener(new ItemListener() {
|
||||
@Override
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
if ( ((JRadioButton) e.getItem()).isSelected() ) {
|
||||
if (((JRadioButton) e.getItem()).isSelected()) {
|
||||
preferences.setDecalEditorPreference(true, null);
|
||||
}
|
||||
}
|
||||
});
|
||||
panel.add(systemRadio,"wrap");
|
||||
panel.add(systemRadio, "wrap");
|
||||
execGroup.add(systemRadio);
|
||||
|
||||
|
||||
}
|
||||
|
||||
boolean commandLineIsSelected = preferences.isDecalEditorPreferenceSet() && ! preferences.isDecalEditorPreferenceSystem();
|
||||
boolean commandLineIsSelected = preferences.isDecalEditorPreferenceSet() && !preferences.isDecalEditorPreferenceSystem();
|
||||
final JRadioButton commandRadio = new JRadioButton(trans.get("EditDecalDialog.lbl.cmdline"));
|
||||
commandRadio.setSelected(commandLineIsSelected);
|
||||
panel.add(commandRadio,"wrap");
|
||||
panel.add(commandRadio, "wrap");
|
||||
execGroup.add(commandRadio);
|
||||
|
||||
|
||||
final JTextArea commandText = new JTextArea();
|
||||
commandText.setEnabled(commandLineIsSelected);
|
||||
commandText.setText( commandLineIsSelected ? preferences.getDecalEditorCommandLine() : "" );
|
||||
commandText.getDocument().addDocumentListener( new DocumentListener() {
|
||||
|
||||
commandText.setText(commandLineIsSelected ? preferences.getDecalEditorCommandLine() : "");
|
||||
commandText.getDocument().addDocumentListener(new DocumentListener() {
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
preferences.setDecalEditorPreference(false, commandText.getText());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
preferences.setDecalEditorPreference(false, commandText.getText());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
preferences.setDecalEditorPreference(false, commandText.getText());
|
||||
@ -533,58 +532,58 @@ public class PreferencesDialog extends JDialog {
|
||||
|
||||
});
|
||||
panel.add(commandText, "growx, wrap");
|
||||
|
||||
|
||||
final JButton chooser = new JButton(trans.get("EditDecalDialog.btn.chooser"));
|
||||
chooser.setEnabled(commandLineIsSelected);
|
||||
chooser.addActionListener( new ActionListener() {
|
||||
|
||||
chooser.addActionListener(new ActionListener() {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JFileChooser fc = new JFileChooser();
|
||||
int action = fc.showOpenDialog(SwingUtilities.windowForComponent(PreferencesDialog.this));
|
||||
if ( action == JFileChooser.APPROVE_OPTION) {
|
||||
if (action == JFileChooser.APPROVE_OPTION) {
|
||||
String commandLine = fc.getSelectedFile().getAbsolutePath();
|
||||
commandText.setText(commandLine);
|
||||
preferences.setDecalEditorPreference(false, commandLine);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
panel.add(chooser, "growx, wrap");
|
||||
|
||||
|
||||
commandRadio.addChangeListener( new ChangeListener() {
|
||||
|
||||
|
||||
|
||||
commandRadio.addChangeListener(new ChangeListener() {
|
||||
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
boolean enabled = commandRadio.isSelected();
|
||||
commandText.setEnabled(enabled);
|
||||
chooser.setEnabled(enabled);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private class DefaultUnitSelector extends AbstractListModel implements ComboBoxModel {
|
||||
|
||||
|
||||
private final UnitGroup group;
|
||||
|
||||
|
||||
public DefaultUnitSelector(UnitGroup group) {
|
||||
this.group = group;
|
||||
unitSelectors.add(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getSelectedItem() {
|
||||
return group.getDefaultUnit();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSelectedItem(Object item) {
|
||||
if (item == null) {
|
||||
@ -596,39 +595,39 @@ public class PreferencesDialog extends JDialog {
|
||||
}
|
||||
group.setDefaultUnit(group.getUnitIndex((Unit) item));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
return group.getUnit(index);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return group.getUnitCount();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void fireChange() {
|
||||
this.fireContentsChanged(this, 0, this.getSize());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private class PrefChoiseSelector extends AbstractListModel implements ComboBoxModel {
|
||||
private final String preference;
|
||||
private final String[] descriptions;
|
||||
|
||||
|
||||
public PrefChoiseSelector(String preference, String... descriptions) {
|
||||
this.preference = preference;
|
||||
this.descriptions = descriptions;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getSelectedItem() {
|
||||
return descriptions[preferences.getChoice(preference, descriptions.length, 0)];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSelectedItem(Object item) {
|
||||
if (item == null) {
|
||||
@ -646,27 +645,27 @@ public class PreferencesDialog extends JDialog {
|
||||
if (index >= descriptions.length) {
|
||||
throw new IllegalArgumentException("Illegal argument " + item);
|
||||
}
|
||||
|
||||
|
||||
preferences.putChoice(preference, index);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
return descriptions[index];
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return descriptions.length;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private class PrefBooleanSelector extends AbstractListModel implements ComboBoxModel {
|
||||
private final String preference;
|
||||
private final String trueDesc, falseDesc;
|
||||
private final boolean def;
|
||||
|
||||
|
||||
public PrefBooleanSelector(String preference, String falseDescription,
|
||||
String trueDescription, boolean defaultState) {
|
||||
this.preference = preference;
|
||||
@ -674,7 +673,7 @@ public class PreferencesDialog extends JDialog {
|
||||
this.falseDesc = falseDescription;
|
||||
this.def = defaultState;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getSelectedItem() {
|
||||
if (preferences.getBoolean(preference, def)) {
|
||||
@ -683,7 +682,7 @@ public class PreferencesDialog extends JDialog {
|
||||
return falseDesc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setSelectedItem(Object item) {
|
||||
if (item == null) {
|
||||
@ -693,7 +692,7 @@ public class PreferencesDialog extends JDialog {
|
||||
if (!(item instanceof String)) {
|
||||
throw new IllegalArgumentException("Illegal argument " + item);
|
||||
}
|
||||
|
||||
|
||||
if (trueDesc.equals(item)) {
|
||||
preferences.putBoolean(preference, true);
|
||||
} else if (falseDesc.equals(item)) {
|
||||
@ -702,44 +701,44 @@ public class PreferencesDialog extends JDialog {
|
||||
throw new IllegalArgumentException("Illegal argument " + item);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int index) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return def ? trueDesc : falseDesc;
|
||||
|
||||
|
||||
case 1:
|
||||
return def ? falseDesc : trueDesc;
|
||||
|
||||
|
||||
default:
|
||||
throw new IndexOutOfBoundsException("Boolean asked for index=" + index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void checkForUpdates() {
|
||||
final UpdateInfoRetriever retriever = new UpdateInfoRetriever();
|
||||
retriever.start();
|
||||
|
||||
|
||||
|
||||
|
||||
// Progress dialog
|
||||
final JDialog dialog1 = new JDialog(this, ModalityType.APPLICATION_MODAL);
|
||||
JPanel panel = new JPanel(new MigLayout());
|
||||
|
||||
|
||||
//// Checking for updates...
|
||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Checkingupdates")), "wrap");
|
||||
|
||||
|
||||
JProgressBar bar = new JProgressBar();
|
||||
bar.setIndeterminate(true);
|
||||
panel.add(bar, "growx, wrap para");
|
||||
|
||||
|
||||
//// Cancel button
|
||||
JButton cancel = new JButton(trans.get("dlg.but.cancel"));
|
||||
cancel.addActionListener(new ActionListener() {
|
||||
@ -750,14 +749,14 @@ public class PreferencesDialog extends JDialog {
|
||||
});
|
||||
panel.add(cancel, "right");
|
||||
dialog1.add(panel);
|
||||
|
||||
|
||||
GUIUtil.setDisposableDialogOptions(dialog1, cancel);
|
||||
|
||||
|
||||
|
||||
|
||||
// Timer to monitor progress
|
||||
final Timer timer = new Timer(100, null);
|
||||
final long startTime = System.currentTimeMillis();
|
||||
|
||||
|
||||
ActionListener listener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -769,12 +768,12 @@ public class PreferencesDialog extends JDialog {
|
||||
};
|
||||
timer.addActionListener(listener);
|
||||
timer.start();
|
||||
|
||||
|
||||
|
||||
|
||||
// Wait for action
|
||||
dialog1.setVisible(true);
|
||||
|
||||
|
||||
|
||||
|
||||
// Check result
|
||||
UpdateInfo info = retriever.getUpdateInfo();
|
||||
if (info == null) {
|
||||
@ -800,14 +799,14 @@ public class PreferencesDialog extends JDialog {
|
||||
preferences.putString(SwingPreferences.LAST_UPDATE, info.getLatestVersion());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//////// Singleton implementation ////////
|
||||
|
||||
|
||||
private static PreferencesDialog dialog = null;
|
||||
|
||||
|
||||
public static void showPreferences(Window parent) {
|
||||
if (dialog != null) {
|
||||
dialog.dispose();
|
||||
@ -815,6 +814,6 @@ public class PreferencesDialog extends JDialog {
|
||||
dialog = new PreferencesDialog(parent);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
|
||||
private static final List<Locale> SUPPORTED_LOCALES;
|
||||
static {
|
||||
List<Locale> list = new ArrayList<Locale>();
|
||||
for (String lang : new String[] { "en", "de", "es", "fr", "it", "ru", "cs", "pl" }) {
|
||||
for (String lang : new String[] { "en", "de", "es", "fr", "it", "ru", "cs", "pl", "ja", "pt" }) {
|
||||
list.add(new Locale(lang));
|
||||
}
|
||||
SUPPORTED_LOCALES = Collections.unmodifiableList(list);
|
||||
@ -225,17 +225,17 @@ public class SwingPreferences extends net.sf.openrocket.startup.Preferences {
|
||||
}
|
||||
|
||||
public File getDefaultUserComponentDirectory() {
|
||||
|
||||
|
||||
File compdir = new File(SystemInfo.getUserApplicationDirectory(), "Components");
|
||||
|
||||
|
||||
if (!compdir.isDirectory()) {
|
||||
compdir.mkdirs();
|
||||
}
|
||||
|
||||
if( !compdir.isDirectory() ) {
|
||||
if (!compdir.isDirectory()) {
|
||||
return null;
|
||||
}
|
||||
if( !compdir.canRead() ) {
|
||||
if (!compdir.canRead()) {
|
||||
return null;
|
||||
}
|
||||
return compdir;
|
||||
|
Loading…
x
Reference in New Issue
Block a user