use of javafx.beans.InvalidationListener in project cryptomator by cryptomator.
the class ObservableListOnMainThread method invalidated.
private void invalidated(Observable observable) {
final Collection<InvalidationListener> listeners = ImmutableList.copyOf(invalidationListeners);
Platform.runLater(() -> {
for (InvalidationListener listener : listeners) {
listener.invalidated(this);
}
});
}
use of javafx.beans.InvalidationListener in project POL-POM-5 by PlayOnLinux.
the class AppPanel method populateCenter.
private void populateCenter() {
this.appDescription = new WebView();
this.appDescription.getEngine().loadContent("<body>" + application.getDescription() + "</body>");
themeManager.bindWebEngineStylesheet(appDescription.getEngine().userStyleSheetLocationProperty());
this.installers = new Label(tr("Installers"));
this.installers.getStyleClass().add("descriptionTitle");
this.scriptGrid = new GridPane();
filteredScripts.addListener((InvalidationListener) change -> this.refreshScripts());
this.refreshScripts();
this.miniaturesPane = new HBox();
this.miniaturesPane.getStyleClass().add("appPanelMiniaturesPane");
this.miniaturesPaneWrapper = new ScrollPane(miniaturesPane);
this.miniaturesPaneWrapper.getStyleClass().add("appPanelMiniaturesPaneWrapper");
for (URI miniatureUri : application.getMiniatures()) {
Region image = new Region();
image.getStyleClass().add("appMiniature");
image.setStyle(String.format("-fx-background-image: url(\"%s\");", miniatureUri.toString()));
image.prefHeightProperty().bind(miniaturesPaneWrapper.heightProperty().multiply(0.8));
image.prefWidthProperty().bind(image.prefHeightProperty().multiply(1.5));
miniaturesPane.getChildren().add(image);
}
this.center = new VBox(appDescription, installers, scriptGrid, miniaturesPaneWrapper);
VBox.setVgrow(appDescription, Priority.ALWAYS);
this.setCenter(center);
}
use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.
the class WidgetTree method bindSelections.
/**
* Link selections in tree view and model
*/
private void bindSelections() {
// Update selected widgets in model from selection in tree_view
final ObservableList<TreeItem<WidgetOrTab>> tree_selection = tree_view.getSelectionModel().getSelectedItems();
InvalidationListener listener = (Observable observable) -> {
if (!active.compareAndSet(false, true))
return;
try {
final List<Widget> widgets = new ArrayList<>(tree_selection.size());
for (TreeItem<WidgetOrTab> item : tree_selection) {
final WidgetOrTab wot = item.getValue();
final Widget widget = wot.isWidget() ? wot.getWidget() : wot.getTab().getWidget();
if (!widgets.contains(widget))
widgets.add(widget);
}
;
logger.log(Level.FINE, "Selected in tree: {0}", widgets);
editor.getWidgetSelectionHandler().setSelection(widgets);
} finally {
active.set(false);
}
};
tree_selection.addListener(listener);
// Update selection in tree_view from selected widgets in model
editor.getWidgetSelectionHandler().addListener(this::setSelectedWidgets);
}
use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.
the class ActionsDialog method createOpenFileDetails.
/**
* @return Sub-pane for OpenFile action
*/
private GridPane createOpenFileDetails() {
final InvalidationListener update = whatever -> {
if (updating || selected_action_index < 0)
return;
actions.set(selected_action_index, getOpenFileAction());
};
final GridPane open_file_details = new GridPane();
open_file_details.setHgap(10);
open_file_details.setVgap(10);
open_file_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
open_file_description = new TextField();
open_file_description.textProperty().addListener(update);
open_file_details.add(open_file_description, 1, 0);
GridPane.setHgrow(open_file_description, Priority.ALWAYS);
open_file_details.add(new Label(Messages.ActionsDialog_FilePath), 0, 1);
open_file_file = new TextField();
open_file_file.textProperty().addListener(update);
final Button select = new Button("...");
select.setOnAction(event -> {
try {
final String path = FilenameSupport.promptForRelativePath(widget, open_file_file.getText());
if (path != null)
open_file_file.setText(path);
FilenameSupport.performMostAwfulTerribleNoGoodHack(action_list);
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot prompt for filename", ex);
}
});
final HBox path_box = new HBox(open_file_file, select);
HBox.setHgrow(open_file_file, Priority.ALWAYS);
open_file_details.add(path_box, 1, 1);
return open_file_details;
}
use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.
the class ActionsDialog method createExecuteCommandDetails.
/**
* @return Sub-pane for ExecuteCommand action
*/
private GridPane createExecuteCommandDetails() {
final InvalidationListener update = whatever -> {
if (updating || selected_action_index < 0)
return;
actions.set(selected_action_index, getExecuteCommandAction());
};
final GridPane execute_command_details = new GridPane();
execute_command_details.setHgap(10);
execute_command_details.setVgap(10);
execute_command_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
execute_command_description = new TextField();
execute_command_description.textProperty().addListener(update);
execute_command_details.add(execute_command_description, 1, 0);
GridPane.setHgrow(execute_command_description, Priority.ALWAYS);
execute_command_details.add(new Label(Messages.ActionsDialog_FilePath), 0, 1);
execute_command_file = new TextField();
execute_command_file.textProperty().addListener(update);
final Button select = new Button("...");
select.setOnAction(event -> {
try {
final String path = FilenameSupport.promptForRelativePath(widget, execute_command_file.getText());
if (path != null)
execute_command_file.setText(path);
FilenameSupport.performMostAwfulTerribleNoGoodHack(action_list);
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot prompt for filename", ex);
}
});
final HBox path_box = new HBox(execute_command_file, select);
HBox.setHgrow(execute_command_file, Priority.ALWAYS);
execute_command_details.add(path_box, 1, 1);
return execute_command_details;
}
Aggregations