Skip to content

Commit

Permalink
feature: display app version
Browse files Browse the repository at this point in the history
  • Loading branch information
LazoYoung committed Feb 12, 2024
1 parent 0751aa6 commit 1201885
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
10 changes: 9 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -65,3 +65,11 @@ launch4j {
tasks.named('test') {
useJUnitPlatform()
}

processResources {
filesMatching(['**/*.properties']) {
filter {
it.replace('%VERSION%', version)
}
}
}
Binary file added logo.ico
Binary file not shown.
22 changes: 15 additions & 7 deletions src/main/java/com/flylazo/naru_acars/NaruACARS.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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()) {
Expand All @@ -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();
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/com/flylazo/naru_acars/gui/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/app.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=%VERSION%

0 comments on commit 1201885

Please sign in to comment.