From 120188537ec3e35b8e41c86201f046c7be8b55ba Mon Sep 17 00:00:00 2001 From: LazoYoung Date: Mon, 12 Feb 2024 13:51:00 +0900 Subject: [PATCH] feature: display app version --- README.md | 2 +- build.gradle | 10 +++++++- logo.ico | Bin 0 -> 6588 bytes .../com/flylazo/naru_acars/NaruACARS.java | 22 ++++++++++++------ .../com/flylazo/naru_acars/gui/Window.java | 13 ++++++++++- .../naru_acars/gui/panel/Dispatcher.java | 2 -- src/main/resources/app.properties | 1 + 7 files changed, 38 insertions(+), 12 deletions(-) create mode 100644 logo.ico create mode 100644 src/main/resources/app.properties diff --git a/README.md b/README.md index 1f31ccd..d8d0c7e 100644 --- a/README.md +++ b/README.md @@ -33,5 +33,5 @@ This application is proudly powered by these amazing works...! ### For Windows WiX Toolset is required for this to work. ``` -jpackage --input target --name Naru-ACARS --app-version 1.1 --icon Naru-ACARS.ico --main-jar Naru-ACARS.jar --type msi --win-dir-chooser --win-shortcut --win-per-user-install +jpackage --input target --name Naru-ACARS --app-version %VERSION% --icon Naru-ACARS.ico --main-jar Naru-ACARS.jar --type msi --win-dir-chooser --win-shortcut --win-per-user-install ``` \ No newline at end of file diff --git a/build.gradle b/build.gradle index ac05794..cc09daa 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } group = 'com.flylazo.naru_acars' -version = '1.1' +version = '1.1.1' sourceCompatibility = '17' targetCompatibility = '17' var fsuipc = 'lib/FSUIPC-1.0.2.jar' @@ -65,3 +65,11 @@ launch4j { tasks.named('test') { useJUnitPlatform() } + +processResources { + filesMatching(['**/*.properties']) { + filter { + it.replace('%VERSION%', version) + } + } +} \ No newline at end of file diff --git a/logo.ico b/logo.ico new file mode 100644 index 0000000000000000000000000000000000000000..5ead7c465f8551d80b6c8ccd2176f01c70eab6aa GIT binary patch literal 6588 zcmb7Ii$9ZJ{D1Z!b1B;-NiobQguZf#%q`}Yd=XLRl5P}95wneib&*R*5=o_~h!AE| z>mr3xp)esOWlU^iw%_y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?g4sH> zU?)!i17ML?JlZaf7aF8c(PT#yttLSxo+<VJd)q%uM-AyMw~tV`MtWgv9M%6rFUZQ;ipJA+}vv@ClR?lF7W z^`b425`jZSt5X7b3QjAVlUE#Zu>5?XQOA%?0QT8XSFlwuo>?zX)pPk&g1Z02=1 z%n2^EC$=Ac#u6QCb7Z@XhL)4+*e<-tjj5pRp*TxTtF{YN;j80qcjt6frD`%FMd_?* p9v5>$SoQSG)r;AVqZ#WYO4-+we&zW8YzCm0>yDjH4;(^L{|7Ma-|GMX literal 0 HcmV?d00001 diff --git a/src/main/java/com/flylazo/naru_acars/NaruACARS.java b/src/main/java/com/flylazo/naru_acars/NaruACARS.java index d09b012..c91031c 100644 --- a/src/main/java/com/flylazo/naru_acars/NaruACARS.java +++ b/src/main/java/com/flylazo/naru_acars/NaruACARS.java @@ -33,9 +33,10 @@ @SpringBootApplication public class NaruACARS { public static final Logger logger = Logger.getLogger(NaruACARS.class.getName()); - private static final String hostAddress = "localhost"; - private static final String portKey = "server.port"; - private static final String directory = "NaruACARS"; + private static final String PORT_KEY = "server.port"; + private static final String DIRECTORY = "NaruACARS"; + private static final String PROPERTY_FILE = "app.properties"; + private static String hostAddress = "localhost"; private static Window window; private static ConfigurableApplicationContext context = null; @@ -51,9 +52,9 @@ public static void main(String[] args) { System.exit(1); } - System.setProperty(portKey, String.valueOf(port)); + System.setProperty(PORT_KEY, String.valueOf(port)); props.put("server.address", hostAddress); - props.put(portKey, port); + props.put(PORT_KEY, port); context = builder.properties(props) .headless(false) .run(args); @@ -99,13 +100,13 @@ public static URL getWebURL(String path) { } public static int getSystemPort() { - return Optional.ofNullable(System.getProperty(portKey)) + return Optional.ofNullable(System.getProperty(PORT_KEY)) .map(Integer::parseInt) .orElse(8080); } public static Path getDirectory() { - var path = Path.of(System.getProperty("user.dir")).resolve(directory); + var path = Path.of(System.getProperty("user.dir")).resolve(DIRECTORY); var file = path.toFile(); if (!file.isDirectory()) { @@ -126,6 +127,13 @@ public static BeanFactory getServiceFactory() { return context.getBeanFactory(); } + public static java.util.Properties getProperties() throws IOException { + var resource = new ClassPathResource(PROPERTY_FILE); + var properties = new java.util.Properties(); + properties.load(resource.getInputStream()); + return properties; + } + private static void loadLibraries() { try { copyNativeBinaries(); diff --git a/src/main/java/com/flylazo/naru_acars/gui/Window.java b/src/main/java/com/flylazo/naru_acars/gui/Window.java index f7bafec..8bf00fc 100644 --- a/src/main/java/com/flylazo/naru_acars/gui/Window.java +++ b/src/main/java/com/flylazo/naru_acars/gui/Window.java @@ -86,12 +86,23 @@ public void windowClosing(WindowEvent e) { setResizable(false); setPreferredSize(new Dimension(800, 500)); setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - setTitle("Naru ACARS"); + setTitle(getWindowTitle()); pack(); setLocationRelativeTo(null); setVisible(true); } + private String getWindowTitle() { + final var title = "Naru-ACARS"; + + try { + String version = NaruACARS.getProperties().getProperty("version"); + return title + " v" + version; + } catch (IOException e) { + return title; + } + } + public void selectPage(Class clazz) { JComponent comp = this.pages.get(clazz); diff --git a/src/main/java/com/flylazo/naru_acars/gui/panel/Dispatcher.java b/src/main/java/com/flylazo/naru_acars/gui/panel/Dispatcher.java index 80178d1..b84cbd6 100644 --- a/src/main/java/com/flylazo/naru_acars/gui/panel/Dispatcher.java +++ b/src/main/java/com/flylazo/naru_acars/gui/panel/Dispatcher.java @@ -7,7 +7,6 @@ import com.flylazo.naru_acars.domain.Properties; import com.flylazo.naru_acars.domain.acars.VirtualAirline; import com.flylazo.naru_acars.domain.acars.response.BookingResponse; -import com.flylazo.naru_acars.domain.acars.response.ErrorResponse; import com.flylazo.naru_acars.gui.Window; import com.flylazo.naru_acars.gui.component.FlightInput; import com.flylazo.naru_acars.gui.component.Header; @@ -33,7 +32,6 @@ import java.util.logging.Logger; import static javax.swing.JOptionPane.*; -import static javax.swing.JOptionPane.ERROR_MESSAGE; import static javax.swing.LayoutStyle.ComponentPlacement.UNRELATED; public class Dispatcher extends PanelBase { diff --git a/src/main/resources/app.properties b/src/main/resources/app.properties new file mode 100644 index 0000000..d95b5dc --- /dev/null +++ b/src/main/resources/app.properties @@ -0,0 +1 @@ +version=%VERSION% \ No newline at end of file