Search in sources :

Example 1 with GlobalPreferences

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());
}
Also used : Path(java.nio.file.Path) NumberStringConverter(javafx.util.converter.NumberStringConverter) GlobalPreferences(eu.fthevenet.binjr.preferences.GlobalPreferences)

Example 2 with GlobalPreferences

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);
    }
}
Also used : StageStyle(javafx.stage.StageStyle) DataAdapterException(eu.fthevenet.binjr.data.exceptions.DataAdapterException) HPos(javafx.geometry.HPos) Pos(javafx.geometry.Pos) Initializable(javafx.fxml.Initializable) DoubleBinding(javafx.beans.binding.DoubleBinding) javafx.scene.layout(javafx.scene.layout) Dialogs(eu.fthevenet.binjr.dialogs.Dialogs) javafx.scene.control(javafx.scene.control) URL(java.net.URL) URISyntaxException(java.net.URISyntaxException) ZonedDateTime(java.time.ZonedDateTime) NoAdapterFoundException(eu.fthevenet.binjr.data.exceptions.NoAdapterFoundException) DataAdapterDialog(eu.fthevenet.binjr.dialogs.DataAdapterDialog) Side(javafx.geometry.Side) Application(javafx.application.Application) Parent(javafx.scene.Parent) MaskerPane(org.controlsfx.control.MaskerPane) ListChangeListener(javafx.collections.ListChangeListener) DiagnosticCommand(eu.fthevenet.util.diagnositic.DiagnosticCommand) CannotInitializeDataAdapterException(eu.fthevenet.binjr.data.exceptions.CannotInitializeDataAdapterException) eu.fthevenet.util.javafx.controls(eu.fthevenet.util.javafx.controls) UpdateManager(eu.fthevenet.binjr.preferences.UpdateManager) eu.fthevenet.binjr.data.workspace(eu.fthevenet.binjr.data.workspace) USE_COMPUTED_SIZE(javafx.scene.layout.Region.USE_COMPUTED_SIZE) Event(javafx.event.Event) AsyncTaskManager(eu.fthevenet.binjr.data.async.AsyncTaskManager) AppEnvironment(eu.fthevenet.binjr.preferences.AppEnvironment) JAXBException(javax.xml.bind.JAXBException) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) DataAdapter(eu.fthevenet.binjr.data.adapters.DataAdapter) Duration(javafx.util.Duration) Logger(org.apache.logging.log4j.Logger) TimeSeriesBinding(eu.fthevenet.binjr.data.adapters.TimeSeriesBinding) Binjr(eu.fthevenet.binjr.Binjr) Notifications(org.controlsfx.control.Notifications) StageAppearanceManager(eu.fthevenet.binjr.dialogs.StageAppearanceManager) Binding(javafx.beans.binding.Binding) java.util(java.util) GithubRelease(eu.fthevenet.util.github.GithubRelease) Action(org.controlsfx.control.action.Action) DiagnosticException(eu.fthevenet.util.diagnositic.DiagnosticException) javafx.animation(javafx.animation) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DataAdapterFactory(eu.fthevenet.binjr.data.adapters.DataAdapterFactory) DataAdapterInfo(eu.fthevenet.binjr.data.adapters.DataAdapterInfo) Bindings(javafx.beans.binding.Bindings) Supplier(java.util.function.Supplier) VPos(javafx.geometry.VPos) FXMLLoader(javafx.fxml.FXMLLoader) GlobalPreferences(eu.fthevenet.binjr.preferences.GlobalPreferences) StreamSupport(java.util.stream.StreamSupport) Callback(javafx.util.Callback) Color(javafx.scene.paint.Color) javafx.beans.property(javafx.beans.property) javafx.scene.input(javafx.scene.input) Files(java.nio.file.Files) Node(javafx.scene.Node) IOException(java.io.IOException) File(java.io.File) FileChooser(javafx.stage.FileChooser) ActionEvent(javafx.event.ActionEvent) ChronoUnit(java.time.temporal.ChronoUnit) Stage(javafx.stage.Stage) Paths(java.nio.file.Paths) ObservableValue(javafx.beans.value.ObservableValue) LogManager(org.apache.logging.log4j.LogManager) GlobalPreferences(eu.fthevenet.binjr.preferences.GlobalPreferences) Stage(javafx.stage.Stage) File(java.io.File)

Aggregations

GlobalPreferences (eu.fthevenet.binjr.preferences.GlobalPreferences)2 Binjr (eu.fthevenet.binjr.Binjr)1 DataAdapter (eu.fthevenet.binjr.data.adapters.DataAdapter)1 DataAdapterFactory (eu.fthevenet.binjr.data.adapters.DataAdapterFactory)1 DataAdapterInfo (eu.fthevenet.binjr.data.adapters.DataAdapterInfo)1 TimeSeriesBinding (eu.fthevenet.binjr.data.adapters.TimeSeriesBinding)1 AsyncTaskManager (eu.fthevenet.binjr.data.async.AsyncTaskManager)1 CannotInitializeDataAdapterException (eu.fthevenet.binjr.data.exceptions.CannotInitializeDataAdapterException)1 DataAdapterException (eu.fthevenet.binjr.data.exceptions.DataAdapterException)1 NoAdapterFoundException (eu.fthevenet.binjr.data.exceptions.NoAdapterFoundException)1 eu.fthevenet.binjr.data.workspace (eu.fthevenet.binjr.data.workspace)1 DataAdapterDialog (eu.fthevenet.binjr.dialogs.DataAdapterDialog)1 Dialogs (eu.fthevenet.binjr.dialogs.Dialogs)1 StageAppearanceManager (eu.fthevenet.binjr.dialogs.StageAppearanceManager)1 AppEnvironment (eu.fthevenet.binjr.preferences.AppEnvironment)1 UpdateManager (eu.fthevenet.binjr.preferences.UpdateManager)1 DiagnosticCommand (eu.fthevenet.util.diagnositic.DiagnosticCommand)1 DiagnosticException (eu.fthevenet.util.diagnositic.DiagnosticException)1 GithubRelease (eu.fthevenet.util.github.GithubRelease)1 eu.fthevenet.util.javafx.controls (eu.fthevenet.util.javafx.controls)1