use of eu.fthevenet.binjr.preferences.GlobalPreferences in project selenium_java by sergueik.
the class PreferenceDialogController method initialize.
@Override
public void initialize(URL location, ResourceBundle resources) {
assert downSamplingThreshold != null : "fx:id\"RDPEpsilon\" was not injected!";
assert enableDownSampling != null : "fx:id\"enableDownSampling\" was not injected!";
assert maxSampleLabel != null : "fx:id\"maxSampleLabel\" was not injected!";
assert accordionPane != null : "fx:id\"accordionPane\" was not injected!";
assert loadAtStartupCheckbox != null : "fx:id\"loadAtStartupCheckbox\" was not injected!";
assert uiThemeChoiceBox != null : "fx:id\"uiThemeChoiceBox\" was not injected!";
assert updateFlow != null : "fx:id\"updateFlow\" was not injected!";
assert updateCheckBox != null : "fx:id\"updateCheckBox\" was not injected!";
assert showOutline != null : "fx:id\"showOutline\" was not injected!";
assert graphOpacitySlider != null : "fx:id\"graphOpacitySlider\" was not injected!";
GlobalPreferences prefs = GlobalPreferences.getInstance();
graphOpacitySlider.valueProperty().bindBidirectional(prefs.defaultGraphOpacityProperty());
opacityText.textProperty().bind(Bindings.format("%.0f%%", graphOpacitySlider.valueProperty().multiply(100)));
enableDownSampling.selectedProperty().addListener((observable, oldValue, newValue) -> {
downSamplingThreshold.setDisable(!newValue);
maxSampleLabel.setDisable(!newValue);
});
enableDownSampling.selectedProperty().bindBidirectional(prefs.downSamplingEnabledProperty());
final TextFormatter<Path> pathFormatter = new TextFormatter<>(new StringConverter<Path>() {
@Override
public String toString(Path object) {
return object.toString();
}
@Override
public Path fromString(String string) {
return Paths.get(string);
}
});
pathFormatter.valueProperty().bindBidirectional(prefs.pluginsLocationProperty());
pluginLocTextfield.setTextFormatter(pathFormatter);
prefs.pluginsLocationProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null && !Files.exists(newValue)) {
Dialogs.notifyError("Invalid Plugins Folder Location", "The selected path for the plugins folder location does not exists", Pos.BOTTOM_RIGHT, root);
Platform.runLater(() -> prefs.setPluginsLocation(oldValue));
} else {
Dialogs.notifyInfo("Plugins Folder Location Changed", "Changes to the plugins folder location will take effect the next time binjr is started", Pos.BOTTOM_RIGHT, root);
}
});
loadExternalToggle.selectedProperty().bindBidirectional(prefs.loadPluginsFromExternalLocationProperty());
browsePluginLocButton.disableProperty().bind(prefs.loadPluginsFromExternalLocationProperty().not());
pluginLocTextfield.disableProperty().bind(prefs.loadPluginsFromExternalLocationProperty().not());
enabledColumn.setCellFactory(CheckBoxTableCell.forTableColumn(enabledColumn));
availableAdapterTable.getItems().setAll(DataAdapterFactory.getInstance().getAllAdapters());
loadAtStartupCheckbox.selectedProperty().bindBidirectional(prefs.loadLastWorkspaceOnStartupProperty());
final TextFormatter<Number> formatter = new TextFormatter<>(new NumberStringConverter(Locale.getDefault(Locale.Category.FORMAT)));
downSamplingThreshold.setTextFormatter(formatter);
formatter.valueProperty().bindBidirectional(prefs.downSamplingThresholdProperty());
uiThemeChoiceBox.getItems().setAll(UserInterfaceThemes.values());
uiThemeChoiceBox.getSelectionModel().select(prefs.getUserInterfaceTheme());
prefs.userInterfaceThemeProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
uiThemeChoiceBox.getSelectionModel().select(newValue);
}
});
uiThemeChoiceBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
prefs.setUserInterfaceTheme(newValue);
}
});
notifcationDurationChoiceBox.getItems().setAll(NotificationDurationChoices.values());
notifcationDurationChoiceBox.getSelectionModel().select(NotificationDurationChoices.valueOf(prefs.getNotificationPopupDuration()));
prefs.notificationPopupDurationProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
notifcationDurationChoiceBox.getSelectionModel().select(NotificationDurationChoices.valueOf(newValue));
}
});
notifcationDurationChoiceBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
prefs.setNotificationPopupDuration(newValue.getDuration());
}
});
updateCheckBox.selectedProperty().bindBidirectional(prefs.checkForUpdateOnStartUpProperty());
showOutline.selectedProperty().bindBidirectional(prefs.showAreaOutlineProperty());
}
use of eu.fthevenet.binjr.preferences.GlobalPreferences 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