diff --git a/BudgetMasterClient/src/main/java/de/deadlocker8/budgetmasterclient/ui/controller/Controller.java b/BudgetMasterClient/src/main/java/de/deadlocker8/budgetmasterclient/ui/controller/Controller.java index ebbca63959dbf5ceee8b808106f634dc48a27938..c6871c3d31ecf7af0b33777e0f5546b8a8c308e8 100644 --- a/BudgetMasterClient/src/main/java/de/deadlocker8/budgetmasterclient/ui/controller/Controller.java +++ b/BudgetMasterClient/src/main/java/de/deadlocker8/budgetmasterclient/ui/controller/Controller.java @@ -472,89 +472,7 @@ public class Controller extends BaseController } Platform.runLater(()->{ - Alert alert = new Alert(AlertType.INFORMATION); - alert.setTitle(Localization.getString(Strings.INFO_TITLE_UPDATE_AVAILABLE)); - alert.setHeaderText(""); - Stage dialogStage = (Stage)alert.getDialogPane().getScene().getWindow(); - dialogStage.getIcons().add(icon); - - Hyperlink linkText = new Hyperlink(Localization.getString(Strings.INFO_TEXT_UPDATE_AVAILABLE_SHOW_CHANGES)); - linkText.setOnAction((event)->{ - if(Desktop.isDesktopSupported()) - { - try - { - Desktop.getDesktop().browse(new URI(Helpers.ROADMAP_URL)); - } - catch(IOException | URISyntaxException e) - { - Logger.error(e); - AlertGenerator.showAlert(AlertType.ERROR, - Localization.getString(Strings.TITLE_ERROR), - "", - Localization.getString(Strings.ERROR_OPEN_BROWSER), - icon, getStage(), null, false); - } - } - }); - - TextFlow textFlow = new TextFlow( - new Text(Localization.getString(Strings.INFO_TEXT_UPDATE_AVAILABLE, - updater.getLatestVersion().getVersionName())), - linkText - ); - - alert.getDialogPane().setContent(textFlow); - - ButtonType buttonTypeOne = new ButtonType(Localization.getString(Strings.INFO_TEXT_UPDATE_AVAILABLE_NOW)); - ButtonType buttonTypeTwo = new ButtonType(Localization.getString(Strings.CANCEL)); - alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeTwo); - - DialogPane dialogPane = alert.getDialogPane(); - dialogPane.getButtonTypes().stream().map(dialogPane::lookupButton).forEach(button -> button.addEventHandler(KeyEvent.KEY_PRESSED, (event) -> { - if(KeyCode.ENTER.equals(event.getCode()) && event.getTarget() instanceof Button) - { - ((Button)event.getTarget()).fire(); - } - })); - - Optional<ButtonType> result = alert.showAndWait(); - if (result.get() == buttonTypeOne) - { - Stage modalStage = UIHelpers.showModal(Localization.getString(Strings.TITLE_MODAL), Localization.getString(Strings.LOAD_UPDATE), getStage(), icon); - - Worker.runLater(() -> { - try - { - updater.downloadLatestVersion(); - Platform.runLater(() -> { - if(modalStage != null) - { - modalStage.close(); - } - }); - } - catch(Exception ex) - { - Logger.error(ex); - Platform.runLater(() -> { - if(modalStage != null) - { - modalStage.close(); - AlertGenerator.showAlert(AlertType.ERROR, - Localization.getString(Strings.TITLE_ERROR), - "", - Localization.getString(Strings.ERROR_UPDATER_DOWNLOAD_LATEST_VERSION, ex.getMessage()), - icon, getStage(), null, true); - } - }); - } - }); - } - else - { - alert.close(); - } + showUpdateAlert(); }); } catch(Exception e) @@ -567,6 +485,115 @@ public class Controller extends BaseController icon, null, null, true); } } + + private void showUpdateAlert() + { + Alert alert = new Alert(AlertType.INFORMATION); + alert.setTitle(Localization.getString(Strings.INFO_TITLE_UPDATE_AVAILABLE)); + alert.setHeaderText(""); + Stage dialogStage = (Stage)alert.getDialogPane().getScene().getWindow(); + dialogStage.getIcons().add(icon); + + Hyperlink linkText = new Hyperlink(Localization.getString(Strings.INFO_TEXT_UPDATE_AVAILABLE_SHOW_CHANGES)); + linkText.setOnAction((event)->{ + if(Desktop.isDesktopSupported()) + { + try + { + Desktop.getDesktop().browse(new URI(Localization.getString(Strings.ROADMAP_URL))); + } + catch(IOException | URISyntaxException e) + { + Logger.error(e); + AlertGenerator.showAlert(AlertType.ERROR, + Localization.getString(Strings.TITLE_ERROR), + "", + Localization.getString(Strings.ERROR_OPEN_BROWSER), + icon, getStage(), null, false); + } + } + }); + + Hyperlink detailedMilestones = new Hyperlink(Localization.getString(Strings.INFO_TEXT_UPDATE_AVAILABLE_SHOW_CHANGES_DETAILED)); + detailedMilestones.setOnAction((event)->{ + if(Desktop.isDesktopSupported()) + { + try + { + Desktop.getDesktop().browse(new URI(Localization.getString(Strings.GITHUB_URL))); + } + catch(IOException | URISyntaxException e) + { + Logger.error(e); + AlertGenerator.showAlert(AlertType.ERROR, + Localization.getString(Strings.TITLE_ERROR), + "", + Localization.getString(Strings.ERROR_OPEN_BROWSER), + icon, getStage(), null, false); + } + } + }); + + TextFlow textFlow = new TextFlow( + new Text(Localization.getString(Strings.INFO_TEXT_UPDATE_AVAILABLE, + updater.getLatestVersion().getVersionName())), + linkText, + new Text("\n\n"), + detailedMilestones + ); + + alert.getDialogPane().setContent(textFlow); + + ButtonType buttonTypeOne = new ButtonType(Localization.getString(Strings.INFO_TEXT_UPDATE_AVAILABLE_NOW)); + ButtonType buttonTypeTwo = new ButtonType(Localization.getString(Strings.CANCEL)); + alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeTwo); + + DialogPane dialogPane = alert.getDialogPane(); + dialogPane.getButtonTypes().stream().map(dialogPane::lookupButton).forEach(button -> button.addEventHandler(KeyEvent.KEY_PRESSED, (event) -> { + if(KeyCode.ENTER.equals(event.getCode()) && event.getTarget() instanceof Button) + { + ((Button)event.getTarget()).fire(); + } + })); + + Optional<ButtonType> result = alert.showAndWait(); + if (result.get() == buttonTypeOne) + { + Stage modalStage = UIHelpers.showModal(Localization.getString(Strings.TITLE_MODAL), Localization.getString(Strings.LOAD_UPDATE), getStage(), icon); + + Worker.runLater(() -> { + try + { + updater.downloadLatestVersion(); + Platform.runLater(() -> { + if(modalStage != null) + { + modalStage.close(); + } + }); + } + catch(Exception ex) + { + Logger.error(ex); + Platform.runLater(() -> { + if(modalStage != null) + { + modalStage.close(); + AlertGenerator.showAlert(AlertType.ERROR, + Localization.getString(Strings.TITLE_ERROR), + "", + Localization.getString(Strings.ERROR_UPDATER_DOWNLOAD_LATEST_VERSION, ex.getMessage()), + icon, getStage(), null, true); + } + }); + } + }); + } + else + { + alert.close(); + } + } public void about() { diff --git a/BudgetMasterClient/src/main/resources/de/deadlocker8/budgetmaster/languages/_de.properties b/BudgetMasterClient/src/main/resources/de/deadlocker8/budgetmaster/languages/_de.properties index 585f5751f75618ac87e9275b9b0529528b1e4add..c7f65097449748c1a987ed288ac0505faf4a252c 100644 --- a/BudgetMasterClient/src/main/resources/de/deadlocker8/budgetmaster/languages/_de.properties +++ b/BudgetMasterClient/src/main/resources/de/deadlocker8/budgetmaster/languages/_de.properties @@ -1,12 +1,14 @@ # DEFAULT app.name=BudgetMaster -version.code=7 +version.code=11 version.name=1.7.0_alpha version.date=03.10.17 author=Robert Goldmann credits=L�nderflaggen von Freepik auf https://www.flaticon.com\nVerwendete Schriftarten: OpenSans folder=Deadlocker/BudgetMaster +roadmap.url=https://deadlocker.thecodelabs.de/roadmap/php/index.php?id=1 +github.url=https://github.com/deadlocker8/BudgetMaster # TITLE @@ -149,6 +151,7 @@ info.text.language.changed.restart.later=Sp info.title.update.available=Update verf�gbar info.text.update.available=Ein Update ist verf�gbar.\nNeue Version: {0}\n\n info.text.update.available.show.changes=�nderungen anzeigen (�ffnet Webbrowser) +info.text.update.available.show.changes.detailed=(detaillierte Infos auf GitHub.com) info.text.update.available.now=Jetzt updaten info.title.start.after.update=Update erfolgreich info.header.text.start.after.update=BudgetMaster wurde erfolgreich auf Version {0} aktualisiert diff --git a/BudgetMasterClient/src/main/resources/de/deadlocker8/budgetmaster/languages/_en.properties b/BudgetMasterClient/src/main/resources/de/deadlocker8/budgetmaster/languages/_en.properties index c777879aacbe3bebfc1875e18bc23b5b132ffc10..d5ab4ad5423d7339c3330587643f9c0cd2104012 100644 --- a/BudgetMasterClient/src/main/resources/de/deadlocker8/budgetmaster/languages/_en.properties +++ b/BudgetMasterClient/src/main/resources/de/deadlocker8/budgetmaster/languages/_en.properties @@ -7,6 +7,8 @@ author=Robert Goldmann credits=Flags by Freepik on https://www.flaticon.com\nFonts used: OpenSans folder=Deadlocker/BudgetMaster +roadmap.url=https://deadlocker.thecodelabs.de/roadmap/php/index.php?id=2 +github.url=https://github.com/deadlocker8/BudgetMaster # TITLE @@ -149,6 +151,7 @@ info.text.language.changed.restart.later=Restart Later info.title.update.available=Update available info.text.update.available=An update is available.\nNew version: {0}\n\n info.text.update.available.show.changes=Show Changes (opens web browsers) +info.text.update.available.show.changes.detailed=(detailed information on GitHub.com) info.text.update.available.now=Update Now info.title.start.after.update=Update successfull info.header.text.start.after.update=Successfully updated BudgetMaster to version {0} diff --git a/BudgetMasterCore/src/main/java/de/deadlocker8/budgetmaster/logic/utils/Strings.java b/BudgetMasterCore/src/main/java/de/deadlocker8/budgetmaster/logic/utils/Strings.java index 735730eb24c9a4ee11d9786b92029d0cbd922b97..85a9172ecef1745d30fc076692759b7a437321e8 100644 --- a/BudgetMasterCore/src/main/java/de/deadlocker8/budgetmaster/logic/utils/Strings.java +++ b/BudgetMasterCore/src/main/java/de/deadlocker8/budgetmaster/logic/utils/Strings.java @@ -9,7 +9,9 @@ public class Strings public static final String VERSION_DATE = "version.date"; public static final String AUTHOR = "author"; public static final String CREDITS = "credits"; - public static final String FOLDER = "folder"; + public static final String FOLDER = "folder"; + public static final String ROADMAP_URL = "roadmap.url"; + public static final String GITHUB_URL = "github.url"; //TITLE public static final String TITLE_INCOMES = "title.incomes"; @@ -152,6 +154,7 @@ public class Strings public static final String INFO_TITLE_UPDATE_AVAILABLE = "info.title.update.available"; public static final String INFO_TEXT_UPDATE_AVAILABLE = "info.text.update.available"; public static final String INFO_TEXT_UPDATE_AVAILABLE_SHOW_CHANGES = "info.text.update.available.show.changes"; + public static final String INFO_TEXT_UPDATE_AVAILABLE_SHOW_CHANGES_DETAILED = "info.text.update.available.show.changes.detailed"; public static final String INFO_TEXT_UPDATE_AVAILABLE_NOW = "info.text.update.available.now"; public static final String INFO_TITLE_START_AFTER_UPDATE = "info.title.start.after.update"; public static final String INFO_HEADER_TEXT_START_AFTER_UPDATE = "info.header.text.start.after.update";