Added preference to auto-open last design file on startup.
This commit is contained in:
parent
417ef81269
commit
5b6e1ecf39
@ -220,6 +220,7 @@ MaterialModel.title.Defcustmat = Define custom material
|
|||||||
pref.dlg.but.add = Add
|
pref.dlg.but.add = Add
|
||||||
pref.dlg.but.reset = Reset
|
pref.dlg.but.reset = Reset
|
||||||
pref.dlg.but.checknow = Check now
|
pref.dlg.but.checknow = Check now
|
||||||
|
pref.dlg.but.openlast = Open last design file on startup
|
||||||
pref.dlg.but.defaultmetric = Default metric
|
pref.dlg.but.defaultmetric = Default metric
|
||||||
pref.dlg.but.defaultimperial = Default imperial
|
pref.dlg.but.defaultimperial = Default imperial
|
||||||
pref.dlg.title.Preferences = Preferences
|
pref.dlg.title.Preferences = Preferences
|
||||||
@ -486,7 +487,7 @@ ExpressionBuilderDialog.led.ttip.Name = Name must not have already been used
|
|||||||
ExpressionBuilderDialog.led.ttip.Symbol = Symbol must not have already been used
|
ExpressionBuilderDialog.led.ttip.Symbol = Symbol must not have already been used
|
||||||
ExpressionBuilderDialog.led.ttip.Expression = Expression must use only known symbols and operators
|
ExpressionBuilderDialog.led.ttip.Expression = Expression must use only known symbols and operators
|
||||||
ExpressionBuilderDialog.CopyToOtherSimulations = Copy to other simulations
|
ExpressionBuilderDialog.CopyToOtherSimulations = Copy to other simulations
|
||||||
ExpressionBuilderDialog.CopyToOtherSimulations.ttip = <html>Make a copy of this expression in other simulations in this document.<br>Will not overwrite or modify any existing expressions in other simulations.
|
ExpressionBuilderDialog.CopyToOtherSimulations.ttip = <html>Make a copy of this expression in other simulations in this document.<br>Will not overwrite or modify any existing expressions in other simulations.
|
||||||
|
|
||||||
! Custom expression variable selector
|
! Custom expression variable selector
|
||||||
CustomVariableSelector.title = Variable Selector
|
CustomVariableSelector.title = Variable Selector
|
||||||
@ -520,7 +521,7 @@ Operator.htan = Hyperbolic tangent
|
|||||||
Operator.log10 = Base 10 logarithm
|
Operator.log10 = Base 10 logarithm
|
||||||
Operator.round = Round to nearest integer value
|
Operator.round = Round to nearest integer value
|
||||||
Operator.random = Random number between zero and given value
|
Operator.random = Random number between zero and given value
|
||||||
Operator.expm1 = The same as exp(x)-1, but more accurate for small x
|
Operator.expm1 = The same as exp(x)-1, but more accurate for small x
|
||||||
Operator.mean = The arithmetic mean of a given range
|
Operator.mean = The arithmetic mean of a given range
|
||||||
Operator.min = The minimum value in a given range
|
Operator.min = The minimum value in a given range
|
||||||
Operator.max = The maximum value in a given range
|
Operator.max = The maximum value in a given range
|
||||||
@ -1106,7 +1107,7 @@ main.menu.analyze.componentAnalysis.desc = Analyze the rocket components separat
|
|||||||
main.menu.analyze.optimization = Rocket optimization
|
main.menu.analyze.optimization = Rocket optimization
|
||||||
main.menu.analyze.optimization.desc = General rocket design optimization
|
main.menu.analyze.optimization.desc = General rocket design optimization
|
||||||
main.menu.analyze.customExpressions = Custom expressions
|
main.menu.analyze.customExpressions = Custom expressions
|
||||||
main.menu.analyze.customExpressions.desc = Define new flight data types by writing custom mathematical expressions
|
main.menu.analyze.customExpressions.desc = Define new flight data types by writing custom mathematical expressions
|
||||||
|
|
||||||
main.menu.help = Help
|
main.menu.help = Help
|
||||||
main.menu.help.desc = Information about OpenRocket
|
main.menu.help.desc = Information about OpenRocket
|
||||||
|
@ -53,21 +53,21 @@ import net.sf.openrocket.util.Utils;
|
|||||||
|
|
||||||
public class PreferencesDialog extends JDialog {
|
public class PreferencesDialog extends JDialog {
|
||||||
private static final LogHelper log = Application.getLogger();
|
private static final LogHelper log = Application.getLogger();
|
||||||
|
|
||||||
private final List<DefaultUnitSelector> unitSelectors = new ArrayList<DefaultUnitSelector>();
|
private final List<DefaultUnitSelector> unitSelectors = new ArrayList<DefaultUnitSelector>();
|
||||||
|
|
||||||
private File defaultDirectory = null;
|
private File defaultDirectory = null;
|
||||||
private static final Translator trans = Application.getTranslator();
|
private static final Translator trans = Application.getTranslator();
|
||||||
|
|
||||||
private PreferencesDialog(Window parent) {
|
private PreferencesDialog(Window parent) {
|
||||||
//// Preferences
|
//// Preferences
|
||||||
super(parent, trans.get("pref.dlg.title.Preferences"), Dialog.ModalityType.APPLICATION_MODAL);
|
super(parent, trans.get("pref.dlg.title.Preferences"), Dialog.ModalityType.APPLICATION_MODAL);
|
||||||
|
|
||||||
JPanel panel = new JPanel(new MigLayout("fill, gap unrel", "[grow]", "[grow][]"));
|
JPanel panel = new JPanel(new MigLayout("fill, gap unrel", "[grow]", "[grow][]"));
|
||||||
|
|
||||||
JTabbedPane tabbedPane = new JTabbedPane();
|
JTabbedPane tabbedPane = new JTabbedPane();
|
||||||
panel.add(tabbedPane, "grow, wrap");
|
panel.add(tabbedPane, "grow, wrap");
|
||||||
|
|
||||||
//// Units and Default units
|
//// Units and Default units
|
||||||
tabbedPane.addTab(trans.get("pref.dlg.tab.Units"), null, unitsPane(),
|
tabbedPane.addTab(trans.get("pref.dlg.tab.Units"), null, unitsPane(),
|
||||||
trans.get("pref.dlg.tab.Defaultunits"));
|
trans.get("pref.dlg.tab.Defaultunits"));
|
||||||
@ -77,7 +77,7 @@ public class PreferencesDialog extends JDialog {
|
|||||||
//// Options and Miscellaneous options
|
//// Options and Miscellaneous options
|
||||||
tabbedPane.addTab(trans.get("pref.dlg.tab.Options"), null, optionsPane(),
|
tabbedPane.addTab(trans.get("pref.dlg.tab.Options"), null, optionsPane(),
|
||||||
trans.get("pref.dlg.tab.Miscellaneousoptions"));
|
trans.get("pref.dlg.tab.Miscellaneousoptions"));
|
||||||
|
|
||||||
//// Close button
|
//// Close button
|
||||||
JButton close = new JButton(trans.get("dlg.but.close"));
|
JButton close = new JButton(trans.get("dlg.but.close"));
|
||||||
close.addActionListener(new ActionListener() {
|
close.addActionListener(new ActionListener() {
|
||||||
@ -88,25 +88,25 @@ public class PreferencesDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(close, "span, right, tag close");
|
panel.add(close, "span, right, tag close");
|
||||||
|
|
||||||
this.setContentPane(panel);
|
this.setContentPane(panel);
|
||||||
pack();
|
pack();
|
||||||
this.setLocationRelativeTo(null);
|
this.setLocationRelativeTo(null);
|
||||||
|
|
||||||
this.addWindowListener(new WindowAdapter() {
|
this.addWindowListener(new WindowAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void windowClosed(WindowEvent e) {
|
public void windowClosed(WindowEvent e) {
|
||||||
((SwingPreferences) Application.getPreferences()).storeDefaultUnits();
|
((SwingPreferences) Application.getPreferences()).storeDefaultUnits();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
GUIUtil.setDisposableDialogOptions(this, close);
|
GUIUtil.setDisposableDialogOptions(this, close);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JPanel optionsPane() {
|
private JPanel optionsPane() {
|
||||||
JPanel panel = new JPanel(new MigLayout("fillx, ins 30lp n n n"));
|
JPanel panel = new JPanel(new MigLayout("fillx, ins 30lp n n n"));
|
||||||
|
|
||||||
|
|
||||||
//// Language selector
|
//// Language selector
|
||||||
Locale userLocale = null;
|
Locale userLocale = null;
|
||||||
@ -120,7 +120,7 @@ public class PreferencesDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
Collections.sort(locales);
|
Collections.sort(locales);
|
||||||
locales.add(0, new Named<Locale>(null, trans.get("languages.default")));
|
locales.add(0, new Named<Locale>(null, trans.get("languages.default")));
|
||||||
|
|
||||||
final JComboBox languageCombo = new JComboBox(locales.toArray());
|
final JComboBox languageCombo = new JComboBox(locales.toArray());
|
||||||
for (int i = 0; i < locales.size(); i++) {
|
for (int i = 0; i < locales.size(); i++) {
|
||||||
if (Utils.equals(userLocale, locales.get(i).get())) {
|
if (Utils.equals(userLocale, locales.get(i).get())) {
|
||||||
@ -138,9 +138,9 @@ public class PreferencesDialog extends JDialog {
|
|||||||
});
|
});
|
||||||
panel.add(new JLabel(trans.get("lbl.language")), "gapright para");
|
panel.add(new JLabel(trans.get("lbl.language")), "gapright para");
|
||||||
panel.add(languageCombo, "wrap rel, growx, sg combos");
|
panel.add(languageCombo, "wrap rel, growx, sg combos");
|
||||||
|
|
||||||
panel.add(new StyledLabel(trans.get("PreferencesDialog.lbl.languageEffect"), -3, Style.ITALIC), "span, wrap para*2");
|
panel.add(new StyledLabel(trans.get("PreferencesDialog.lbl.languageEffect"), -3, Style.ITALIC), "span, wrap para*2");
|
||||||
|
|
||||||
|
|
||||||
//// Position to insert new body components:
|
//// Position to insert new body components:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Positiontoinsert")), "gapright para");
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Positiontoinsert")), "gapright para");
|
||||||
@ -151,7 +151,7 @@ public class PreferencesDialog extends JDialog {
|
|||||||
trans.get("pref.dlg.PrefChoiseSelector1"),
|
trans.get("pref.dlg.PrefChoiseSelector1"),
|
||||||
trans.get("pref.dlg.PrefChoiseSelector2"),
|
trans.get("pref.dlg.PrefChoiseSelector2"),
|
||||||
trans.get("pref.dlg.PrefChoiseSelector3"))), "wrap para, growx, sg combos");
|
trans.get("pref.dlg.PrefChoiseSelector3"))), "wrap para, growx, sg combos");
|
||||||
|
|
||||||
//// Confirm deletion of simulations:
|
//// Confirm deletion of simulations:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Confirmdeletion")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Confirmdeletion")));
|
||||||
panel.add(new JComboBox(new PrefBooleanSelector(Preferences.CONFIRM_DELETE_SIMULATION,
|
panel.add(new JComboBox(new PrefBooleanSelector(Preferences.CONFIRM_DELETE_SIMULATION,
|
||||||
@ -159,7 +159,7 @@ public class PreferencesDialog extends JDialog {
|
|||||||
//// Confirm
|
//// Confirm
|
||||||
trans.get("pref.dlg.PrefBooleanSelector1"),
|
trans.get("pref.dlg.PrefBooleanSelector1"),
|
||||||
trans.get("pref.dlg.PrefBooleanSelector2"), true)), "wrap 40lp, growx, sg combos");
|
trans.get("pref.dlg.PrefBooleanSelector2"), true)), "wrap 40lp, growx, sg combos");
|
||||||
|
|
||||||
//// User-defined thrust curves:
|
//// User-defined thrust curves:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.User-definedthrust")), "spanx, wrap");
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.User-definedthrust")), "spanx, wrap");
|
||||||
final JTextField field = new JTextField();
|
final JTextField field = new JTextField();
|
||||||
@ -177,17 +177,17 @@ public class PreferencesDialog extends JDialog {
|
|||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertUpdate(DocumentEvent e) {
|
public void insertUpdate(DocumentEvent e) {
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changedUpdate(DocumentEvent e) {
|
public void changedUpdate(DocumentEvent e) {
|
||||||
changed();
|
changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changed() {
|
private void changed() {
|
||||||
String text = field.getText();
|
String text = field.getText();
|
||||||
List<File> list = new ArrayList<File>();
|
List<File> list = new ArrayList<File>();
|
||||||
@ -201,7 +201,7 @@ public class PreferencesDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(field, "w 100px, gapright unrel, spanx, growx, split");
|
panel.add(field, "w 100px, gapright unrel, spanx, growx, split");
|
||||||
|
|
||||||
//// Add button
|
//// Add button
|
||||||
JButton button = new JButton(trans.get("pref.dlg.but.add"));
|
JButton button = new JButton(trans.get("pref.dlg.but.add"));
|
||||||
button.addActionListener(new ActionListener() {
|
button.addActionListener(new ActionListener() {
|
||||||
@ -228,7 +228,7 @@ public class PreferencesDialog extends JDialog {
|
|||||||
if (defaultDirectory != null) {
|
if (defaultDirectory != null) {
|
||||||
chooser.setCurrentDirectory(defaultDirectory);
|
chooser.setCurrentDirectory(defaultDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
//// Add
|
//// Add
|
||||||
int returnVal = chooser.showDialog(PreferencesDialog.this, trans.get("pref.dlg.Add"));
|
int returnVal = chooser.showDialog(PreferencesDialog.this, trans.get("pref.dlg.Add"));
|
||||||
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
if (returnVal == JFileChooser.APPROVE_OPTION) {
|
||||||
@ -244,10 +244,10 @@ public class PreferencesDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(button, "gapright unrel");
|
panel.add(button, "gapright unrel");
|
||||||
|
|
||||||
//// Reset button
|
//// Reset button
|
||||||
button = new JButton(trans.get("pref.dlg.but.reset"));
|
button = new JButton(trans.get("pref.dlg.but.reset"));
|
||||||
|
|
||||||
button.addActionListener(new ActionListener() {
|
button.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@ -257,12 +257,12 @@ public class PreferencesDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(button, "wrap");
|
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.
|
//// 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);
|
DescriptionArea desc = new DescriptionArea(trans.get("pref.dlg.DescriptionArea.Adddirectories"), 3, -3, false);
|
||||||
desc.setBackground(getBackground());
|
desc.setBackground(getBackground());
|
||||||
panel.add(desc, "spanx, growx, wrap 40lp");
|
panel.add(desc, "spanx, growx, wrap 40lp");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//// Check for software updates at startup
|
//// Check for software updates at startup
|
||||||
@ -276,7 +276,7 @@ public class PreferencesDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(softwareUpdateBox);
|
panel.add(softwareUpdateBox);
|
||||||
|
|
||||||
//// Check now button
|
//// Check now button
|
||||||
button = new JButton(trans.get("pref.dlg.but.checknow"));
|
button = new JButton(trans.get("pref.dlg.but.checknow"));
|
||||||
//// Check for software updates now
|
//// Check for software updates now
|
||||||
@ -288,127 +288,137 @@ public class PreferencesDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(button, "right, wrap");
|
panel.add(button, "right, wrap");
|
||||||
|
|
||||||
|
|
||||||
return panel;
|
|
||||||
|
final JCheckBox autoOpenDesignFile = new JCheckBox(trans.get("pref.dlg.but.openlast"));
|
||||||
|
autoOpenDesignFile.setSelected(Application.getPreferences().isAutoOpenLastDesignOnStartupEnabled());
|
||||||
|
autoOpenDesignFile.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
Application.getPreferences().setAutoOpenLastDesignOnStartup(autoOpenDesignFile.isSelected());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(autoOpenDesignFile);
|
||||||
|
|
||||||
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPanel unitsPane() {
|
private JPanel unitsPane() {
|
||||||
JPanel panel = new JPanel(new MigLayout("", "[][]40lp[][]"));
|
JPanel panel = new JPanel(new MigLayout("", "[][]40lp[][]"));
|
||||||
JComboBox combo;
|
JComboBox combo;
|
||||||
|
|
||||||
//// Select your preferred units:
|
//// Select your preferred units:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Selectprefunits")), "span, wrap paragraph");
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Selectprefunits")), "span, wrap paragraph");
|
||||||
|
|
||||||
|
|
||||||
//// Rocket dimensions:
|
//// Rocket dimensions:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Rocketdimensions")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Rocketdimensions")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_LENGTH));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_LENGTH));
|
||||||
panel.add(combo, "sizegroup boxes");
|
panel.add(combo, "sizegroup boxes");
|
||||||
|
|
||||||
//// Line density:
|
//// Line density:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Linedensity")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Linedensity")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_DENSITY_LINE));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_DENSITY_LINE));
|
||||||
panel.add(combo, "sizegroup boxes, wrap");
|
panel.add(combo, "sizegroup boxes, wrap");
|
||||||
|
|
||||||
|
|
||||||
//// Motor dimensions:
|
//// Motor dimensions:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Motordimensions")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Motordimensions")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_MOTOR_DIMENSIONS));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_MOTOR_DIMENSIONS));
|
||||||
panel.add(combo, "sizegroup boxes");
|
panel.add(combo, "sizegroup boxes");
|
||||||
|
|
||||||
//// Surface density:
|
//// Surface density:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Surfacedensity")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Surfacedensity")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_DENSITY_SURFACE));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_DENSITY_SURFACE));
|
||||||
panel.add(combo, "sizegroup boxes, wrap");
|
panel.add(combo, "sizegroup boxes, wrap");
|
||||||
|
|
||||||
|
|
||||||
//// Distance:
|
//// Distance:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Distance")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Distance")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_DISTANCE));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_DISTANCE));
|
||||||
panel.add(combo, "sizegroup boxes");
|
panel.add(combo, "sizegroup boxes");
|
||||||
|
|
||||||
//// Bulk density::
|
//// Bulk density::
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Bulkdensity")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Bulkdensity")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_DENSITY_BULK));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_DENSITY_BULK));
|
||||||
panel.add(combo, "sizegroup boxes, wrap");
|
panel.add(combo, "sizegroup boxes, wrap");
|
||||||
|
|
||||||
|
|
||||||
//// Velocity:
|
//// Velocity:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Velocity")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Velocity")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_VELOCITY));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_VELOCITY));
|
||||||
panel.add(combo, "sizegroup boxes");
|
panel.add(combo, "sizegroup boxes");
|
||||||
|
|
||||||
//// Surface roughness:
|
//// Surface roughness:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Surfaceroughness")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Surfaceroughness")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_ROUGHNESS));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_ROUGHNESS));
|
||||||
panel.add(combo, "sizegroup boxes, wrap");
|
panel.add(combo, "sizegroup boxes, wrap");
|
||||||
|
|
||||||
|
|
||||||
//// Acceleration:
|
//// Acceleration:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Acceleration")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Acceleration")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_ACCELERATION));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_ACCELERATION));
|
||||||
panel.add(combo, "sizegroup boxes");
|
panel.add(combo, "sizegroup boxes");
|
||||||
|
|
||||||
//// Area:
|
//// Area:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Area")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Area")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_AREA));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_AREA));
|
||||||
panel.add(combo, "sizegroup boxes, wrap");
|
panel.add(combo, "sizegroup boxes, wrap");
|
||||||
|
|
||||||
|
|
||||||
//// Mass:
|
//// Mass:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Mass")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Mass")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_MASS));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_MASS));
|
||||||
panel.add(combo, "sizegroup boxes");
|
panel.add(combo, "sizegroup boxes");
|
||||||
|
|
||||||
//// Angle:
|
//// Angle:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Angle")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Angle")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_ANGLE));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_ANGLE));
|
||||||
panel.add(combo, "sizegroup boxes, wrap");
|
panel.add(combo, "sizegroup boxes, wrap");
|
||||||
|
|
||||||
|
|
||||||
//// Force:
|
//// Force:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Force")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Force")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_FORCE));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_FORCE));
|
||||||
panel.add(combo, "sizegroup boxes");
|
panel.add(combo, "sizegroup boxes");
|
||||||
|
|
||||||
//// Roll rate:
|
//// Roll rate:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Rollrate")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Rollrate")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_ROLL));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_ROLL));
|
||||||
panel.add(combo, "sizegroup boxes, wrap");
|
panel.add(combo, "sizegroup boxes, wrap");
|
||||||
|
|
||||||
|
|
||||||
//// Total impulse:
|
//// Total impulse:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Totalimpulse")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Totalimpulse")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_IMPULSE));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_IMPULSE));
|
||||||
panel.add(combo, "sizegroup boxes");
|
panel.add(combo, "sizegroup boxes");
|
||||||
|
|
||||||
//// Temperature:
|
//// Temperature:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Temperature")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Temperature")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_TEMPERATURE));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_TEMPERATURE));
|
||||||
panel.add(combo, "sizegroup boxes, wrap");
|
panel.add(combo, "sizegroup boxes, wrap");
|
||||||
|
|
||||||
//// Moment of inertia:
|
//// Moment of inertia:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Momentofinertia")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Momentofinertia")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_INERTIA));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_INERTIA));
|
||||||
panel.add(combo, "sizegroup boxes");
|
panel.add(combo, "sizegroup boxes");
|
||||||
|
|
||||||
//// Pressure:
|
//// Pressure:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Pressure")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Pressure")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_PRESSURE));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_PRESSURE));
|
||||||
panel.add(combo, "sizegroup boxes, wrap");
|
panel.add(combo, "sizegroup boxes, wrap");
|
||||||
|
|
||||||
|
|
||||||
//// Stability:
|
//// Stability:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Stability")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Stability")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_STABILITY));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_STABILITY));
|
||||||
panel.add(combo, "sizegroup boxes");
|
panel.add(combo, "sizegroup boxes");
|
||||||
|
|
||||||
//// Windspeed:
|
//// Windspeed:
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Windspeed")));
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Windspeed")));
|
||||||
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_WINDSPEED));
|
combo = new JComboBox(new DefaultUnitSelector(UnitGroup.UNITS_WINDSPEED));
|
||||||
panel.add(combo, "sizegroup boxes, wrap para");
|
panel.add(combo, "sizegroup boxes, wrap para");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -423,7 +433,7 @@ public class PreferencesDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(button, "spanx, split 2, grow");
|
panel.add(button, "spanx, split 2, grow");
|
||||||
|
|
||||||
//// Default imperial button
|
//// Default imperial button
|
||||||
button = new JButton(trans.get("pref.dlg.but.defaultimperial"));
|
button = new JButton(trans.get("pref.dlg.but.defaultimperial"));
|
||||||
button.addActionListener(new ActionListener() {
|
button.addActionListener(new ActionListener() {
|
||||||
@ -435,34 +445,34 @@ public class PreferencesDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
panel.add(button, "grow, wrap para");
|
panel.add(button, "grow, wrap para");
|
||||||
|
|
||||||
//// The effects will take place the next time you open a window.
|
//// The effects will take place the next time you open a window.
|
||||||
panel.add(new StyledLabel(
|
panel.add(new StyledLabel(
|
||||||
trans.get("pref.dlg.lbl.effect1"), -2, Style.ITALIC),
|
trans.get("pref.dlg.lbl.effect1"), -2, Style.ITALIC),
|
||||||
"spanx, wrap");
|
"spanx, wrap");
|
||||||
|
|
||||||
|
|
||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private class DefaultUnitSelector extends AbstractListModel implements ComboBoxModel {
|
private class DefaultUnitSelector extends AbstractListModel implements ComboBoxModel {
|
||||||
|
|
||||||
private final UnitGroup group;
|
private final UnitGroup group;
|
||||||
|
|
||||||
public DefaultUnitSelector(UnitGroup group) {
|
public DefaultUnitSelector(UnitGroup group) {
|
||||||
this.group = group;
|
this.group = group;
|
||||||
unitSelectors.add(this);
|
unitSelectors.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getSelectedItem() {
|
public Object getSelectedItem() {
|
||||||
return group.getDefaultUnit();
|
return group.getDefaultUnit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSelectedItem(Object item) {
|
public void setSelectedItem(Object item) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
@ -474,39 +484,39 @@ public class PreferencesDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
group.setDefaultUnit(group.getUnitIndex((Unit) item));
|
group.setDefaultUnit(group.getUnitIndex((Unit) item));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getElementAt(int index) {
|
public Object getElementAt(int index) {
|
||||||
return group.getUnit(index);
|
return group.getUnit(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return group.getUnitCount();
|
return group.getUnitCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void fireChange() {
|
public void fireChange() {
|
||||||
this.fireContentsChanged(this, 0, this.getSize());
|
this.fireContentsChanged(this, 0, this.getSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private class PrefChoiseSelector extends AbstractListModel implements ComboBoxModel {
|
private class PrefChoiseSelector extends AbstractListModel implements ComboBoxModel {
|
||||||
private final String preference;
|
private final String preference;
|
||||||
private final String[] descriptions;
|
private final String[] descriptions;
|
||||||
|
|
||||||
public PrefChoiseSelector(String preference, String... descriptions) {
|
public PrefChoiseSelector(String preference, String... descriptions) {
|
||||||
this.preference = preference;
|
this.preference = preference;
|
||||||
this.descriptions = descriptions;
|
this.descriptions = descriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getSelectedItem() {
|
public Object getSelectedItem() {
|
||||||
return descriptions[Application.getPreferences().getChoice(preference, descriptions.length, 0)];
|
return descriptions[Application.getPreferences().getChoice(preference, descriptions.length, 0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSelectedItem(Object item) {
|
public void setSelectedItem(Object item) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
@ -524,27 +534,27 @@ public class PreferencesDialog extends JDialog {
|
|||||||
if (index >= descriptions.length) {
|
if (index >= descriptions.length) {
|
||||||
throw new IllegalArgumentException("Illegal argument " + item);
|
throw new IllegalArgumentException("Illegal argument " + item);
|
||||||
}
|
}
|
||||||
|
|
||||||
Application.getPreferences().putChoice(preference, index);
|
Application.getPreferences().putChoice(preference, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getElementAt(int index) {
|
public Object getElementAt(int index) {
|
||||||
return descriptions[index];
|
return descriptions[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return descriptions.length;
|
return descriptions.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class PrefBooleanSelector extends AbstractListModel implements ComboBoxModel {
|
private class PrefBooleanSelector extends AbstractListModel implements ComboBoxModel {
|
||||||
private final String preference;
|
private final String preference;
|
||||||
private final String trueDesc, falseDesc;
|
private final String trueDesc, falseDesc;
|
||||||
private final boolean def;
|
private final boolean def;
|
||||||
|
|
||||||
public PrefBooleanSelector(String preference, String falseDescription,
|
public PrefBooleanSelector(String preference, String falseDescription,
|
||||||
String trueDescription, boolean defaultState) {
|
String trueDescription, boolean defaultState) {
|
||||||
this.preference = preference;
|
this.preference = preference;
|
||||||
@ -552,7 +562,7 @@ public class PreferencesDialog extends JDialog {
|
|||||||
this.falseDesc = falseDescription;
|
this.falseDesc = falseDescription;
|
||||||
this.def = defaultState;
|
this.def = defaultState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getSelectedItem() {
|
public Object getSelectedItem() {
|
||||||
if (Application.getPreferences().getBoolean(preference, def)) {
|
if (Application.getPreferences().getBoolean(preference, def)) {
|
||||||
@ -561,7 +571,7 @@ public class PreferencesDialog extends JDialog {
|
|||||||
return falseDesc;
|
return falseDesc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSelectedItem(Object item) {
|
public void setSelectedItem(Object item) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
@ -571,7 +581,7 @@ public class PreferencesDialog extends JDialog {
|
|||||||
if (!(item instanceof String)) {
|
if (!(item instanceof String)) {
|
||||||
throw new IllegalArgumentException("Illegal argument " + item);
|
throw new IllegalArgumentException("Illegal argument " + item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trueDesc.equals(item)) {
|
if (trueDesc.equals(item)) {
|
||||||
Application.getPreferences().putBoolean(preference, true);
|
Application.getPreferences().putBoolean(preference, true);
|
||||||
} else if (falseDesc.equals(item)) {
|
} else if (falseDesc.equals(item)) {
|
||||||
@ -580,44 +590,44 @@ public class PreferencesDialog extends JDialog {
|
|||||||
throw new IllegalArgumentException("Illegal argument " + item);
|
throw new IllegalArgumentException("Illegal argument " + item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getElementAt(int index) {
|
public Object getElementAt(int index) {
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0:
|
case 0:
|
||||||
return def ? trueDesc : falseDesc;
|
return def ? trueDesc : falseDesc;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
return def ? falseDesc : trueDesc;
|
return def ? falseDesc : trueDesc;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new IndexOutOfBoundsException("Boolean asked for index=" + index);
|
throw new IndexOutOfBoundsException("Boolean asked for index=" + index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void checkForUpdates() {
|
private void checkForUpdates() {
|
||||||
final UpdateInfoRetriever retriever = new UpdateInfoRetriever();
|
final UpdateInfoRetriever retriever = new UpdateInfoRetriever();
|
||||||
retriever.start();
|
retriever.start();
|
||||||
|
|
||||||
|
|
||||||
// Progress dialog
|
// Progress dialog
|
||||||
final JDialog dialog = new JDialog(this, ModalityType.APPLICATION_MODAL);
|
final JDialog dialog = new JDialog(this, ModalityType.APPLICATION_MODAL);
|
||||||
JPanel panel = new JPanel(new MigLayout());
|
JPanel panel = new JPanel(new MigLayout());
|
||||||
|
|
||||||
//// Checking for updates...
|
//// Checking for updates...
|
||||||
panel.add(new JLabel(trans.get("pref.dlg.lbl.Checkingupdates")), "wrap");
|
panel.add(new JLabel(trans.get("pref.dlg.lbl.Checkingupdates")), "wrap");
|
||||||
|
|
||||||
JProgressBar bar = new JProgressBar();
|
JProgressBar bar = new JProgressBar();
|
||||||
bar.setIndeterminate(true);
|
bar.setIndeterminate(true);
|
||||||
panel.add(bar, "growx, wrap para");
|
panel.add(bar, "growx, wrap para");
|
||||||
|
|
||||||
//// Cancel button
|
//// Cancel button
|
||||||
JButton cancel = new JButton(trans.get("dlg.but.cancel"));
|
JButton cancel = new JButton(trans.get("dlg.but.cancel"));
|
||||||
cancel.addActionListener(new ActionListener() {
|
cancel.addActionListener(new ActionListener() {
|
||||||
@ -628,14 +638,14 @@ public class PreferencesDialog extends JDialog {
|
|||||||
});
|
});
|
||||||
panel.add(cancel, "right");
|
panel.add(cancel, "right");
|
||||||
dialog.add(panel);
|
dialog.add(panel);
|
||||||
|
|
||||||
GUIUtil.setDisposableDialogOptions(dialog, cancel);
|
GUIUtil.setDisposableDialogOptions(dialog, cancel);
|
||||||
|
|
||||||
|
|
||||||
// Timer to monitor progress
|
// Timer to monitor progress
|
||||||
final Timer timer = new Timer(100, null);
|
final Timer timer = new Timer(100, null);
|
||||||
final long startTime = System.currentTimeMillis();
|
final long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
ActionListener listener = new ActionListener() {
|
ActionListener listener = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@ -647,11 +657,11 @@ public class PreferencesDialog extends JDialog {
|
|||||||
};
|
};
|
||||||
timer.addActionListener(listener);
|
timer.addActionListener(listener);
|
||||||
timer.start();
|
timer.start();
|
||||||
|
|
||||||
|
|
||||||
// Wait for action
|
// Wait for action
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
|
|
||||||
|
|
||||||
// Check result
|
// Check result
|
||||||
UpdateInfo info = retriever.getUpdateInfo();
|
UpdateInfo info = retriever.getUpdateInfo();
|
||||||
@ -678,14 +688,14 @@ public class PreferencesDialog extends JDialog {
|
|||||||
Application.getPreferences().putString(SwingPreferences.LAST_UPDATE, info.getLatestVersion());
|
Application.getPreferences().putString(SwingPreferences.LAST_UPDATE, info.getLatestVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////// Singleton implementation ////////
|
//////// Singleton implementation ////////
|
||||||
|
|
||||||
private static PreferencesDialog dialog = null;
|
private static PreferencesDialog dialog = null;
|
||||||
|
|
||||||
public static void showPreferences(Window parent) {
|
public static void showPreferences(Window parent) {
|
||||||
if (dialog != null) {
|
if (dialog != null) {
|
||||||
dialog.dispose();
|
dialog.dispose();
|
||||||
@ -693,6 +703,6 @@ public class PreferencesDialog extends JDialog {
|
|||||||
dialog = new PreferencesDialog(parent);
|
dialog = new PreferencesDialog(parent);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1058,7 +1058,7 @@ public class BasicFrame extends JFrame {
|
|||||||
log.info("Closing window because it is replaceable");
|
log.info("Closing window because it is replaceable");
|
||||||
closeAction();
|
closeAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Open a file based on a URL.
|
* Open a file based on a URL.
|
||||||
|
@ -56,6 +56,20 @@ public class MRUDesignFile {
|
|||||||
return mruFileList;
|
return mruFileList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the last edited design file.
|
||||||
|
*
|
||||||
|
* @return an absolute file name, or null
|
||||||
|
*/
|
||||||
|
public String getLastEditedDesignFile() {
|
||||||
|
if (!mruFileList.isEmpty()) {
|
||||||
|
return mruFileList.get(0);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the most-recently-used list to the given parameter and fire change events.
|
* Set the most-recently-used list to the given parameter and fire change events.
|
||||||
*
|
*
|
||||||
|
@ -22,7 +22,7 @@ import net.sf.openrocket.util.MathUtil;
|
|||||||
import net.sf.openrocket.util.UniqueID;
|
import net.sf.openrocket.util.UniqueID;
|
||||||
|
|
||||||
public abstract class Preferences {
|
public abstract class Preferences {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Well known string keys to preferences.
|
* Well known string keys to preferences.
|
||||||
* There are other strings out there in the source as well.
|
* There are other strings out there in the source as well.
|
||||||
@ -37,39 +37,40 @@ public abstract class Preferences {
|
|||||||
public static final String EXPORT_EVENT_COMMENTS = "ExportEventComments";
|
public static final String EXPORT_EVENT_COMMENTS = "ExportEventComments";
|
||||||
public static final String EXPORT_COMMENT_CHARACTER = "ExportCommentCharacter";
|
public static final String EXPORT_COMMENT_CHARACTER = "ExportCommentCharacter";
|
||||||
public static final String USER_LOCAL = "locale";
|
public static final String USER_LOCAL = "locale";
|
||||||
|
|
||||||
public static final String PLOT_SHOW_POINTS = "ShowPlotPoints";
|
public static final String PLOT_SHOW_POINTS = "ShowPlotPoints";
|
||||||
|
|
||||||
private static final String CHECK_UPDATES = "CheckUpdates";
|
private static final String CHECK_UPDATES = "CheckUpdates";
|
||||||
public static final String LAST_UPDATE = "LastUpdateVersion";
|
public static final String LAST_UPDATE = "LastUpdateVersion";
|
||||||
|
|
||||||
public static final String MOTOR_DIAMETER_FILTER = "MotorDiameterMatch";
|
public static final String MOTOR_DIAMETER_FILTER = "MotorDiameterMatch";
|
||||||
public static final String MOTOR_HIDE_SIMILAR = "MotorHideSimilar";
|
public static final String MOTOR_HIDE_SIMILAR = "MotorHideSimilar";
|
||||||
|
|
||||||
// Node names
|
// Node names
|
||||||
public static final String PREFERRED_THRUST_CURVE_MOTOR_NODE = "preferredThrustCurveMotors";
|
public static final String PREFERRED_THRUST_CURVE_MOTOR_NODE = "preferredThrustCurveMotors";
|
||||||
|
private static final String AUTO_OPEN_LAST_DESIGN = "AUTO_OPEN_LAST_DESIGN";
|
||||||
/*
|
|
||||||
* ******************************************************************************************
|
/*
|
||||||
*
|
* ******************************************************************************************
|
||||||
* Abstract methods which must be implemented by any derived class.
|
*
|
||||||
*/
|
* Abstract methods which must be implemented by any derived class.
|
||||||
|
*/
|
||||||
public abstract boolean getBoolean(String key, boolean defaultValue);
|
public abstract boolean getBoolean(String key, boolean defaultValue);
|
||||||
|
|
||||||
public abstract void putBoolean(String key, boolean value);
|
public abstract void putBoolean(String key, boolean value);
|
||||||
|
|
||||||
public abstract int getInt(String key, int defaultValue);
|
public abstract int getInt(String key, int defaultValue);
|
||||||
|
|
||||||
public abstract void putInt(String key, int value);
|
public abstract void putInt(String key, int value);
|
||||||
|
|
||||||
public abstract double getDouble(String key, double defaultValue);
|
public abstract double getDouble(String key, double defaultValue);
|
||||||
|
|
||||||
public abstract void putDouble(String key, double value);
|
public abstract void putDouble(String key, double value);
|
||||||
|
|
||||||
public abstract String getString(String key, String defaultValue);
|
public abstract String getString(String key, String defaultValue);
|
||||||
|
|
||||||
public abstract void putString(String key, String value);
|
public abstract void putString(String key, String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directory represents a way to collect multiple keys together. Implementors may
|
* Directory represents a way to collect multiple keys together. Implementors may
|
||||||
* choose to concatenate the directory with the key using some special character.
|
* choose to concatenate the directory with the key using some special character.
|
||||||
@ -79,28 +80,44 @@ public abstract class Preferences {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract String getString(String directory, String key, String defaultValue);
|
public abstract String getString(String directory, String key, String defaultValue);
|
||||||
|
|
||||||
public abstract void putString(String directory, String key, String value);
|
public abstract void putString(String directory, String key, String value);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ******************************************************************************************
|
* ******************************************************************************************
|
||||||
*/
|
*/
|
||||||
public final boolean getCheckUpdates() {
|
public final boolean getCheckUpdates() {
|
||||||
return this.getBoolean(CHECK_UPDATES, BuildProperties.getDefaultCheckUpdates());
|
return this.getBoolean(CHECK_UPDATES, BuildProperties.getDefaultCheckUpdates());
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setCheckUpdates(boolean check) {
|
public final void setCheckUpdates(boolean check) {
|
||||||
this.putBoolean(CHECK_UPDATES, check);
|
this.putBoolean(CHECK_UPDATES, check);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final double getDefaultMach() {
|
public final double getDefaultMach() {
|
||||||
// TODO: HIGH: implement custom default mach number
|
// TODO: HIGH: implement custom default mach number
|
||||||
return 0.3;
|
return 0.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable/Disable the auto-opening of the last edited design file on startup.
|
||||||
|
*/
|
||||||
|
public final void setAutoOpenLastDesignOnStartup(boolean enabled) {
|
||||||
|
this.putBoolean(AUTO_OPEN_LAST_DESIGN, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Answer if the auto-opening of the last edited design file on startup is enabled.
|
||||||
|
*
|
||||||
|
* @return true if the application should automatically open the last edited design file on startup.
|
||||||
|
*/
|
||||||
|
public final boolean isAutoOpenLastDesignOnStartupEnabled() {
|
||||||
|
return this.getBoolean(AUTO_OPEN_LAST_DESIGN, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the OpenRocket unique ID.
|
* Return the OpenRocket unique ID.
|
||||||
*
|
*
|
||||||
* @return a random ID string that stays constant between OpenRocket executions
|
* @return a random ID string that stays constant between OpenRocket executions
|
||||||
*/
|
*/
|
||||||
public final String getUniqueID() {
|
public final String getUniqueID() {
|
||||||
@ -111,12 +128,12 @@ public abstract class Preferences {
|
|||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a limited-range integer value from the preferences. If the value
|
* Returns a limited-range integer value from the preferences. If the value
|
||||||
* in the preferences is negative or greater than max, then the default value
|
* in the preferences is negative or greater than max, then the default value
|
||||||
* is returned.
|
* is returned.
|
||||||
*
|
*
|
||||||
* @param key The preference to retrieve.
|
* @param key The preference to retrieve.
|
||||||
* @param max Maximum allowed value for the choice.
|
* @param max Maximum allowed value for the choice.
|
||||||
* @param def Default value.
|
* @param def Default value.
|
||||||
@ -128,20 +145,20 @@ public abstract class Preferences {
|
|||||||
return def;
|
return def;
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method that puts an integer choice value into the preferences.
|
* Helper method that puts an integer choice value into the preferences.
|
||||||
*
|
*
|
||||||
* @param key the preference key.
|
* @param key the preference key.
|
||||||
* @param value the value to store.
|
* @param value the value to store.
|
||||||
*/
|
*/
|
||||||
public final void putChoice(String key, int value) {
|
public final void putChoice(String key, int value) {
|
||||||
this.putInt(key, value);
|
this.putInt(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve an enum value from the user preferences.
|
* Retrieve an enum value from the user preferences.
|
||||||
*
|
*
|
||||||
* @param <T> the enum type
|
* @param <T> the enum type
|
||||||
* @param key the key
|
* @param key the key
|
||||||
* @param def the default value, cannot be null
|
* @param def the default value, cannot be null
|
||||||
@ -151,22 +168,22 @@ public abstract class Preferences {
|
|||||||
if (def == null) {
|
if (def == null) {
|
||||||
throw new BugException("Default value cannot be null");
|
throw new BugException("Default value cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
String value = getString(key, null);
|
String value = getString(key, null);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return Enum.valueOf(def.getDeclaringClass(), value);
|
return Enum.valueOf(def.getDeclaringClass(), value);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store an enum value to the user preferences.
|
* Store an enum value to the user preferences.
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
* @param value the value to store, or null to remove the value
|
* @param value the value to store, or null to remove the value
|
||||||
*/
|
*/
|
||||||
@ -177,12 +194,12 @@ public abstract class Preferences {
|
|||||||
putString(key, value.name());
|
putString(key, value.name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getDefaultColor(Class<? extends RocketComponent> c) {
|
public Color getDefaultColor(Class<? extends RocketComponent> c) {
|
||||||
String color = get("componentColors", c, DEFAULT_COLORS);
|
String color = get("componentColors", c, DEFAULT_COLORS);
|
||||||
if (color == null)
|
if (color == null)
|
||||||
return Color.BLACK;
|
return Color.BLACK;
|
||||||
|
|
||||||
Color clr = parseColor(color);
|
Color clr = parseColor(color);
|
||||||
if (clr != null) {
|
if (clr != null) {
|
||||||
return clr;
|
return clr;
|
||||||
@ -190,14 +207,14 @@ public abstract class Preferences {
|
|||||||
return Color.BLACK;
|
return Color.BLACK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setDefaultColor(Class<? extends RocketComponent> c, Color color) {
|
public final void setDefaultColor(Class<? extends RocketComponent> c, Color color) {
|
||||||
if (color == null)
|
if (color == null)
|
||||||
return;
|
return;
|
||||||
putString("componentColors", c.getSimpleName(), stringifyColor(color));
|
putString("componentColors", c.getSimpleName(), stringifyColor(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve a Line style for the given component.
|
* Retrieve a Line style for the given component.
|
||||||
* @param c
|
* @param c
|
||||||
@ -211,7 +228,7 @@ public abstract class Preferences {
|
|||||||
return LineStyle.SOLID;
|
return LineStyle.SOLID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a default line style for the given component.
|
* Set a default line style for the given component.
|
||||||
* @param c
|
* @param c
|
||||||
@ -223,7 +240,7 @@ public abstract class Preferences {
|
|||||||
return;
|
return;
|
||||||
putString("componentStyle", c.getSimpleName(), style.name());
|
putString("componentStyle", c.getSimpleName(), style.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the default material type for the given component.
|
* Get the default material type for the given component.
|
||||||
* @param componentClass
|
* @param componentClass
|
||||||
@ -233,7 +250,7 @@ public abstract class Preferences {
|
|||||||
public Material getDefaultComponentMaterial(
|
public Material getDefaultComponentMaterial(
|
||||||
Class<? extends RocketComponent> componentClass,
|
Class<? extends RocketComponent> componentClass,
|
||||||
Material.Type type) {
|
Material.Type type) {
|
||||||
|
|
||||||
String material = get("componentMaterials", componentClass, null);
|
String material = get("componentMaterials", componentClass, null);
|
||||||
if (material != null) {
|
if (material != null) {
|
||||||
try {
|
try {
|
||||||
@ -243,7 +260,7 @@ public abstract class Preferences {
|
|||||||
} catch (IllegalArgumentException ignore) {
|
} catch (IllegalArgumentException ignore) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case LINE:
|
case LINE:
|
||||||
return DefaultMaterialHolder.DEFAULT_LINE_MATERIAL;
|
return DefaultMaterialHolder.DEFAULT_LINE_MATERIAL;
|
||||||
@ -254,7 +271,7 @@ public abstract class Preferences {
|
|||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Unknown material type: " + type);
|
throw new IllegalArgumentException("Unknown material type: " + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the default material for a component type.
|
* Set the default material for a component type.
|
||||||
* @param componentClass
|
* @param componentClass
|
||||||
@ -262,11 +279,11 @@ public abstract class Preferences {
|
|||||||
*/
|
*/
|
||||||
public void setDefaultComponentMaterial(
|
public void setDefaultComponentMaterial(
|
||||||
Class<? extends RocketComponent> componentClass, Material material) {
|
Class<? extends RocketComponent> componentClass, Material material) {
|
||||||
|
|
||||||
putString("componentMaterials", componentClass.getSimpleName(),
|
putString("componentMaterials", componentClass.getSimpleName(),
|
||||||
material == null ? null : material.toStorableString());
|
material == null ? null : material.toStorableString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get a net.sf.openrocket.util.Color object for the given key.
|
* get a net.sf.openrocket.util.Color object for the given key.
|
||||||
* @param key
|
* @param key
|
||||||
@ -280,7 +297,7 @@ public abstract class Preferences {
|
|||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set a net.sf.openrocket.util.Color preference value for the given key.
|
* set a net.sf.openrocket.util.Color preference value for the given key.
|
||||||
* @param key
|
* @param key
|
||||||
@ -289,7 +306,7 @@ public abstract class Preferences {
|
|||||||
public final void putColor(String key, Color value) {
|
public final void putColor(String key, Color value) {
|
||||||
putString(key, stringifyColor(value));
|
putString(key, stringifyColor(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to convert a string representation into a net.sf.openrocket.util.Color object.
|
* Helper function to convert a string representation into a net.sf.openrocket.util.Color object.
|
||||||
* @param color
|
* @param color
|
||||||
@ -299,7 +316,7 @@ public abstract class Preferences {
|
|||||||
if (color == null) {
|
if (color == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] rgb = color.split(",");
|
String[] rgb = color.split(",");
|
||||||
if (rgb.length == 3) {
|
if (rgb.length == 3) {
|
||||||
try {
|
try {
|
||||||
@ -312,7 +329,7 @@ public abstract class Preferences {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to convert a net.sf.openrocket.util.Color object into a
|
* Helper function to convert a net.sf.openrocket.util.Color object into a
|
||||||
* String before storing in a preference.
|
* String before storing in a preference.
|
||||||
@ -323,13 +340,13 @@ public abstract class Preferences {
|
|||||||
String string = color.getRed() + "," + color.getGreen() + "," + color.getBlue();
|
String string = color.getRed() + "," + color.getGreen() + "," + color.getBlue();
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special helper function which allows for a map of default values.
|
* Special helper function which allows for a map of default values.
|
||||||
*
|
*
|
||||||
* First getString(directory,componentClass.getSimpleName(), null) is invoked,
|
* First getString(directory,componentClass.getSimpleName(), null) is invoked,
|
||||||
* if the returned value is null, the defaultMap is consulted for a value.
|
* if the returned value is null, the defaultMap is consulted for a value.
|
||||||
*
|
*
|
||||||
* @param directory
|
* @param directory
|
||||||
* @param componentClass
|
* @param componentClass
|
||||||
* @param defaultMap
|
* @param defaultMap
|
||||||
@ -338,7 +355,7 @@ public abstract class Preferences {
|
|||||||
protected String get(String directory,
|
protected String get(String directory,
|
||||||
Class<? extends RocketComponent> componentClass,
|
Class<? extends RocketComponent> componentClass,
|
||||||
Map<Class<?>, String> defaultMap) {
|
Map<Class<?>, String> defaultMap) {
|
||||||
|
|
||||||
// Search preferences
|
// Search preferences
|
||||||
Class<?> c = componentClass;
|
Class<?> c = componentClass;
|
||||||
while (c != null && RocketComponent.class.isAssignableFrom(c)) {
|
while (c != null && RocketComponent.class.isAssignableFrom(c)) {
|
||||||
@ -347,10 +364,10 @@ public abstract class Preferences {
|
|||||||
return value;
|
return value;
|
||||||
c = c.getSuperclass();
|
c = c.getSuperclass();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defaultMap == null)
|
if (defaultMap == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// Search defaults
|
// Search defaults
|
||||||
c = componentClass;
|
c = componentClass;
|
||||||
while (RocketComponent.class.isAssignableFrom(c)) {
|
while (RocketComponent.class.isAssignableFrom(c)) {
|
||||||
@ -359,20 +376,20 @@ public abstract class Preferences {
|
|||||||
return value;
|
return value;
|
||||||
c = c.getSuperclass();
|
c = c.getSuperclass();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void addUserMaterial(Material m);
|
public abstract void addUserMaterial(Material m);
|
||||||
|
|
||||||
public abstract Set<Material> getUserMaterials();
|
public abstract Set<Material> getUserMaterials();
|
||||||
|
|
||||||
public abstract void removeUserMaterial(Material m);
|
public abstract void removeUserMaterial(Material m);
|
||||||
|
|
||||||
public abstract void setComponentFavorite(ComponentPreset preset, ComponentPreset.Type type, boolean favorite);
|
public abstract void setComponentFavorite(ComponentPreset preset, ComponentPreset.Type type, boolean favorite);
|
||||||
|
|
||||||
public abstract Set<String> getComponentFavorites(ComponentPreset.Type type);
|
public abstract Set<String> getComponentFavorites(ComponentPreset.Type type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map of default line styles
|
* Map of default line styles
|
||||||
*/
|
*/
|
||||||
@ -382,7 +399,7 @@ public abstract class Preferences {
|
|||||||
DEFAULT_LINE_STYLES.put(RocketComponent.class, LineStyle.SOLID.name());
|
DEFAULT_LINE_STYLES.put(RocketComponent.class, LineStyle.SOLID.name());
|
||||||
DEFAULT_LINE_STYLES.put(MassObject.class, LineStyle.DASHED.name());
|
DEFAULT_LINE_STYLES.put(MassObject.class, LineStyle.DASHED.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Within a holder class so they will load only when needed.
|
* Within a holder class so they will load only when needed.
|
||||||
*/
|
*/
|
||||||
@ -391,7 +408,7 @@ public abstract class Preferences {
|
|||||||
private static final Material DEFAULT_SURFACE_MATERIAL = Databases.findMaterial(Material.Type.SURFACE, "Ripstop nylon");
|
private static final Material DEFAULT_SURFACE_MATERIAL = Databases.findMaterial(Material.Type.SURFACE, "Ripstop nylon");
|
||||||
private static final Material DEFAULT_BULK_MATERIAL = Databases.findMaterial(Material.Type.BULK, "Cardboard");
|
private static final Material DEFAULT_BULK_MATERIAL = Databases.findMaterial(Material.Type.BULK, "Cardboard");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HashMap<Class<?>, String> DEFAULT_COLORS =
|
private static final HashMap<Class<?>, String> DEFAULT_COLORS =
|
||||||
new HashMap<Class<?>, String>();
|
new HashMap<Class<?>, String>();
|
||||||
static {
|
static {
|
||||||
@ -402,7 +419,7 @@ public abstract class Preferences {
|
|||||||
DEFAULT_COLORS.put(MassObject.class, "0,0,0");
|
DEFAULT_COLORS.put(MassObject.class, "0,0,0");
|
||||||
DEFAULT_COLORS.put(RecoveryDevice.class, "255,0,0");
|
DEFAULT_COLORS.put(RecoveryDevice.class, "255,0,0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ import net.sf.openrocket.database.ComponentPresetDatabase;
|
|||||||
import net.sf.openrocket.database.Databases;
|
import net.sf.openrocket.database.Databases;
|
||||||
import net.sf.openrocket.gui.dialogs.UpdateInfoDialog;
|
import net.sf.openrocket.gui.dialogs.UpdateInfoDialog;
|
||||||
import net.sf.openrocket.gui.main.BasicFrame;
|
import net.sf.openrocket.gui.main.BasicFrame;
|
||||||
|
import net.sf.openrocket.gui.main.MRUDesignFile;
|
||||||
import net.sf.openrocket.gui.main.Splash;
|
import net.sf.openrocket.gui.main.Splash;
|
||||||
import net.sf.openrocket.gui.main.SwingExceptionHandler;
|
import net.sf.openrocket.gui.main.SwingExceptionHandler;
|
||||||
import net.sf.openrocket.gui.util.GUIUtil;
|
import net.sf.openrocket.gui.util.GUIUtil;
|
||||||
@ -27,38 +28,38 @@ import net.sf.openrocket.util.BuildProperties;
|
|||||||
/**
|
/**
|
||||||
* The second class in the OpenRocket startup sequence. This class can assume the
|
* The second class in the OpenRocket startup sequence. This class can assume the
|
||||||
* Application class to be properly set up, and can use any classes safely.
|
* Application class to be properly set up, and can use any classes safely.
|
||||||
*
|
*
|
||||||
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
* @author Sampo Niskanen <sampo.niskanen@iki.fi>
|
||||||
*/
|
*/
|
||||||
public class Startup2 {
|
public class Startup2 {
|
||||||
private static final LogHelper log = Application.getLogger();
|
private static final LogHelper log = Application.getLogger();
|
||||||
|
|
||||||
|
|
||||||
private static final String THRUSTCURVE_DIRECTORY = "datafiles/thrustcurves/";
|
private static final String THRUSTCURVE_DIRECTORY = "datafiles/thrustcurves/";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run when starting up OpenRocket after Application has been set up.
|
* Run when starting up OpenRocket after Application has been set up.
|
||||||
*
|
*
|
||||||
* @param args command line arguments
|
* @param args command line arguments
|
||||||
*/
|
*/
|
||||||
static void runMain(final String[] args) throws Exception {
|
static void runMain(final String[] args) throws Exception {
|
||||||
|
|
||||||
log.info("Starting up OpenRocket version " + BuildProperties.getVersion());
|
log.info("Starting up OpenRocket version " + BuildProperties.getVersion());
|
||||||
|
|
||||||
// Check that we're not running headless
|
// Check that we're not running headless
|
||||||
log.info("Checking for graphics head");
|
log.info("Checking for graphics head");
|
||||||
checkHead();
|
checkHead();
|
||||||
|
|
||||||
// Check that we're running a good version of a JRE
|
// Check that we're running a good version of a JRE
|
||||||
log.info("Checking JRE compatibility");
|
log.info("Checking JRE compatibility");
|
||||||
VersionHelper.checkVersion();
|
VersionHelper.checkVersion();
|
||||||
VersionHelper.checkOpenJDK();
|
VersionHelper.checkOpenJDK();
|
||||||
|
|
||||||
// If running on a MAC set up OSX UI Elements.
|
// If running on a MAC set up OSX UI Elements.
|
||||||
if ( SystemInfo.getPlatform() == Platform.MAC_OS ){
|
if ( SystemInfo.getPlatform() == Platform.MAC_OS ){
|
||||||
OSXStartup.setupOSX();
|
OSXStartup.setupOSX();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the actual startup method in the EDT since it can use progress dialogs etc.
|
// Run the actual startup method in the EDT since it can use progress dialogs etc.
|
||||||
log.info("Moving startup to EDT");
|
log.info("Moving startup to EDT");
|
||||||
SwingUtilities.invokeAndWait(new Runnable() {
|
SwingUtilities.invokeAndWait(new Runnable() {
|
||||||
@ -67,22 +68,22 @@ public class Startup2 {
|
|||||||
runInEDT(args);
|
runInEDT(args);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
log.info("Startup complete");
|
log.info("Startup complete");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run in the EDT when starting up OpenRocket.
|
* Run in the EDT when starting up OpenRocket.
|
||||||
*
|
*
|
||||||
* @param args command line arguments
|
* @param args command line arguments
|
||||||
*/
|
*/
|
||||||
private static void runInEDT(String[] args) {
|
private static void runInEDT(String[] args) {
|
||||||
|
|
||||||
// Initialize the splash screen with version info
|
// Initialize the splash screen with version info
|
||||||
log.info("Initializing the splash screen");
|
log.info("Initializing the splash screen");
|
||||||
Splash.init();
|
Splash.init();
|
||||||
|
|
||||||
// Must be done after localization is initialized
|
// Must be done after localization is initialized
|
||||||
ComponentPresetDatabase componentPresetDao = new ComponentPresetDatabase(true) {
|
ComponentPresetDatabase componentPresetDao = new ComponentPresetDatabase(true) {
|
||||||
|
|
||||||
@ -93,21 +94,21 @@ public class Startup2 {
|
|||||||
try {
|
try {
|
||||||
presetLoader.await();
|
presetLoader.await();
|
||||||
} catch ( InterruptedException iex) {
|
} catch ( InterruptedException iex) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
Application.setComponentPresetDao( componentPresetDao );
|
Application.setComponentPresetDao( componentPresetDao );
|
||||||
|
|
||||||
componentPresetDao.startLoading();
|
componentPresetDao.startLoading();
|
||||||
|
|
||||||
// Setup the uncaught exception handler
|
// Setup the uncaught exception handler
|
||||||
log.info("Registering exception handler");
|
log.info("Registering exception handler");
|
||||||
SwingExceptionHandler exceptionHandler = new SwingExceptionHandler();
|
SwingExceptionHandler exceptionHandler = new SwingExceptionHandler();
|
||||||
Application.setExceptionHandler(exceptionHandler);
|
Application.setExceptionHandler(exceptionHandler);
|
||||||
exceptionHandler.registerExceptionHandler();
|
exceptionHandler.registerExceptionHandler();
|
||||||
|
|
||||||
// Start update info fetching
|
// Start update info fetching
|
||||||
final UpdateInfoRetriever updateInfo;
|
final UpdateInfoRetriever updateInfo;
|
||||||
if ( Application.getPreferences().getCheckUpdates()) {
|
if ( Application.getPreferences().getCheckUpdates()) {
|
||||||
@ -118,37 +119,54 @@ public class Startup2 {
|
|||||||
log.info("Update check disabled");
|
log.info("Update check disabled");
|
||||||
updateInfo = null;
|
updateInfo = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the best available look-and-feel
|
// Set the best available look-and-feel
|
||||||
log.info("Setting best LAF");
|
log.info("Setting best LAF");
|
||||||
GUIUtil.setBestLAF();
|
GUIUtil.setBestLAF();
|
||||||
|
|
||||||
// Set tooltip delay time. Tooltips are used in MotorChooserDialog extensively.
|
// Set tooltip delay time. Tooltips are used in MotorChooserDialog extensively.
|
||||||
ToolTipManager.sharedInstance().setDismissDelay(30000);
|
ToolTipManager.sharedInstance().setDismissDelay(30000);
|
||||||
|
|
||||||
// Load defaults
|
// Load defaults
|
||||||
((SwingPreferences) Application.getPreferences()).loadDefaultUnits();
|
((SwingPreferences) Application.getPreferences()).loadDefaultUnits();
|
||||||
|
|
||||||
// Load motors etc.
|
// Load motors etc.
|
||||||
log.info("Loading databases");
|
log.info("Loading databases");
|
||||||
|
|
||||||
loadMotor();
|
loadMotor();
|
||||||
|
|
||||||
Databases.fakeMethod();
|
Databases.fakeMethod();
|
||||||
|
|
||||||
|
|
||||||
// Starting action (load files or open new document)
|
// Starting action (load files or open new document)
|
||||||
log.info("Opening main application window");
|
log.info("Opening main application window");
|
||||||
if (!handleCommandLine(args)) {
|
if (!handleCommandLine(args)) {
|
||||||
BasicFrame.newAction();
|
if (!Application.getPreferences().isAutoOpenLastDesignOnStartupEnabled()) {
|
||||||
}
|
BasicFrame.newAction();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
String lastFile = MRUDesignFile.getInstance().getLastEditedDesignFile();
|
||||||
|
if (lastFile != null) {
|
||||||
|
if (!BasicFrame.open(new File(lastFile), null)) {
|
||||||
|
MRUDesignFile.getInstance().removeFile(lastFile);
|
||||||
|
BasicFrame.newAction();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MRUDesignFile.getInstance().addFile(lastFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BasicFrame.newAction();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check whether update info has been fetched or whether it needs more time
|
// Check whether update info has been fetched or whether it needs more time
|
||||||
log.info("Checking update status");
|
log.info("Checking update status");
|
||||||
checkUpdateStatus(updateInfo);
|
checkUpdateStatus(updateInfo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this method is useful for the python bindings.
|
* this method is useful for the python bindings.
|
||||||
*/
|
*/
|
||||||
@ -157,12 +175,12 @@ public class Startup2 {
|
|||||||
motorLoader.startLoading();
|
motorLoader.startLoading();
|
||||||
Application.setMotorSetDatabase(motorLoader);
|
Application.setMotorSetDatabase(motorLoader);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that the JRE is not running headless.
|
* Check that the JRE is not running headless.
|
||||||
*/
|
*/
|
||||||
private static void checkHead() {
|
private static void checkHead() {
|
||||||
|
|
||||||
if (GraphicsEnvironment.isHeadless()) {
|
if (GraphicsEnvironment.isHeadless()) {
|
||||||
log.error("Application is headless.");
|
log.error("Application is headless.");
|
||||||
System.err.println();
|
System.err.println();
|
||||||
@ -171,36 +189,36 @@ public class Startup2 {
|
|||||||
System.err.println();
|
System.err.println();
|
||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static void checkUpdateStatus(final UpdateInfoRetriever updateInfo) {
|
private static void checkUpdateStatus(final UpdateInfoRetriever updateInfo) {
|
||||||
if (updateInfo == null)
|
if (updateInfo == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int delay = 1000;
|
int delay = 1000;
|
||||||
if (!updateInfo.isRunning())
|
if (!updateInfo.isRunning())
|
||||||
delay = 100;
|
delay = 100;
|
||||||
|
|
||||||
final Timer timer = new Timer(delay, null);
|
final Timer timer = new Timer(delay, null);
|
||||||
|
|
||||||
ActionListener listener = new ActionListener() {
|
ActionListener listener = new ActionListener() {
|
||||||
private int count = 5;
|
private int count = 5;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (!updateInfo.isRunning()) {
|
if (!updateInfo.isRunning()) {
|
||||||
timer.stop();
|
timer.stop();
|
||||||
|
|
||||||
String current = BuildProperties.getVersion();
|
String current = BuildProperties.getVersion();
|
||||||
String last = Application.getPreferences().getString(Preferences.LAST_UPDATE, "");
|
String last = Application.getPreferences().getString(Preferences.LAST_UPDATE, "");
|
||||||
|
|
||||||
UpdateInfo info = updateInfo.getUpdateInfo();
|
UpdateInfo info = updateInfo.getUpdateInfo();
|
||||||
if (info != null && info.getLatestVersion() != null &&
|
if (info != null && info.getLatestVersion() != null &&
|
||||||
!current.equals(info.getLatestVersion()) &&
|
!current.equals(info.getLatestVersion()) &&
|
||||||
!last.equals(info.getLatestVersion())) {
|
!last.equals(info.getLatestVersion())) {
|
||||||
|
|
||||||
UpdateInfoDialog infoDialog = new UpdateInfoDialog(info);
|
UpdateInfoDialog infoDialog = new UpdateInfoDialog(info);
|
||||||
infoDialog.setVisible(true);
|
infoDialog.setVisible(true);
|
||||||
if (infoDialog.isReminderSelected()) {
|
if (infoDialog.isReminderSelected()) {
|
||||||
@ -218,18 +236,18 @@ public class Startup2 {
|
|||||||
timer.addActionListener(listener);
|
timer.addActionListener(listener);
|
||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles arguments passed from the command line. This may be used either
|
* Handles arguments passed from the command line. This may be used either
|
||||||
* when starting the first instance of OpenRocket or later when OpenRocket is
|
* when starting the first instance of OpenRocket or later when OpenRocket is
|
||||||
* executed again while running.
|
* executed again while running.
|
||||||
*
|
*
|
||||||
* @param args the command-line arguments.
|
* @param args the command-line arguments.
|
||||||
* @return whether a new frame was opened or similar user desired action was
|
* @return whether a new frame was opened or similar user desired action was
|
||||||
* performed as a result.
|
* performed as a result.
|
||||||
*/
|
*/
|
||||||
private static boolean handleCommandLine(String[] args) {
|
private static boolean handleCommandLine(String[] args) {
|
||||||
|
|
||||||
// Check command-line for files
|
// Check command-line for files
|
||||||
boolean opened = false;
|
boolean opened = false;
|
||||||
for (String file : args) {
|
for (String file : args) {
|
||||||
@ -239,5 +257,5 @@ public class Startup2 {
|
|||||||
}
|
}
|
||||||
return opened;
|
return opened;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user