From 981d69525f3eb570bb096bbda2067348011c65e6 Mon Sep 17 00:00:00 2001 From: Marvin Date: Sun, 2 Jan 2022 21:49:54 +0100 Subject: [PATCH] #v0.3.1 release - fix for parsing issue with durations in flight plan --- CHANGELOG.md | 10 ++++++++++ pom.xml | 2 +- .../net/marvk/fs/vatsim/map/data/FlightPlan.java | 15 +++++++++++++-- .../fs/vatsim/map/view/toolbar/ToolBarView.java | 7 ++++++- .../vatsim/map/view/toolbar/ToolBarViewModel.java | 4 ++++ .../fs/vatsim/map/view/toolbar/ToolbarView.fxml | 4 +++- 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ce65641..2db61f00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [0.3.1](https://github.com/marvk/vatprism/compare/v0.3.0...v0.3.1) - 2022-01-02 + +### Added + +- Changelog button in the toolbar + +### Fixed + +- Fixed parsing issue with invalid fuel remaining and enroute times preventing application startup + ## [0.3.0](https://github.com/marvk/vatprism/compare/v0.2.0...v0.3.0) - 2021-12-28 ### Added diff --git a/pom.xml b/pom.xml index 802cf8e8..21445d9f 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,7 @@ - 0.3.0 + 0.3.1 1 net.marvk.fs.vatsim.map.Application diff --git a/src/main/java/net/marvk/fs/vatsim/map/data/FlightPlan.java b/src/main/java/net/marvk/fs/vatsim/map/data/FlightPlan.java index 2875a2ba..e1bfe6c9 100644 --- a/src/main/java/net/marvk/fs/vatsim/map/data/FlightPlan.java +++ b/src/main/java/net/marvk/fs/vatsim/map/data/FlightPlan.java @@ -15,6 +15,7 @@ public class FlightPlan implements Settable, Data { private static final Pattern ALTITUDE_PATTERN = Pattern.compile("^(?FL|F)?(?\\d+)$", Pattern.CASE_INSENSITIVE); private static final Pattern AIRCRAFT_PATTERN = Pattern.compile("^(?:./)?(...[^/-]{0,2})(?:[/-].*)?$", Pattern.CASE_INSENSITIVE); + private static final Pattern HOURS_MINUTES = Pattern.compile("\\d{4}"); private final Pilot pilot; private final StringProperty aircraft = new SimpleStringProperty(); @@ -51,8 +52,8 @@ public void setFromModel(final VatsimFlightPlan model) { departureTime.set(parseDepartureTime(model.getDepartureTime())); altitude.set(parseAltitude(model.getAltitude())); trueCruiseAirspeed.set(model.getCruiseTas()); - enrouteProperty.set(parseDuration(model.getEnrouteTime())); - fuelProperty.set(parseDuration(model.getFuelTime())); + enrouteProperty.set(parseDurationOrNull(model.getEnrouteTime())); + fuelProperty.set(parseDurationOrNull(model.getFuelTime())); plannedRoute.set(model.getRoute()); remarks.set(model.getRemarks()); @@ -250,6 +251,16 @@ private boolean isDomesticAirportsAndCountriesNullable() { return getDepartureAirport().getCountry().equals(getArrivalAirport().getCountry()); } + private static Duration parseDurationOrNull(final String hoursMinutes) { + if (hoursMinutes != null && HOURS_MINUTES.matcher(hoursMinutes).matches()) { + return parseDuration(hoursMinutes); + } + + log.warn("Failed to parse duration %s".formatted(hoursMinutes)); + + return null; + } + private static Duration parseDuration(final String hoursMinutes) { return ParseUtil.parseNullSafe( hoursMinutes, diff --git a/src/main/java/net/marvk/fs/vatsim/map/view/toolbar/ToolBarView.java b/src/main/java/net/marvk/fs/vatsim/map/view/toolbar/ToolBarView.java index afaa59a8..42f2c2f2 100644 --- a/src/main/java/net/marvk/fs/vatsim/map/view/toolbar/ToolBarView.java +++ b/src/main/java/net/marvk/fs/vatsim/map/view/toolbar/ToolBarView.java @@ -243,7 +243,12 @@ private void openGithub() { } @FXML - private void showUsageGuide() { + private void openUsageGuide() { viewModel.visitUsageGuide(); } + + @FXML + private void openChangelog() { + viewModel.visitChangelog(); + } } diff --git a/src/main/java/net/marvk/fs/vatsim/map/view/toolbar/ToolBarViewModel.java b/src/main/java/net/marvk/fs/vatsim/map/view/toolbar/ToolBarViewModel.java index 35883baf..3a84d652 100644 --- a/src/main/java/net/marvk/fs/vatsim/map/view/toolbar/ToolBarViewModel.java +++ b/src/main/java/net/marvk/fs/vatsim/map/view/toolbar/ToolBarViewModel.java @@ -107,4 +107,8 @@ public void visitGithub() { public void visitUsageGuide() { hostServices.showDocument("https://vatprism.org/usage-guide"); } + + public void visitChangelog() { + hostServices.showDocument("https://github.com/marvk/vatprism/blob/master/CHANGELOG.md"); + } } diff --git a/src/main/resources/net/marvk/fs/vatsim/map/view/toolbar/ToolbarView.fxml b/src/main/resources/net/marvk/fs/vatsim/map/view/toolbar/ToolbarView.fxml index d4972381..38337891 100644 --- a/src/main/resources/net/marvk/fs/vatsim/map/view/toolbar/ToolbarView.fxml +++ b/src/main/resources/net/marvk/fs/vatsim/map/view/toolbar/ToolbarView.fxml @@ -141,6 +141,8 @@ +