Search in sources :

Example 1 with FxPlugin

use of jgnash.plugin.FxPlugin in project jgnash by ccavanaugh.

the class OptionDialogController method initialize.

@FXML
void initialize() {
    // Load the plugin tabs into the dialog
    JavaFXUtils.runLater(() -> PluginFactory.getPlugins().stream().filter(plugin -> plugin instanceof FxPlugin).forEachOrdered(plugin -> {
        final Node tab = ((FxPlugin) plugin).getOptionsNode();
        if (tab != null) {
            tabPane.getTabs().add(new Tab(plugin.getName(), tab));
        }
    }));
    JavaFXUtils.runLater(() -> {
        final Preferences preferences = Preferences.userNodeForPackage(OptionDialogController.class);
        tabPane.getSelectionModel().select(preferences.getInt(INDEX, 0));
        tabPane.getSelectionModel().selectedIndexProperty().addListener(new WeakChangeListener<>((observable, oldValue, newValue) -> {
            if (newValue != null) {
                preferences.putInt(INDEX, newValue.intValue());
            }
        }));
    });
}
Also used : WeakChangeListener(javafx.beans.value.WeakChangeListener) Scene(javafx.scene.Scene) ObjectProperty(javafx.beans.property.ObjectProperty) PluginFactory(jgnash.plugin.PluginFactory) InjectFXML(jgnash.uifx.util.InjectFXML) Node(javafx.scene.Node) JavaFXUtils(jgnash.uifx.util.JavaFXUtils) Preferences(java.util.prefs.Preferences) FXML(javafx.fxml.FXML) TabPane(javafx.scene.control.TabPane) Stage(javafx.stage.Stage) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Tab(javafx.scene.control.Tab) FxPlugin(jgnash.plugin.FxPlugin) Tab(javafx.scene.control.Tab) Node(javafx.scene.Node) Preferences(java.util.prefs.Preferences) FxPlugin(jgnash.plugin.FxPlugin) InjectFXML(jgnash.uifx.util.InjectFXML) FXML(javafx.fxml.FXML)

Aggregations

Preferences (java.util.prefs.Preferences)1 ObjectProperty (javafx.beans.property.ObjectProperty)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 WeakChangeListener (javafx.beans.value.WeakChangeListener)1 FXML (javafx.fxml.FXML)1 Node (javafx.scene.Node)1 Scene (javafx.scene.Scene)1 Tab (javafx.scene.control.Tab)1 TabPane (javafx.scene.control.TabPane)1 Stage (javafx.stage.Stage)1 FxPlugin (jgnash.plugin.FxPlugin)1 PluginFactory (jgnash.plugin.PluginFactory)1 InjectFXML (jgnash.uifx.util.InjectFXML)1 JavaFXUtils (jgnash.uifx.util.JavaFXUtils)1