Fix small issues on update checker
Scroll to the top (was on the bottom at first), add margins to the text panel, and add UNIX as a platform for the update checker
This commit is contained in:
parent
53026d0838
commit
1193f3b364
@ -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");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user