diff --git a/core/resources/build.properties b/core/resources/build.properties index e8ae1f4fc..3a06e646e 100644 --- a/core/resources/build.properties +++ b/core/resources/build.properties @@ -14,5 +14,7 @@ build.source=default # Whether checking for updates is enabled by default. - build.checkupdates=true + +# Whether checking for beta updates is enabled by default. +build.checkbetaupdates=true diff --git a/core/resources/l10n/messages.properties b/core/resources/l10n/messages.properties index 1df581652..760636393 100644 --- a/core/resources/l10n/messages.properties +++ b/core/resources/l10n/messages.properties @@ -297,6 +297,8 @@ pref.dlg.RockSimfiles = RockSim engine files (*.rse) pref.dlg.ZIParchives = ZIP archives (*.zip) pref.dlg.checkbox.Checkupdates = Check for software updates at startup pref.dlg.checkbox.Checkupdates.ttip = Check for software updates every time you start up OpenRocket +pref.dlg.checkbox.CheckBetaupdates = Also check for beta releases +pref.dlg.checkbox.CheckBetaupdates.ttip = If checked, beta release updates are also notified. If unchecked, only official releases are considered. pref.dlg.ttip.Checkupdatesnow = Check for software updates now pref.dlg.lbl.Selectprefunits = Select your preferred units: pref.dlg.lbl.Rocketinfofontsize = Size of text in rocket design panel: diff --git a/core/src/net/sf/openrocket/communication/UpdateInfoRetriever.java b/core/src/net/sf/openrocket/communication/UpdateInfoRetriever.java index b664a684c..4018c12b6 100644 --- a/core/src/net/sf/openrocket/communication/UpdateInfoRetriever.java +++ b/core/src/net/sf/openrocket/communication/UpdateInfoRetriever.java @@ -117,7 +117,6 @@ public class UpdateInfoRetriever { private final String preTag = null; // Change e.g. to 'android' for Android release private final String[] filterTags = null; // Change to e.g. ["beta"] to only retrieve beta releases - private final boolean onlyOfficial = false; // Change to false for beta testing private volatile UpdateInfo info; @@ -140,7 +139,7 @@ public class UpdateInfoRetriever { // Get the latest release name from the GitHub release page JsonArray jsonArr = retrieveAllReleaseObjects(); - JsonObject latestObj = getLatestReleaseJSON(jsonArr, preTag, filterTags, onlyOfficial); + JsonObject latestObj = getLatestReleaseJSON(jsonArr, preTag, filterTags, !Application.getPreferences().getCheckBetaUpdates()); ReleaseInfo release = new ReleaseInfo(latestObj); String latestName = release.getReleaseName(); diff --git a/core/src/net/sf/openrocket/startup/Preferences.java b/core/src/net/sf/openrocket/startup/Preferences.java index 687a0512f..58f76a742 100644 --- a/core/src/net/sf/openrocket/startup/Preferences.java +++ b/core/src/net/sf/openrocket/startup/Preferences.java @@ -55,6 +55,8 @@ public abstract class Preferences implements ChangeSource { public static final String PLOT_SHOW_POINTS = "ShowPlotPoints"; private static final String CHECK_UPDATES = "CheckUpdates"; + + private static final String CHECK_BETA_UPDATES = "CheckBetaUpdates"; public static final String MOTOR_DIAMETER_FILTER = "MotorDiameterMatch"; public static final String MOTOR_HIDE_SIMILAR = "MotorHideSimilar"; @@ -140,6 +142,14 @@ public abstract class Preferences implements ChangeSource { public final void setCheckUpdates(boolean check) { this.putBoolean(CHECK_UPDATES, check); } + + public final boolean getCheckBetaUpdates() { + return this.getBoolean(CHECK_BETA_UPDATES, BuildProperties.getDefaultCheckBetaUpdates()); + } + + public final void setCheckBetaUpdates(boolean check) { + this.putBoolean(CHECK_BETA_UPDATES, check); + } public final boolean getConfirmSimDeletion() { return this.getBoolean(CONFIRM_DELETE_SIMULATION, true); diff --git a/core/src/net/sf/openrocket/util/BuildProperties.java b/core/src/net/sf/openrocket/util/BuildProperties.java index 870d9001c..d1d69c69a 100644 --- a/core/src/net/sf/openrocket/util/BuildProperties.java +++ b/core/src/net/sf/openrocket/util/BuildProperties.java @@ -12,6 +12,7 @@ public class BuildProperties { private static final String BUILD_COPYRIGHT; private static final String BUILD_SOURCE; private static final boolean DEFAULT_CHECK_UPDATES; + private static final boolean DEFAULT_CHECK_BETA_UPDATES; /** * Return the OpenRocket version number. @@ -30,6 +31,10 @@ public class BuildProperties { public static boolean getDefaultCheckUpdates() { return DEFAULT_CHECK_UPDATES; } + + public static boolean getDefaultCheckBetaUpdates() { + return DEFAULT_CHECK_BETA_UPDATES; + } public static String getCopyrightYear() { return BUILD_COPYRIGHT; @@ -69,6 +74,12 @@ public class BuildProperties { DEFAULT_CHECK_UPDATES = Boolean.parseBoolean(value); else DEFAULT_CHECK_UPDATES = true; + + value = PROPERTIES.getProperty("build.checkbetaupdates"); + if (value != null) + DEFAULT_CHECK_BETA_UPDATES = Boolean.parseBoolean(value); + else + DEFAULT_CHECK_BETA_UPDATES = true; BUILD_COPYRIGHT = PROPERTIES.getProperty("build.copyright", "2021"); diff --git a/swing/src/net/sf/openrocket/communication/AssetHandler.java b/swing/src/net/sf/openrocket/communication/AssetHandler.java index 5ddb63929..e21b5e997 100644 --- a/swing/src/net/sf/openrocket/communication/AssetHandler.java +++ b/swing/src/net/sf/openrocket/communication/AssetHandler.java @@ -14,26 +14,28 @@ import java.util.TreeMap; * @author Sibo Van Gool */ public class AssetHandler { - private static final Map mapExtensionToPlatform = new HashMap<>(); // Map file extensions to operating platform + private static final Map mapExtensionToPlatform = new HashMap<>(); // Map file extensions to operating platform private static final Map mapPlatformToName = new HashMap<>(); // Map operating platform to a name public enum UpdatePlatform { WINDOWS, MAC_OS, LINUX, + UNIX, JAR } static { - mapExtensionToPlatform.put(".dmg", UpdatePlatform.MAC_OS); - mapExtensionToPlatform.put(".exe", UpdatePlatform.WINDOWS); - mapExtensionToPlatform.put(".AppImage", UpdatePlatform.LINUX); - mapExtensionToPlatform.put(".sh", UpdatePlatform.LINUX); - mapExtensionToPlatform.put(".jar", UpdatePlatform.JAR); + mapExtensionToPlatform.put(".dmg", new UpdatePlatform[] {UpdatePlatform.MAC_OS}); + mapExtensionToPlatform.put(".exe", new UpdatePlatform[] {UpdatePlatform.WINDOWS}); + mapExtensionToPlatform.put(".AppImage", new UpdatePlatform[] {UpdatePlatform.LINUX, UpdatePlatform.UNIX}); + mapExtensionToPlatform.put(".sh", new UpdatePlatform[] {UpdatePlatform.LINUX, UpdatePlatform.UNIX}); + mapExtensionToPlatform.put(".jar", new UpdatePlatform[] {UpdatePlatform.JAR}); mapPlatformToName.put(UpdatePlatform.MAC_OS, "Mac OS"); mapPlatformToName.put(UpdatePlatform.WINDOWS, "Windows"); mapPlatformToName.put(UpdatePlatform.LINUX, "Linux"); + mapPlatformToName.put(UpdatePlatform.UNIX, "Linux"); mapPlatformToName.put(UpdatePlatform.JAR, "JAR"); } @@ -45,13 +47,13 @@ public class AssetHandler { * @return map with as key the operating platform name and as value the corresponding asset URL */ public static Map mapURLToPlatform(List urls) { - Map output = new TreeMap<>(); + Map output = new HashMap<>(); if (urls == null) return null; for (String url : urls) { for (String ext : mapExtensionToPlatform.keySet()) { if (url.endsWith(ext)) { - output.put(mapExtensionToPlatform.get(ext), url); + output.put(mapExtensionToPlatform.get(ext)[0], url); // First Platform element is enough } } } diff --git a/swing/src/net/sf/openrocket/gui/dialogs/UpdateInfoDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/UpdateInfoDialog.java index da22da924..e5587a812 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/UpdateInfoDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/UpdateInfoDialog.java @@ -3,6 +3,7 @@ package net.sf.openrocket.gui.dialogs; import java.awt.Component; import java.awt.Desktop; import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.net.URI; @@ -61,6 +62,7 @@ public class UpdateInfoDialog extends JDialog { final JTextPane textPane = new JTextPane(); textPane.setEditable(false); textPane.setContentType("text/html"); + textPane.setMargin(new Insets(10, 10, 40, 10)); textPane.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, true); ReleaseInfo release = info.getLatestRelease(); @@ -99,6 +101,7 @@ public class UpdateInfoDialog extends JDialog { }); textPane.setText(sb.toString()); + textPane.setCaretPosition(0); // Scroll to the top panel.add(new JScrollPane(textPane), "left, grow, span, push, gapleft 40px, gapbottom 6px, wrap"); diff --git a/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java b/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java index 62b069136..e2efb2251 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/preferences/GeneralPreferencesPanel.java @@ -212,6 +212,18 @@ public class GeneralPreferencesPanel extends PreferencesPanel { } }); this.add(button, "right, wrap"); + + //// Check for beta releases + final JCheckBox betaUpdateBox = new JCheckBox(trans.get("pref.dlg.checkbox.CheckBetaupdates")); + betaUpdateBox.setToolTipText(trans.get("pref.dlg.checkbox.CheckBetaupdates.ttip")); + betaUpdateBox.setSelected(preferences.getCheckBetaUpdates()); + betaUpdateBox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + preferences.setCheckBetaUpdates(betaUpdateBox.isSelected()); + } + }); + this.add(betaUpdateBox, "gapleft para, wrap"); //// Open most recent file on startup final JCheckBox openRecentOnStartupBox = new JCheckBox(trans.get("pref.dlg.but.openlast"));