use of eu.fthevenet.binjr.Binjr in project selenium_java by sergueik.
the class MainViewController method onAvailableUpdate.
private void onAvailableUpdate(GithubRelease githubRelease) {
Notifications n = Notifications.create().title("New release available!").text("You are currently running binjr version " + AppEnvironment.getInstance().getVersion() + "\t\t.\nVersion " + githubRelease.getVersion() + " is now available.").hideAfter(Duration.seconds(20)).position(Pos.BOTTOM_RIGHT).owner(root);
n.action(new Action("Download", actionEvent -> {
String newReleaseUrl = githubRelease.getHtmlUrl();
if (newReleaseUrl != null && newReleaseUrl.trim().length() > 0) {
try {
Dialogs.launchUrlInExternalBrowser(newReleaseUrl);
} catch (IOException | URISyntaxException e) {
logger.error("Failed to launch url in browser " + newReleaseUrl, e);
}
}
n.hideAfter(Duration.seconds(0));
}));
n.showInformation();
}
use of eu.fthevenet.binjr.Binjr in project selenium_java by sergueik.
the class MainViewController method runAfterInitialize.
protected void runAfterInitialize() {
GlobalPreferences prefs = GlobalPreferences.getInstance();
Stage stage = Dialogs.getStage(root);
stage.titleProperty().bind(Bindings.createStringBinding(() -> String.format("%s%s - binjr", (workspace.isDirty() ? "*" : ""), workspace.pathProperty().getValue().toString()), workspace.pathProperty(), workspace.dirtyProperty()));
stage.setOnCloseRequest(event -> {
if (!confirmAndClearWorkspace()) {
event.consume();
} else {
Platform.exit();
}
});
stage.addEventFilter(KeyEvent.KEY_PRESSED, e -> handleControlKey(e, true));
stage.addEventFilter(KeyEvent.KEY_RELEASED, e -> handleControlKey(e, false));
stage.focusedProperty().addListener((observable, oldValue, newValue) -> {
// main stage lost focus -> invalidates shift or ctrl pressed
prefs.setShiftPressed(false);
prefs.setCtrlPressed(false);
});
if (associatedFile.isPresent()) {
logger.debug(() -> "Opening associated file " + associatedFile.get());
loadWorkspace(new File(associatedFile.get()));
} else if (prefs.isLoadLastWorkspaceOnStartup()) {
prefs.getMostRecentSavedWorkspace().ifPresent(path -> {
File latestWorkspace = path.toFile();
if (latestWorkspace.exists()) {
loadWorkspace(latestWorkspace);
} else {
logger.warn("Cannot reopen workspace " + latestWorkspace.getPath() + ": file does not exists");
}
});
}
if (prefs.isCheckForUpdateOnStartUp()) {
UpdateManager.getInstance().asyncCheckForUpdate(this::onAvailableUpdate, null, null);
}
}
Aggregations