diff --git a/core/src/main/java/info/openrocket/core/preferences/ApplicationPreferences.java b/core/src/main/java/info/openrocket/core/preferences/ApplicationPreferences.java index e3a4c87d7..8666e5f5a 100644 --- a/core/src/main/java/info/openrocket/core/preferences/ApplicationPreferences.java +++ b/core/src/main/java/info/openrocket/core/preferences/ApplicationPreferences.java @@ -20,6 +20,7 @@ import info.openrocket.core.material.Material; import info.openrocket.core.models.atmosphere.AtmosphericModel; import info.openrocket.core.models.atmosphere.ExtendedISAModel; import info.openrocket.core.preset.ComponentPreset; +import info.openrocket.core.rocketcomponent.FlightConfiguration; import info.openrocket.core.rocketcomponent.MassObject; import info.openrocket.core.rocketcomponent.Rocket; import info.openrocket.core.rocketcomponent.RocketComponent; @@ -101,8 +102,10 @@ public abstract class ApplicationPreferences implements ChangeSource, ORPreferen public static final String ROCKET_INFO_FONT_SIZE = "RocketInfoFontSize"; - // Preferences Related to Simulations + // Preferences related to flight configurations + public static final String DEFAULT_FLIGHT_CONFIG_NAME = "DefaultFlightConfigName"; + // Preferences Related to Simulations public static final String CONFIRM_DELETE_SIMULATION = "ConfirmDeleteSimulation"; public static final String AUTO_RUN_SIMULATIONS = "AutoRunSimulations"; public static final String LAUNCH_ROD_LENGTH = "LaunchRodLength"; @@ -258,6 +261,18 @@ public abstract class ApplicationPreferences implements ChangeSource, ORPreferen } + /* + * ****************************************************************************************** + */ + + public String getDefaultFlightConfigName() { + return getString(DEFAULT_FLIGHT_CONFIG_NAME, FlightConfiguration.DEFAULT_CONFIG_NAME); + } + + public void setDefaultFlightConfigName(String name) { + putString(DEFAULT_FLIGHT_CONFIG_NAME, name); + } + /* * ****************************************************************************************** */ diff --git a/core/src/main/java/info/openrocket/core/rocketcomponent/FlightConfiguration.java b/core/src/main/java/info/openrocket/core/rocketcomponent/FlightConfiguration.java index 061398139..905a1d6cc 100644 --- a/core/src/main/java/info/openrocket/core/rocketcomponent/FlightConfiguration.java +++ b/core/src/main/java/info/openrocket/core/rocketcomponent/FlightConfiguration.java @@ -10,6 +10,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentLinkedQueue; import info.openrocket.core.formatting.RocketDescriptor; +import info.openrocket.core.preferences.ApplicationPreferences; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,6 +34,7 @@ import info.openrocket.core.util.Transformation; */ public class FlightConfiguration implements FlightConfigurableParameter, Monitorable { private static final Logger log = LoggerFactory.getLogger(FlightConfiguration.class); + private static final ApplicationPreferences prefs = Application.getPreferences(); private String configurationName; public static String DEFAULT_CONFIG_NAME = "[{motors}]"; @@ -105,7 +107,7 @@ public class FlightConfiguration implements FlightConfigurableParameter{motors}' will be replaced with the motor designation(s).
\te.g. '{motors} \u2192 'M1350-0'
RenameConfigDialog.lbl.infoManufacturers = The text '{manufacturers}' will be replaced with the motor manufacturer(s).
\te.g. '{manufacturers}' \u2192 'AeroTech'
diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index c93859634..f8c077ae0 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -6,16 +6,16 @@ description: | OpenRocket is a free, fully featured model rocket simulator that allows you to design and simulate your rockets before actually building and flying them. - The main features include + The main features include: * Six-degree-of-freedom flight simulation * Automatic design optimization * Realtime simulated altitude, velocity and acceleration display * Staging and clustering support * Cross-platform (Java-based) - * Read more about it on the OpenRocket.info. + * Read more about it on OpenRocket.info license: GPL-3.0 -base: core22 +base: core18 confinement: strict plugs: @@ -37,7 +37,6 @@ architectures: apps: openrocket: - extensions: [gnome] command: bin/launcher plugs: - home @@ -47,43 +46,23 @@ apps: - dot-java-user-prefs-openrocket - dot-openrocket environment: - JAVA_HOME: "$SNAP/usr/lib/jvm/java-17-openjdk-$CRAFT_TARGET_ARCH" + JAVA_HOME: "$SNAP/usr/lib/jvm/java-17-openjdk-$SNAP_ARCH" parts: openrocket: - plugin: ant - build-packages: - - ant - - ant-contrib - - ant-optional - - openjdk-17-jdk - - openjdk-17-jre + plugin: gradle source: . - source-type: git - ant-build-targets: - - clean - - check - - unittest - - jar + build-packages: + - openjdk-17-jdk override-pull: | - # Override the pull in order to set the version and the grade. - # In the future, the releases can be annotated tags and snapcraft - # will use those for the version numbers. - # - # This can be extended to other parts of OpenRocket (to use the - # git describe --tags command) but the build should be updated at - # the same time so its consistent across all artifacts. Will defer - # that to a later pull request. - # - # Until then, just use the build.version value craftctl default - VERSION=$(cat core/resources/build.properties | awk -F'=' '/build\.version/ { print $2 }') - craftctl set version="$VERSION" + version=$(grep 'version =' build.gradle | awk '{print $3}' | tr -d "'") + craftctl set version="$version" override-build: | craftctl default - mv swing/build/jar/OpenRocket.jar $CRAFT_PART_INSTALL/OpenRocket.jar + mkdir -p $CRAFT_PART_INSTALL/bin + cp build/libs/OpenRocket-*.jar $CRAFT_PART_INSTALL/OpenRocket.jar stage-packages: - - openjdk-17-jdk - openjdk-17-jre - ca-certificates - ca-certificates-java @@ -95,6 +74,6 @@ parts: launcher: plugin: dump source: snap/local + source-type: local organize: - 'launcher': 'bin/' - + launcher: bin/launcher \ No newline at end of file diff --git a/swing/src/main/java/info/openrocket/swing/gui/dialogs/flightconfiguration/RenameConfigDialog.java b/swing/src/main/java/info/openrocket/swing/gui/dialogs/flightconfiguration/RenameConfigDialog.java index 6aa581c3e..b8384edd8 100644 --- a/swing/src/main/java/info/openrocket/swing/gui/dialogs/flightconfiguration/RenameConfigDialog.java +++ b/swing/src/main/java/info/openrocket/swing/gui/dialogs/flightconfiguration/RenameConfigDialog.java @@ -9,10 +9,12 @@ import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JLabel; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JTextField; import info.openrocket.core.l10n.Translator; +import info.openrocket.core.preferences.ApplicationPreferences; import info.openrocket.core.rocketcomponent.FlightConfigurationId; import info.openrocket.core.rocketcomponent.Rocket; import info.openrocket.core.startup.Application; @@ -26,6 +28,7 @@ import info.openrocket.swing.gui.theme.UITheme; public class RenameConfigDialog extends JDialog { private static final long serialVersionUID = -5423008694485357248L; private static final Translator trans = Application.getTranslator(); + private static final ApplicationPreferences prefs = Application.getPreferences(); private static Color dimTextColor; @@ -55,6 +58,17 @@ public class RenameConfigDialog extends JDialog { } }); panel.add(okButton); + + JButton saveAsDefaultButton = new JButton(trans.get("RenameConfigDialog.but.saveDefault")); + saveAsDefaultButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + JOptionPane.showMessageDialog(RenameConfigDialog.this, trans.get("RenameConfigDialog.dlg.saveDefault.msg"), + trans.get("RenameConfigDialog.dlg.saveDefault.title"), JOptionPane.INFORMATION_MESSAGE); + prefs.setDefaultFlightConfigName(textbox.getText()); + } + }); + panel.add(saveAsDefaultButton); JButton resetToDefaultButton = new JButton(trans.get("RenameConfigDialog.but.reset")); resetToDefaultButton.addActionListener(new ActionListener() { diff --git a/swing/src/main/java/info/openrocket/swing/gui/simulation/SimulationConfigDialog.java b/swing/src/main/java/info/openrocket/swing/gui/simulation/SimulationConfigDialog.java index 7027b024a..95a95f23f 100644 --- a/swing/src/main/java/info/openrocket/swing/gui/simulation/SimulationConfigDialog.java +++ b/swing/src/main/java/info/openrocket/swing/gui/simulation/SimulationConfigDialog.java @@ -372,12 +372,13 @@ public class SimulationConfigDialog extends JDialog { if (plot != null) { plot.setVisible(true); } - closeDialog(); return; } else if (tabIdx == EXPORT_IDX) { - if (exportTab == null || exportTab.doExport()) { + if (exportTab == null) { closeDialog(); + return; } + exportTab.doExport(); return; }