Merge pull request #1403 from SiboVG/softwareUpdaterBeta
Add checkbox in preferences for checking for beta updates + fixes
This commit is contained in:
commit
f184940715
@ -14,5 +14,7 @@ build.source=default
|
|||||||
|
|
||||||
|
|
||||||
# Whether checking for updates is enabled by default.
|
# Whether checking for updates is enabled by default.
|
||||||
|
|
||||||
build.checkupdates=true
|
build.checkupdates=true
|
||||||
|
|
||||||
|
# Whether checking for beta updates is enabled by default.
|
||||||
|
build.checkbetaupdates=true
|
||||||
|
@ -297,6 +297,8 @@ pref.dlg.RockSimfiles = RockSim engine files (*.rse)
|
|||||||
pref.dlg.ZIParchives = ZIP archives (*.zip)
|
pref.dlg.ZIParchives = ZIP archives (*.zip)
|
||||||
pref.dlg.checkbox.Checkupdates = Check for software updates at startup
|
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.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.ttip.Checkupdatesnow = Check for software updates now
|
||||||
pref.dlg.lbl.Selectprefunits = Select your preferred units:
|
pref.dlg.lbl.Selectprefunits = Select your preferred units:
|
||||||
pref.dlg.lbl.Rocketinfofontsize = Size of text in rocket design panel:
|
pref.dlg.lbl.Rocketinfofontsize = Size of text in rocket design panel:
|
||||||
|
@ -117,7 +117,6 @@ public class UpdateInfoRetriever {
|
|||||||
|
|
||||||
private final String preTag = null; // Change e.g. to 'android' for Android release
|
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 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;
|
private volatile UpdateInfo info;
|
||||||
|
|
||||||
@ -140,7 +139,7 @@ public class UpdateInfoRetriever {
|
|||||||
|
|
||||||
// Get the latest release name from the GitHub release page
|
// Get the latest release name from the GitHub release page
|
||||||
JsonArray jsonArr = retrieveAllReleaseObjects();
|
JsonArray jsonArr = retrieveAllReleaseObjects();
|
||||||
JsonObject latestObj = getLatestReleaseJSON(jsonArr, preTag, filterTags, onlyOfficial);
|
JsonObject latestObj = getLatestReleaseJSON(jsonArr, preTag, filterTags, !Application.getPreferences().getCheckBetaUpdates());
|
||||||
ReleaseInfo release = new ReleaseInfo(latestObj);
|
ReleaseInfo release = new ReleaseInfo(latestObj);
|
||||||
String latestName = release.getReleaseName();
|
String latestName = release.getReleaseName();
|
||||||
|
|
||||||
|
@ -56,6 +56,8 @@ public abstract class Preferences implements ChangeSource {
|
|||||||
|
|
||||||
private static final String CHECK_UPDATES = "CheckUpdates";
|
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_DIAMETER_FILTER = "MotorDiameterMatch";
|
||||||
public static final String MOTOR_HIDE_SIMILAR = "MotorHideSimilar";
|
public static final String MOTOR_HIDE_SIMILAR = "MotorHideSimilar";
|
||||||
public static final String MOTOR_HIDE_UNAVAILABLE = "MotorHideUnavailable";
|
public static final String MOTOR_HIDE_UNAVAILABLE = "MotorHideUnavailable";
|
||||||
@ -141,6 +143,14 @@ public abstract class Preferences implements ChangeSource {
|
|||||||
this.putBoolean(CHECK_UPDATES, 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() {
|
public final boolean getConfirmSimDeletion() {
|
||||||
return this.getBoolean(CONFIRM_DELETE_SIMULATION, true);
|
return this.getBoolean(CONFIRM_DELETE_SIMULATION, true);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ public class BuildProperties {
|
|||||||
private static final String BUILD_COPYRIGHT;
|
private static final String BUILD_COPYRIGHT;
|
||||||
private static final String BUILD_SOURCE;
|
private static final String BUILD_SOURCE;
|
||||||
private static final boolean DEFAULT_CHECK_UPDATES;
|
private static final boolean DEFAULT_CHECK_UPDATES;
|
||||||
|
private static final boolean DEFAULT_CHECK_BETA_UPDATES;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the OpenRocket version number.
|
* Return the OpenRocket version number.
|
||||||
@ -31,6 +32,10 @@ public class BuildProperties {
|
|||||||
return DEFAULT_CHECK_UPDATES;
|
return DEFAULT_CHECK_UPDATES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getDefaultCheckBetaUpdates() {
|
||||||
|
return DEFAULT_CHECK_BETA_UPDATES;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getCopyrightYear() {
|
public static String getCopyrightYear() {
|
||||||
return BUILD_COPYRIGHT;
|
return BUILD_COPYRIGHT;
|
||||||
}
|
}
|
||||||
@ -70,6 +75,12 @@ public class BuildProperties {
|
|||||||
else
|
else
|
||||||
DEFAULT_CHECK_UPDATES = true;
|
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");
|
BUILD_COPYRIGHT = PROPERTIES.getProperty("build.copyright", "2021");
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -14,26 +14,28 @@ import java.util.TreeMap;
|
|||||||
* @author Sibo Van Gool <sibo.vangool@hotmail.com>
|
* @author Sibo Van Gool <sibo.vangool@hotmail.com>
|
||||||
*/
|
*/
|
||||||
public class AssetHandler {
|
public class AssetHandler {
|
||||||
private static final Map<String, UpdatePlatform> mapExtensionToPlatform = new HashMap<>(); // Map file extensions to operating platform
|
private static final Map<String, UpdatePlatform[]> mapExtensionToPlatform = new HashMap<>(); // Map file extensions to operating platform
|
||||||
private static final Map<UpdatePlatform, String> mapPlatformToName = new HashMap<>(); // Map operating platform to a name
|
private static final Map<UpdatePlatform, String> mapPlatformToName = new HashMap<>(); // Map operating platform to a name
|
||||||
|
|
||||||
public enum UpdatePlatform {
|
public enum UpdatePlatform {
|
||||||
WINDOWS,
|
WINDOWS,
|
||||||
MAC_OS,
|
MAC_OS,
|
||||||
LINUX,
|
LINUX,
|
||||||
|
UNIX,
|
||||||
JAR
|
JAR
|
||||||
}
|
}
|
||||||
|
|
||||||
static {
|
static {
|
||||||
mapExtensionToPlatform.put(".dmg", UpdatePlatform.MAC_OS);
|
mapExtensionToPlatform.put(".dmg", new UpdatePlatform[] {UpdatePlatform.MAC_OS});
|
||||||
mapExtensionToPlatform.put(".exe", UpdatePlatform.WINDOWS);
|
mapExtensionToPlatform.put(".exe", new UpdatePlatform[] {UpdatePlatform.WINDOWS});
|
||||||
mapExtensionToPlatform.put(".AppImage", UpdatePlatform.LINUX);
|
mapExtensionToPlatform.put(".AppImage", new UpdatePlatform[] {UpdatePlatform.LINUX, UpdatePlatform.UNIX});
|
||||||
mapExtensionToPlatform.put(".sh", UpdatePlatform.LINUX);
|
mapExtensionToPlatform.put(".sh", new UpdatePlatform[] {UpdatePlatform.LINUX, UpdatePlatform.UNIX});
|
||||||
mapExtensionToPlatform.put(".jar", UpdatePlatform.JAR);
|
mapExtensionToPlatform.put(".jar", new UpdatePlatform[] {UpdatePlatform.JAR});
|
||||||
|
|
||||||
mapPlatformToName.put(UpdatePlatform.MAC_OS, "Mac OS");
|
mapPlatformToName.put(UpdatePlatform.MAC_OS, "Mac OS");
|
||||||
mapPlatformToName.put(UpdatePlatform.WINDOWS, "Windows");
|
mapPlatformToName.put(UpdatePlatform.WINDOWS, "Windows");
|
||||||
mapPlatformToName.put(UpdatePlatform.LINUX, "Linux");
|
mapPlatformToName.put(UpdatePlatform.LINUX, "Linux");
|
||||||
|
mapPlatformToName.put(UpdatePlatform.UNIX, "Linux");
|
||||||
mapPlatformToName.put(UpdatePlatform.JAR, "JAR");
|
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
|
* @return map with as key the operating platform name and as value the corresponding asset URL
|
||||||
*/
|
*/
|
||||||
public static Map<UpdatePlatform, String> mapURLToPlatform(List<String> urls) {
|
public static Map<UpdatePlatform, String> mapURLToPlatform(List<String> urls) {
|
||||||
Map<UpdatePlatform, String> output = new TreeMap<>();
|
Map<UpdatePlatform, String> output = new HashMap<>();
|
||||||
if (urls == null) return null;
|
if (urls == null) return null;
|
||||||
|
|
||||||
for (String url : urls) {
|
for (String url : urls) {
|
||||||
for (String ext : mapExtensionToPlatform.keySet()) {
|
for (String ext : mapExtensionToPlatform.keySet()) {
|
||||||
if (url.endsWith(ext)) {
|
if (url.endsWith(ext)) {
|
||||||
output.put(mapExtensionToPlatform.get(ext), url);
|
output.put(mapExtensionToPlatform.get(ext)[0], url); // First Platform element is enough
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package net.sf.openrocket.gui.dialogs;
|
|||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Desktop;
|
import java.awt.Desktop;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Insets;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -61,6 +62,7 @@ public class UpdateInfoDialog extends JDialog {
|
|||||||
final JTextPane textPane = new JTextPane();
|
final JTextPane textPane = new JTextPane();
|
||||||
textPane.setEditable(false);
|
textPane.setEditable(false);
|
||||||
textPane.setContentType("text/html");
|
textPane.setContentType("text/html");
|
||||||
|
textPane.setMargin(new Insets(10, 10, 40, 10));
|
||||||
textPane.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, true);
|
textPane.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, true);
|
||||||
|
|
||||||
ReleaseInfo release = info.getLatestRelease();
|
ReleaseInfo release = info.getLatestRelease();
|
||||||
@ -99,6 +101,7 @@ public class UpdateInfoDialog extends JDialog {
|
|||||||
});
|
});
|
||||||
|
|
||||||
textPane.setText(sb.toString());
|
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");
|
panel.add(new JScrollPane(textPane), "left, grow, span, push, gapleft 40px, gapbottom 6px, wrap");
|
||||||
|
|
||||||
|
@ -213,6 +213,18 @@ public class GeneralPreferencesPanel extends PreferencesPanel {
|
|||||||
});
|
});
|
||||||
this.add(button, "right, wrap");
|
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
|
//// Open most recent file on startup
|
||||||
final JCheckBox openRecentOnStartupBox = new JCheckBox(trans.get("pref.dlg.but.openlast"));
|
final JCheckBox openRecentOnStartupBox = new JCheckBox(trans.get("pref.dlg.but.openlast"));
|
||||||
openRecentOnStartupBox.setSelected(preferences.isAutoOpenLastDesignOnStartupEnabled());
|
openRecentOnStartupBox.setSelected(preferences.isAutoOpenLastDesignOnStartupEnabled());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user