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 0000000..5ead7c4 Binary files /dev/null and b/logo.ico differ 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