use of javafx.beans.value.WeakChangeListener in project jgnash by ccavanaugh.
the class OptionDialogController method initialize.
@FXML
void initialize() {
// Load the plugin tabs into the dialog
Platform.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());
}
}));
});
}
Aggregations