Added message properties and prefs for showing warning dialogs.

Restored auto-open last design preference.
This commit is contained in:
Kevin Ruland 2015-10-28 06:27:55 -05:00
parent f5786d8d90
commit e8167ac159
3 changed files with 71 additions and 5 deletions

View File

@ -259,6 +259,9 @@ pref.dlg.tab.Simulation = Simulation
pref.dlg.tab.Launch = Launch pref.dlg.tab.Launch = Launch
pref.dlg.tab.Miscellaneousoptions = Miscellaneous options pref.dlg.tab.Miscellaneousoptions = Miscellaneous options
pref.dlg.lbl.RockSimWarning = Show warning when saving in RockSim format
pref.dlg.lbl.FileExtensionWarning = Show warning when saving with unusual file name extension
pref.dlg.tab.Graphics = Graphics pref.dlg.tab.Graphics = Graphics
pref.dlg.lbl.DecalEditor = Graphics Editor pref.dlg.lbl.DecalEditor = Graphics Editor
pref.dlg.opengl.lbl.title = 3D Graphics pref.dlg.opengl.lbl.title = 3D Graphics
@ -1134,6 +1137,15 @@ FinsetCfg.ttip.Finfillets1 = <HTML>Adds the predicted mass of fin fillets to the
FinsetCfg.ttip.Finfillets2 = Assumes the fillet is concave and tangent to the body tube and fin.<br> FinsetCfg.ttip.Finfillets2 = Assumes the fillet is concave and tangent to the body tube and fin.<br>
FinsetCfg.ttip.Finfillets3 = Zero radius will give no fillet. FinsetCfg.ttip.Finfillets3 = Zero radius will give no fillet.
! Save RKT Warning Dialog
SaveRktWarningDialog.txt1="The RockSim file format does not support all features of OpenRocket."
SaveRktWarningDialog.txt2="Do you want to save in RockSim .RKT format or OpenRocket .ORK format?"
SaveRktWarningDialog.btn.rkt="Save as RKT"
SaveRktWarningDialog.btn.ork="Save as ORK"
! SaveExtensionWarningDialog
SaveExtensionWarningDialog.txt="The file format {} usually has the extension {}"
! StorageOptionChooser ! StorageOptionChooser
StorageOptChooser.lbl.Simdatatostore = Simulated data to store: StorageOptChooser.lbl.Simdatatostore = Simulated data to store:
StorageOptChooser.rdbut.Allsimdata = All simulated data StorageOptChooser.rdbut.Allsimdata = All simulated data

View File

@ -61,6 +61,8 @@ public abstract class Preferences implements ChangeSource {
// 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"; private static final String AUTO_OPEN_LAST_DESIGN = "AUTO_OPEN_LAST_DESIGN";
private static final String SHOW_ROCKSIM_FORMAT_WARNING = "SHOW_ROCKSIM_FORMAT_WARNING";
private static final String SHOW_FILE_EXTENSION_WARNING = "SHOW_FILE_EXTENSION_WARNING";
//Preferences related to 3D graphics //Preferences related to 3D graphics
public static final String OPENGL_ENABLED = "OpenGL_Is_Enabled"; public static final String OPENGL_ENABLED = "OpenGL_Is_Enabled";
@ -162,6 +164,22 @@ public abstract class Preferences implements ChangeSource {
this.putBoolean(LAUNCH_INTO_WIND, check); this.putBoolean(LAUNCH_INTO_WIND, check);
} }
public final boolean getShowRockSimFormatWarning() {
return this.getBoolean(SHOW_ROCKSIM_FORMAT_WARNING, true);
}
public final void setShowRockSimFormatWarning(boolean check) {
this.putBoolean(SHOW_ROCKSIM_FORMAT_WARNING, check);
}
public final boolean getShowFileExtensionWarning() {
return this.getBoolean(SHOW_FILE_EXTENSION_WARNING, true);
}
public final void setShowFileExtensionWarning(boolean check) {
this.putBoolean(SHOW_FILE_EXTENSION_WARNING, check);
}
public final double getDefaultMach() { public final double getDefaultMach() {
return Application.getPreferences().getChoice(Preferences.DEFAULT_MACH_NUMBER, 0.9, 0.3); return Application.getPreferences().getChoice(Preferences.DEFAULT_MACH_NUMBER, 0.9, 0.3);
} }
@ -533,7 +551,7 @@ public abstract class Preferences implements ChangeSource {
String color = get("componentColors", c, StaticFieldHolder.DEFAULT_COLORS); String color = get("componentColors", c, StaticFieldHolder.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;
@ -584,7 +602,7 @@ public abstract class Preferences implements ChangeSource {
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 {
@ -613,7 +631,7 @@ public abstract class Preferences implements ChangeSource {
*/ */
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());
} }
@ -689,7 +707,7 @@ public abstract class Preferences implements ChangeSource {
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)) {
@ -701,7 +719,7 @@ public abstract class Preferences implements ChangeSource {
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)) {
@ -736,12 +754,14 @@ public abstract class Preferences implements ChangeSource {
*/ */
private static final HashMap<Class<?>, String> DEFAULT_LINE_STYLES = new HashMap<Class<?>, String>(); private static final HashMap<Class<?>, String> DEFAULT_LINE_STYLES = new HashMap<Class<?>, String>();
static { static {
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());
} }
private static final HashMap<Class<?>, String> DEFAULT_COLORS = new HashMap<Class<?>, String>(); private static final HashMap<Class<?>, String> DEFAULT_COLORS = new HashMap<Class<?>, String>();
static { static {
DEFAULT_COLORS.put(BodyComponent.class, "0,0,240"); DEFAULT_COLORS.put(BodyComponent.class, "0,0,240");
DEFAULT_COLORS.put(TubeFinSet.class, "0,0,200"); DEFAULT_COLORS.put(TubeFinSet.class, "0,0,200");

View File

@ -208,6 +208,40 @@ public class GeneralPreferencesPanel extends PreferencesPanel {
} }
}); });
this.add(button, "right, wrap"); this.add(button, "right, wrap");
//// Open most recent file on startup
final JCheckBox openRecentOnStartupBox = new JCheckBox(trans.get("pref.dlg.but.openlast"));
openRecentOnStartupBox.setSelected(preferences.isAutoOpenLastDesignOnStartupEnabled());
openRecentOnStartupBox.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
preferences.setAutoOpenLastDesignOnStartup(openRecentOnStartupBox.isSelected());
}
});
this.add(openRecentOnStartupBox,"spanx, wrap");
//// Save RockSim Format warning dialog
final JCheckBox rocksimWarningDialogBox = new JCheckBox(trans.get("pref.dlg.lbl.RockSimWarning"));
rocksimWarningDialogBox.setSelected(preferences.getShowRockSimFormatWarning());
rocksimWarningDialogBox.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
preferences.setShowRockSimFormatWarning(rocksimWarningDialogBox.isSelected());
}
});
this.add(rocksimWarningDialogBox,"spanx, wrap");
//// Extension Format warning dialog
final JCheckBox extensionWarningDialoBox = new JCheckBox(trans.get("pref.dlg.lbl.FileExtensionWarning"));
extensionWarningDialoBox.setSelected(preferences.getShowFileExtensionWarning());
extensionWarningDialoBox.addActionListener( new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
preferences.setShowFileExtensionWarning(extensionWarningDialoBox.isSelected());
}
});
this.add(extensionWarningDialoBox,"spanx, wrap");
} }