Search in sources :

Example 6 with InvalidationListener

use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.

the class ActionsDialog method createWritePVDetails.

/**
 * @return Sub-pane for WritePV action
 */
private GridPane createWritePVDetails() {
    final InvalidationListener update = whatever -> {
        if (updating || selected_action_index < 0)
            return;
        actions.set(selected_action_index, getWritePVAction());
    };
    final GridPane write_pv_details = new GridPane();
    write_pv_details.setHgap(10);
    write_pv_details.setVgap(10);
    write_pv_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
    write_pv_description = new TextField();
    write_pv_description.textProperty().addListener(update);
    write_pv_details.add(write_pv_description, 1, 0);
    GridPane.setHgrow(write_pv_description, Priority.ALWAYS);
    write_pv_details.add(new Label(Messages.ActionsDialog_PVName), 0, 1);
    write_pv_name = new TextField();
    menu.attachField(write_pv_name);
    setOnHidden((event) -> menu.removeField(write_pv_name));
    write_pv_name.textProperty().addListener(update);
    write_pv_details.add(write_pv_name, 1, 1);
    write_pv_details.add(new Label(Messages.ActionsDialog_Value), 0, 2);
    write_pv_value = new TextField();
    write_pv_value.textProperty().addListener(update);
    write_pv_details.add(write_pv_value, 1, 2);
    return write_pv_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) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) InvalidationListener(javafx.beans.InvalidationListener) TextField(javafx.scene.control.TextField)

Example 7 with InvalidationListener

use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.

the class ActionsDialog method createOpenWebDetails.

/**
 * @return Sub-pane for OpenWeb action
 */
private GridPane createOpenWebDetails() {
    final InvalidationListener update = whatever -> {
        if (updating || selected_action_index < 0)
            return;
        actions.set(selected_action_index, getOpenWebAction());
    };
    final GridPane open_web_details = new GridPane();
    open_web_details.setHgap(10);
    open_web_details.setVgap(10);
    open_web_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
    open_web_description = new TextField();
    open_web_description.textProperty().addListener(update);
    open_web_details.add(open_web_description, 1, 0);
    GridPane.setHgrow(open_web_description, Priority.ALWAYS);
    open_web_details.add(new Label(Messages.ActionsDialog_URL), 0, 1);
    open_web_url = new TextField();
    open_web_url.textProperty().addListener(update);
    open_web_details.add(open_web_url, 1, 1);
    return open_web_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) GridPane(javafx.scene.layout.GridPane) Label(javafx.scene.control.Label) InvalidationListener(javafx.beans.InvalidationListener) TextField(javafx.scene.control.TextField)

Example 8 with InvalidationListener

use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.

the class ActionsDialog method createOpenDisplayDetails.

/**
 * @return Sub-pane for OpenDisplay action
 */
private GridPane createOpenDisplayDetails() {
    final InvalidationListener update = whatever -> {
        if (updating || selected_action_index < 0)
            return;
        actions.set(selected_action_index, getOpenDisplayAction());
    };
    final GridPane open_display_details = new GridPane();
    // open_display_details.setGridLinesVisible(true);
    open_display_details.setHgap(10);
    open_display_details.setVgap(10);
    open_display_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
    open_display_description = new TextField();
    open_display_description.textProperty().addListener(update);
    open_display_details.add(open_display_description, 1, 0);
    GridPane.setHgrow(open_display_description, Priority.ALWAYS);
    open_display_details.add(new Label(Messages.ActionsDialog_DisplayPath), 0, 1);
    open_display_path = new TextField();
    open_display_path.textProperty().addListener(update);
    final Button select = new Button("...");
    select.setOnAction(event -> {
        try {
            final String path = FilenameSupport.promptForRelativePath(widget, open_display_path.getText());
            if (path != null)
                open_display_path.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_display_path, select);
    HBox.setHgrow(open_display_path, Priority.ALWAYS);
    open_display_details.add(path_box, 1, 1);
    final HBox modes_box = new HBox(10);
    open_display_targets = new ToggleGroup();
    final Target[] modes = Target.values();
    for (int i = 0; i < modes.length; ++i) {
        final RadioButton target = new RadioButton(modes[i].toString());
        target.setToggleGroup(open_display_targets);
        target.selectedProperty().addListener(update);
        if (modes[i] == Target.STANDALONE && !Preferences.isStandaloneWindowSupported())
            target.setDisable(true);
        modes_box.getChildren().add(target);
    }
    open_display_details.add(modes_box, 0, 2, 2, 1);
    open_display_macros = new MacrosTable(new Macros());
    open_display_macros.addListener(update);
    open_display_details.add(open_display_macros.getNode(), 0, 3, 2, 1);
    GridPane.setHgrow(open_display_macros.getNode(), Priority.ALWAYS);
    GridPane.setVgrow(open_display_macros.getNode(), Priority.ALWAYS);
    return open_display_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) Label(javafx.scene.control.Label) RadioButton(javafx.scene.control.RadioButton) Macros(org.csstudio.display.builder.model.macros.Macros) Target(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo.Target) Button(javafx.scene.control.Button) RadioButton(javafx.scene.control.RadioButton) MenuButton(javafx.scene.control.MenuButton) ToggleGroup(javafx.scene.control.ToggleGroup) InvalidationListener(javafx.beans.InvalidationListener) TextField(javafx.scene.control.TextField)

Example 9 with InvalidationListener

use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.

the class PopupDemo method start.

@Override
public void start(final Stage stage) {
    final Popup popup = new Popup();
    final BorderPane content = new BorderPane(new Label("Center"), new Label("Top"), new Label("Right"), new Label("Bottom"), new Label("Left"));
    final Rectangle background = new Rectangle(100, 100, Color.LIGHTGRAY);
    final InvalidationListener resize_background = p -> {
        background.setWidth(content.getWidth());
        background.setHeight(content.getHeight());
    };
    content.widthProperty().addListener(resize_background);
    content.heightProperty().addListener(resize_background);
    final StackPane stack = new StackPane(background, content);
    popup.getContent().addAll(stack);
    final Button toggle_popup = new Button("Popup");
    final ChangeListener<Number> track_moves = (p, old, current) -> {
        // Position popup just below button
        final Bounds bounds = toggle_popup.localToScreen(toggle_popup.getBoundsInLocal());
        popup.setX(bounds.getMinX());
        popup.setY(bounds.getMaxY());
    };
    toggle_popup.setOnAction(event -> {
        if (popup.isShowing()) {
            popup.hide();
            toggle_popup.getScene().getWindow().xProperty().removeListener(track_moves);
            toggle_popup.getScene().getWindow().yProperty().removeListener(track_moves);
        } else {
            toggle_popup.getScene().getWindow().xProperty().addListener(track_moves);
            toggle_popup.getScene().getWindow().yProperty().addListener(track_moves);
            track_moves.changed(null, null, null);
            popup.show(stage);
        }
    });
    final BorderPane layout = new BorderPane(toggle_popup);
    stage.setScene(new Scene(layout));
    stage.show();
}
Also used : Button(javafx.scene.control.Button) Scene(javafx.scene.Scene) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) Rectangle(javafx.scene.shape.Rectangle) StackPane(javafx.scene.layout.StackPane) InvalidationListener(javafx.beans.InvalidationListener) Application(javafx.application.Application) Popup(javafx.stage.Popup) Stage(javafx.stage.Stage) BorderPane(javafx.scene.layout.BorderPane) ChangeListener(javafx.beans.value.ChangeListener) Bounds(javafx.geometry.Bounds) BorderPane(javafx.scene.layout.BorderPane) Button(javafx.scene.control.Button) Popup(javafx.stage.Popup) Bounds(javafx.geometry.Bounds) Label(javafx.scene.control.Label) Rectangle(javafx.scene.shape.Rectangle) InvalidationListener(javafx.beans.InvalidationListener) Scene(javafx.scene.Scene) StackPane(javafx.scene.layout.StackPane)

Example 10 with InvalidationListener

use of javafx.beans.InvalidationListener in project org.csstudio.display.builder by kasemir.

the class ColorMapDialog method hookListeners.

private void hookListeners() {
    predefined_table.getSelectionModel().selectedItemProperty().addListener((p, old, selected_map) -> {
        if (selected_map != null)
            updateUIfromMap(selected_map);
    });
    // Assert that at least 2 sections are left
    remove.setOnAction(event -> {
        if (color_sections.size() <= 2)
            return;
        final int index = sections_table.getSelectionModel().getSelectedIndex();
        if (index < 0)
            return;
        color_sections.remove(index);
        updateMapFromSections();
    });
    final InvalidationListener check_sections = observable -> remove.setDisable(color_sections.size() < 3);
    color_sections.addListener(check_sections);
    check_sections.invalidated(color_sections);
    // Try to interpolate new section between existing sections
    add.setOnAction(event -> {
        final int size = color_sections.size();
        final int index = Math.max(0, sections_table.getSelectionModel().getSelectedIndex());
        final ColorSection before = color_sections.get(index);
        if (index + 1 < size) {
            // Add new color in 'middle'
            final ColorSection after = (index + 1) < size ? color_sections.get(index + 1) : null;
            final int mid_value = (before.value + after.value) / 2;
            final Color color_mix = before.color.interpolate(after.color, 0.5);
            color_sections.add(index + 1, new ColorSection(mid_value, color_mix));
        } else
            color_sections.add(new ColorSection(255, before.color));
        updateMapFromSections();
    });
}
Also used : Button(javafx.scene.control.Button) PredefinedColorMaps(org.csstudio.display.builder.model.properties.PredefinedColorMaps) BackgroundSize(javafx.scene.layout.BackgroundSize) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) ButtonType(javafx.scene.control.ButtonType) FXCollections(javafx.collections.FXCollections) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) BackgroundImage(javafx.scene.layout.BackgroundImage) VBox(javafx.scene.layout.VBox) InvalidationListener(javafx.beans.InvalidationListener) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) BackgroundRepeat(javafx.scene.layout.BackgroundRepeat) BackgroundPosition(javafx.scene.layout.BackgroundPosition) TableView(javafx.scene.control.TableView) ColorPicker(javafx.scene.control.ColorPicker) HBox(javafx.scene.layout.HBox) Color(javafx.scene.paint.Color) Dialog(javafx.scene.control.Dialog) Label(javafx.scene.control.Label) Node(javafx.scene.Node) WritableImage(javafx.scene.image.WritableImage) ColorMap(org.csstudio.display.builder.model.properties.ColorMap) Background(javafx.scene.layout.Background) Separator(javafx.scene.control.Separator) Priority(javafx.scene.layout.Priority) Region(javafx.scene.layout.Region) PixelWriter(javafx.scene.image.PixelWriter) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction) ObservableList(javafx.collections.ObservableList) Color(javafx.scene.paint.Color) InvalidationListener(javafx.beans.InvalidationListener)

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