Add preference saving for decimal places & exponential notation
This commit is contained in:
parent
34279641c9
commit
e6622c7326
@ -46,6 +46,8 @@ public abstract class Preferences implements ChangeSource {
|
|||||||
public static final String DEFAULT_MACH_NUMBER = "DefaultMachNumber";
|
public static final String DEFAULT_MACH_NUMBER = "DefaultMachNumber";
|
||||||
// Preferences related to data export
|
// Preferences related to data export
|
||||||
public static final String EXPORT_FIELD_SEPARATOR = "ExportFieldSeparator";
|
public static final String EXPORT_FIELD_SEPARATOR = "ExportFieldSeparator";
|
||||||
|
public static final String EXPORT_DECIMAL_PLACES = "ExportDecimalPlaces";
|
||||||
|
public static final String EXPORT_EXPONENTIAL_NOTATION = "ExportExponentialNotation";
|
||||||
public static final String EXPORT_SIMULATION_COMMENT = "ExportSimulationComment";
|
public static final String EXPORT_SIMULATION_COMMENT = "ExportSimulationComment";
|
||||||
public static final String EXPORT_FIELD_NAME_COMMENT = "ExportFieldDescriptionComment";
|
public static final String EXPORT_FIELD_NAME_COMMENT = "ExportFieldDescriptionComment";
|
||||||
public static final String EXPORT_EVENT_COMMENTS = "ExportEventComments";
|
public static final String EXPORT_EVENT_COMMENTS = "ExportEventComments";
|
||||||
|
@ -10,6 +10,7 @@ import javax.swing.SpinnerModel;
|
|||||||
import javax.swing.SpinnerNumberModel;
|
import javax.swing.SpinnerNumberModel;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
import net.sf.openrocket.gui.util.SaveCSVWorker;
|
||||||
import net.sf.openrocket.l10n.Translator;
|
import net.sf.openrocket.l10n.Translator;
|
||||||
import net.sf.openrocket.startup.Application;
|
import net.sf.openrocket.startup.Application;
|
||||||
import net.sf.openrocket.startup.Preferences;
|
import net.sf.openrocket.startup.Preferences;
|
||||||
@ -75,17 +76,17 @@ public class CsvOptionPanel extends JPanel {
|
|||||||
label.setToolTipText(trans.get("SimExpPan.lbl.DecimalPlaces.ttip"));
|
label.setToolTipText(trans.get("SimExpPan.lbl.DecimalPlaces.ttip"));
|
||||||
panel.add(label, "gapright unrel");
|
panel.add(label, "gapright unrel");
|
||||||
|
|
||||||
SpinnerModel dpModel = new SpinnerNumberModel(3, 0, 15, 1);
|
SpinnerModel dpModel = new SpinnerNumberModel(Application.getPreferences().getInt(Preferences.EXPORT_DECIMAL_PLACES, SaveCSVWorker.DEFAULT_DECIMAL_PLACES),
|
||||||
|
0, 15, 1);
|
||||||
decimalPlacesSpinner = new JSpinner(dpModel);
|
decimalPlacesSpinner = new JSpinner(dpModel);
|
||||||
decimalPlacesSpinner.setToolTipText(trans.get("SimExpPan.lbl.DecimalPlaces.ttip"));
|
decimalPlacesSpinner.setToolTipText(trans.get("SimExpPan.lbl.DecimalPlaces.ttip"));
|
||||||
panel.add(decimalPlacesSpinner, "growx, wrap");
|
panel.add(decimalPlacesSpinner, "growx, wrap");
|
||||||
// TODO: preferences + action
|
|
||||||
|
|
||||||
//// Exponential notation
|
//// Exponential notation
|
||||||
exponentialNotationCheckbox = new JCheckBox(trans.get("SimExpPan.lbl.ExponentialNotation"));
|
exponentialNotationCheckbox = new JCheckBox(trans.get("SimExpPan.lbl.ExponentialNotation"));
|
||||||
exponentialNotationCheckbox.setToolTipText(trans.get("SimExpPan.lbl.ExponentialNotation.ttip"));
|
exponentialNotationCheckbox.setToolTipText(trans.get("SimExpPan.lbl.ExponentialNotation.ttip"));
|
||||||
|
exponentialNotationCheckbox.setSelected(Application.getPreferences().getBoolean(Preferences.EXPORT_EXPONENTIAL_NOTATION, true));
|
||||||
panel.add(exponentialNotationCheckbox);
|
panel.add(exponentialNotationCheckbox);
|
||||||
// TODO: preferences + action
|
|
||||||
|
|
||||||
this.add(panel, "growx, wrap unrel");
|
this.add(panel, "growx, wrap unrel");
|
||||||
|
|
||||||
@ -149,6 +150,8 @@ public class CsvOptionPanel extends JPanel {
|
|||||||
*/
|
*/
|
||||||
public void storePreferences() {
|
public void storePreferences() {
|
||||||
Application.getPreferences().putString(Preferences.EXPORT_FIELD_SEPARATOR, getFieldSeparator());
|
Application.getPreferences().putString(Preferences.EXPORT_FIELD_SEPARATOR, getFieldSeparator());
|
||||||
|
Application.getPreferences().putInt(Preferences.EXPORT_DECIMAL_PLACES, getDecimalPlaces());
|
||||||
|
Application.getPreferences().putBoolean(Preferences.EXPORT_EXPONENTIAL_NOTATION, isExponentialNotation());
|
||||||
Application.getPreferences().putString(Preferences.EXPORT_COMMENT_CHARACTER, getCommentCharacter());
|
Application.getPreferences().putString(Preferences.EXPORT_COMMENT_CHARACTER, getCommentCharacter());
|
||||||
for (int i = 0; i < options.length; i++) {
|
for (int i = 0; i < options.length; i++) {
|
||||||
Application.getPreferences().putBoolean("csvOptions." + baseClassName + "." + i, options[i].isSelected());
|
Application.getPreferences().putBoolean("csvOptions." + baseClassName + "." + i, options[i].isSelected());
|
||||||
|
@ -23,7 +23,7 @@ import net.sf.openrocket.util.BugException;
|
|||||||
public class SaveCSVWorker extends SwingWorker<Void, Void> {
|
public class SaveCSVWorker extends SwingWorker<Void, Void> {
|
||||||
|
|
||||||
private static final int BYTES_PER_FIELD_PER_POINT = 7;
|
private static final int BYTES_PER_FIELD_PER_POINT = 7;
|
||||||
private static final int DEFAULT_DECIMAL_PLACES = 3;
|
public static final int DEFAULT_DECIMAL_PLACES = 3;
|
||||||
|
|
||||||
private final File file;
|
private final File file;
|
||||||
private final Simulation simulation;
|
private final Simulation simulation;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user