Search in sources :

Example 1 with InvalidationListener

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);
        }
    });
}
Also used : InvalidationListener(javafx.beans.InvalidationListener)

Example 2 with InvalidationListener

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);
}
Also used : Button(javafx.scene.control.Button) WebView(javafx.scene.web.WebView) Label(javafx.scene.control.Label) Logger(org.slf4j.Logger) javafx.scene.layout(javafx.scene.layout) ErrorMessage(org.phoenicis.javafx.views.common.ErrorMessage) FilteredList(javafx.collections.transformation.FilteredList) LoggerFactory(org.slf4j.LoggerFactory) FXCollections(javafx.collections.FXCollections) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) InvalidationListener(javafx.beans.InvalidationListener) ApplicationDTO(org.phoenicis.repository.dto.ApplicationDTO) Consumer(java.util.function.Consumer) ScrollPane(javafx.scene.control.ScrollPane) DetailsView(org.phoenicis.javafx.views.common.widgets.lists.DetailsView) SettingsManager(org.phoenicis.settings.SettingsManager) URI(java.net.URI) Tooltip(javafx.scene.control.Tooltip) ThemeManager(org.phoenicis.javafx.views.common.ThemeManager) ScriptDTO(org.phoenicis.repository.dto.ScriptDTO) ScrollPane(javafx.scene.control.ScrollPane) Label(javafx.scene.control.Label) WebView(javafx.scene.web.WebView) URI(java.net.URI)

Example 3 with InvalidationListener

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);
}
Also used : TreeItem(javafx.scene.control.TreeItem) TabsWidget(org.csstudio.display.builder.model.widgets.TabsWidget) Widget(org.csstudio.display.builder.model.Widget) InvalidationListener(javafx.beans.InvalidationListener) ArrayList(java.util.ArrayList) List(java.util.List) ObservableList(javafx.collections.ObservableList) Observable(javafx.beans.Observable)

Example 4 with InvalidationListener

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;
}
Also used : Button(javafx.scene.control.Button) ActionInfo(org.csstudio.display.builder.model.properties.ActionInfo) OpenWebpageActionInfo(org.csstudio.display.builder.model.properties.OpenWebpageActionInfo) ListView(javafx.scene.control.ListView) TextArea(javafx.scene.control.TextArea) ButtonType(javafx.scene.control.ButtonType) ListCell(javafx.scene.control.ListCell) FXCollections(javafx.collections.FXCollections) StackPane(javafx.scene.layout.StackPane) VBox(javafx.scene.layout.VBox) Level(java.util.logging.Level) WritePVActionInfo(org.csstudio.display.builder.model.properties.WritePVActionInfo) InvalidationListener(javafx.beans.InvalidationListener) Insets(javafx.geometry.Insets) GridPane(javafx.scene.layout.GridPane) HBox(javafx.scene.layout.HBox) ScriptInfo(org.csstudio.display.builder.model.properties.ScriptInfo) TextField(javafx.scene.control.TextField) OpenFileActionInfo(org.csstudio.display.builder.model.properties.OpenFileActionInfo) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) Target(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo.Target) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) ToolkitRepresentation.logger(org.csstudio.display.builder.representation.ToolkitRepresentation.logger) Priority(javafx.scene.layout.Priority) List(java.util.List) ExecuteScriptActionInfo(org.csstudio.display.builder.model.properties.ExecuteScriptActionInfo) ToggleGroup(javafx.scene.control.ToggleGroup) Macros(org.csstudio.display.builder.model.macros.Macros) ActionType(org.csstudio.display.builder.model.properties.ActionInfo.ActionType) RadioButton(javafx.scene.control.RadioButton) ImageView(javafx.scene.image.ImageView) Preferences(org.csstudio.display.builder.model.Preferences) MenuButton(javafx.scene.control.MenuButton) ActionInfos(org.csstudio.display.builder.model.properties.ActionInfos) OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo) Toggle(javafx.scene.control.Toggle) ExecuteCommandActionInfo(org.csstudio.display.builder.model.properties.ExecuteCommandActionInfo) ObservableList(javafx.collections.ObservableList) Widget(org.csstudio.display.builder.model.Widget) Collections(java.util.Collections) Image(javafx.scene.image.Image) HBox(javafx.scene.layout.HBox) GridPane(javafx.scene.layout.GridPane) Button(javafx.scene.control.Button) RadioButton(javafx.scene.control.RadioButton) MenuButton(javafx.scene.control.MenuButton) Label(javafx.scene.control.Label) InvalidationListener(javafx.beans.InvalidationListener) TextField(javafx.scene.control.TextField)

Example 5 with InvalidationListener

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;
}
Also used : Button(javafx.scene.control.Button) ActionInfo(org.csstudio.display.builder.model.properties.ActionInfo) OpenWebpageActionInfo(org.csstudio.display.builder.model.properties.OpenWebpageActionInfo) ListView(javafx.scene.control.ListView) TextArea(javafx.scene.control.TextArea) ButtonType(javafx.scene.control.ButtonType) ListCell(javafx.scene.control.ListCell) FXCollections(javafx.collections.FXCollections) StackPane(javafx.scene.layout.StackPane) VBox(javafx.scene.layout.VBox) Level(java.util.logging.Level) WritePVActionInfo(org.csstudio.display.builder.model.properties.WritePVActionInfo) InvalidationListener(javafx.beans.InvalidationListener) Insets(javafx.geometry.Insets) GridPane(javafx.scene.layout.GridPane) HBox(javafx.scene.layout.HBox) ScriptInfo(org.csstudio.display.builder.model.properties.ScriptInfo) TextField(javafx.scene.control.TextField) OpenFileActionInfo(org.csstudio.display.builder.model.properties.OpenFileActionInfo) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) MenuItem(javafx.scene.control.MenuItem) Target(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo.Target) Node(javafx.scene.Node) CheckBox(javafx.scene.control.CheckBox) ToolkitRepresentation.logger(org.csstudio.display.builder.representation.ToolkitRepresentation.logger) Priority(javafx.scene.layout.Priority) List(java.util.List) ExecuteScriptActionInfo(org.csstudio.display.builder.model.properties.ExecuteScriptActionInfo) ToggleGroup(javafx.scene.control.ToggleGroup) Macros(org.csstudio.display.builder.model.macros.Macros) ActionType(org.csstudio.display.builder.model.properties.ActionInfo.ActionType) RadioButton(javafx.scene.control.RadioButton) ImageView(javafx.scene.image.ImageView) Preferences(org.csstudio.display.builder.model.Preferences) MenuButton(javafx.scene.control.MenuButton) ActionInfos(org.csstudio.display.builder.model.properties.ActionInfos) OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo) Toggle(javafx.scene.control.Toggle) ExecuteCommandActionInfo(org.csstudio.display.builder.model.properties.ExecuteCommandActionInfo) ObservableList(javafx.collections.ObservableList) Widget(org.csstudio.display.builder.model.Widget) Collections(java.util.Collections) Image(javafx.scene.image.Image) HBox(javafx.scene.layout.HBox) GridPane(javafx.scene.layout.GridPane) Button(javafx.scene.control.Button) RadioButton(javafx.scene.control.RadioButton) MenuButton(javafx.scene.control.MenuButton) Label(javafx.scene.control.Label) InvalidationListener(javafx.beans.InvalidationListener) TextField(javafx.scene.control.TextField)

Aggregations

InvalidationListener (javafx.beans.InvalidationListener)27 Button (javafx.scene.control.Button)14 Label (javafx.scene.control.Label)13 Node (javafx.scene.Node)12 FXCollections (javafx.collections.FXCollections)11 List (java.util.List)10 ObservableList (javafx.collections.ObservableList)10 Insets (javafx.geometry.Insets)8 Level (java.util.logging.Level)7 Image (javafx.scene.image.Image)7 ImageView (javafx.scene.image.ImageView)7 HBox (javafx.scene.layout.HBox)7 VBox (javafx.scene.layout.VBox)7 ButtonType (javafx.scene.control.ButtonType)6 Dialog (javafx.scene.control.Dialog)6 Priority (javafx.scene.layout.Priority)6 StackPane (javafx.scene.layout.StackPane)6 Widget (org.csstudio.display.builder.model.Widget)6 Collections (java.util.Collections)5 Consumer (java.util.function.Consumer)5