From 59de3094b29c0fee5ed3eac6ca003f7ce26afc88 Mon Sep 17 00:00:00 2001 From: Sibo Van Gool Date: Thu, 27 Jan 2022 20:18:25 +0100 Subject: [PATCH] [fixes #825] Rename AssetHandler methods --- .../communication/AssetHandler.java | 43 ++++++++++--------- .../gui/dialogs/UpdateInfoDialog.java | 7 ++- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/core/src/net/sf/openrocket/communication/AssetHandler.java b/core/src/net/sf/openrocket/communication/AssetHandler.java index 194f250a4..c61aec22f 100644 --- a/core/src/net/sf/openrocket/communication/AssetHandler.java +++ b/core/src/net/sf/openrocket/communication/AssetHandler.java @@ -14,35 +14,35 @@ import java.util.TreeMap; * @author Sibo Van Gool */ public class AssetHandler { - private static final Map mapExtensionToOS = new HashMap<>(); // Map file extensions to operating system - private static final Map mapOSToName = new HashMap<>(); // Map operating system to a name + 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 static { - mapExtensionToOS.put(".dmg", Platform.MAC_OS); - mapExtensionToOS.put(".exe", Platform.WINDOWS); - mapExtensionToOS.put(".AppImage", Platform.UNIX); - mapExtensionToOS.put(".jar", null); + mapExtensionToPlatform.put(".dmg", Platform.MAC_OS); + mapExtensionToPlatform.put(".exe", Platform.WINDOWS); + mapExtensionToPlatform.put(".AppImage", Platform.UNIX); + mapExtensionToPlatform.put(".jar", null); - mapOSToName.put(Platform.MAC_OS, "Mac OS"); - mapOSToName.put(Platform.WINDOWS, "Windows"); - mapOSToName.put(Platform.UNIX, "Linux"); - mapOSToName.put(null, "JAR"); + mapPlatformToName.put(Platform.MAC_OS, "Mac OS"); + mapPlatformToName.put(Platform.WINDOWS, "Windows"); + mapPlatformToName.put(Platform.UNIX, "Linux"); + mapPlatformToName.put(null, "JAR"); } /** - * Maps a list of asset URLs to their respective operating system. - * E.g. "https://github.com/openrocket/openrocket/releases/download/release-15.03/OpenRocket-15.03.dmg" is mapped to - * "Mac OS". + * Maps a list of asset URLs to their respective operating platform name. + * E.g. "https://github.com/openrocket/openrocket/releases/download/release-15.03/OpenRocket-15.03.dmg" is mapped a + * map element with "Mac OS" as key and the url as value. * @param urls list of asset URLs - * @return map with as key the operating system 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 mapURLToOSName(List urls) { + public static Map mapURLToPlatformName(List urls) { Map output = new TreeMap<>(); if (urls == null) return null; for (String url : urls) { - for (String ext : mapExtensionToOS.keySet()) { + for (String ext : mapExtensionToPlatform.keySet()) { if (url.endsWith(ext)) { - output.put(mapOSToName.get(mapExtensionToOS.get(ext)), url); + output.put(mapPlatformToName.get(mapExtensionToPlatform.get(ext)), url); } } } @@ -50,12 +50,13 @@ public class AssetHandler { } /** - * Returns the OS name based on the operating system that the user is running on, or the value stored in preferences. - * @return operating system name + * Returns the operating platform name based on the operating system that the user is running on, or the value + * stored in preferences. + * @return operating platform name */ - public static String getOSName() { + public static String getPlatformName() { Platform currentPlatform = SystemInfo.getPlatform(); // TODO: select right option based on preference - return mapOSToName.get(currentPlatform); + return mapPlatformToName.get(currentPlatform); } } diff --git a/swing/src/net/sf/openrocket/gui/dialogs/UpdateInfoDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/UpdateInfoDialog.java index 024c18ded..feadafc8b 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/UpdateInfoDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/UpdateInfoDialog.java @@ -29,7 +29,6 @@ import net.sf.openrocket.gui.util.SwingPreferences; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.startup.Application; import net.sf.openrocket.gui.widgets.SelectColorButton; -import net.sf.openrocket.util.ArrayList; import net.sf.openrocket.util.BuildProperties; import net.sf.openrocket.util.MarkdownUtil; import org.slf4j.Logger; @@ -114,7 +113,7 @@ public class UpdateInfoDialog extends JDialog { // Install operating system combo box List assetURLs = release.getAssetURLs(); - Map mappedAssets = AssetHandler.mapURLToOSName(assetURLs); + Map mappedAssets = AssetHandler.mapURLToPlatformName(assetURLs); JComboBox comboBox; if (mappedAssets == null || mappedAssets.size() == 0) { comboBox = new JComboBox<>(new String[]{ @@ -124,8 +123,8 @@ public class UpdateInfoDialog extends JDialog { comboBox = new JComboBox<>(mappedAssets.keySet().toArray(new String[0])); } panel.add(comboBox, "pushx, right"); - String os = AssetHandler.getOSName(); - comboBox.setSelectedItem(os); + String platformName = AssetHandler.getPlatformName(); + comboBox.setSelectedItem(platformName); // Install update button JButton btnInstall = new SelectColorButton(trans.get("update.dlg.updateAvailable.but.install"));