Skip to content

Commit

Permalink
#v0.3.1 release - fix for parsing issue with durations in flight plan
Browse files Browse the repository at this point in the history
  • Loading branch information
marvk committed Jan 2, 2022
1 parent 501a83a commit 981d695
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 5 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

<properties>
<!--Defaults, should be passed as command line argument for real builds-->
<versionName>0.3.0</versionName>
<versionName>0.3.1</versionName>
<buildNumber>1</buildNumber>

<mainClass>net.marvk.fs.vatsim.map.Application</mainClass>
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/net/marvk/fs/vatsim/map/data/FlightPlan.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class FlightPlan implements Settable<VatsimFlightPlan>, Data {
private static final Pattern ALTITUDE_PATTERN = Pattern.compile("^(?<prefix>FL|F)?(?<amount>\\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();
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,12 @@ private void openGithub() {
}

@FXML
private void showUsageGuide() {
private void openUsageGuide() {
viewModel.visitUsageGuide();
}

@FXML
private void openChangelog() {
viewModel.visitChangelog();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
<!-- </graphic>-->
<!-- </ToggleButton>-->
<Region HBox.hgrow="ALWAYS"/>
<Label styleClass="hyperlink-label" text="Changelog" onMouseClicked="#openChangelog"/>
<Separator orientation="VERTICAL"/>
<Label style="-fx-font-weight: bold" text="VATprism"/>
<Label text=" is still in Development. Join the discourse!">
<padding>
Expand Down Expand Up @@ -181,7 +183,7 @@
<FontIcon iconLiteral="oct-bug-16" iconSize="24"/>
</graphic>
</ToggleButton>
<Button styleClass="icon-button" onAction="#showUsageGuide" mnemonicParsing="false">
<Button styleClass="icon-button" onAction="#openUsageGuide" mnemonicParsing="false">
<tooltip>
<Tooltip text="Usage Guide"/>
</tooltip>
Expand Down

0 comments on commit 981d695

Please sign in to comment.