Search in sources :

Example 16 with InvalidationListener

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

the class ActionsDialog method createExecuteScriptDetails.

/**
 * @return Sub-pane for ExecuteScript action
 */
private GridPane createExecuteScriptDetails() {
    final InvalidationListener update = whatever -> {
        if (updating || selected_action_index < 0)
            return;
        actions.set(selected_action_index, getExecuteScriptAction());
    };
    final GridPane execute_script_details = new GridPane();
    execute_script_details.setHgap(10);
    execute_script_details.setVgap(10);
    execute_script_details.add(new Label(Messages.ActionsDialog_Description), 0, 0);
    execute_script_description = new TextField();
    execute_script_description.textProperty().addListener(update);
    execute_script_details.add(execute_script_description, 1, 0);
    GridPane.setHgrow(execute_script_description, Priority.ALWAYS);
    execute_script_details.add(new Label(Messages.ActionsDialog_ScriptPath), 0, 1);
    execute_script_file = new TextField();
    execute_script_file.textProperty().addListener(update);
    final Button select = new Button("...");
    select.setOnAction(event -> {
        try {
            final String path = FilenameSupport.promptForRelativePath(widget, execute_script_file.getText());
            if (path != null)
                execute_script_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_script_file, select);
    HBox.setHgrow(execute_script_file, Priority.ALWAYS);
    execute_script_details.add(path_box, 1, 1);
    final Button btn_embed_py = new Button(Messages.ScriptsDialog_BtnEmbedPy, JFXUtil.getIcon("embedded_script.png"));
    btn_embed_py.setOnAction(event -> {
        execute_script_file.setText(ScriptInfo.EMBEDDED_PYTHON);
        final String text = execute_script_text.getText();
        if (text == null || text.trim().isEmpty() || text.trim().equals(ScriptInfo.EXAMPLE_JAVASCRIPT))
            execute_script_text.setText(ScriptInfo.EXAMPLE_PYTHON);
    });
    final Button btn_embed_js = new Button(Messages.ScriptsDialog_BtnEmbedJS, JFXUtil.getIcon("embedded_script.png"));
    btn_embed_js.setOnAction(event -> {
        execute_script_file.setText(ScriptInfo.EMBEDDED_JAVASCRIPT);
        final String text = execute_script_text.getText();
        if (text == null || text.trim().isEmpty() || text.trim().equals(ScriptInfo.EXAMPLE_PYTHON))
            execute_script_text.setText(ScriptInfo.EXAMPLE_JAVASCRIPT);
    });
    execute_script_details.add(new HBox(10, btn_embed_py, btn_embed_js), 1, 2);
    execute_script_details.add(new Label(Messages.ActionsDialog_ScriptText), 0, 3);
    execute_script_text = new TextArea();
    execute_script_text.setText(null);
    execute_script_text.textProperty().addListener(update);
    execute_script_details.add(execute_script_text, 0, 4, 2, 1);
    GridPane.setVgrow(execute_script_text, Priority.ALWAYS);
    return execute_script_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) TextArea(javafx.scene.control.TextArea) Label(javafx.scene.control.Label) InvalidationListener(javafx.beans.InvalidationListener) TextField(javafx.scene.control.TextField)

Example 17 with InvalidationListener

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

the class JFXRepresentation method createModelRoot.

/**
 * Create scrollpane etc. for hosting the model
 *
 *  @return ScrollPane
 *  @throws IllegalStateException if had already been called
 */
public final ScrollPane createModelRoot() {
    if (model_root != null)
        throw new IllegalStateException("Already created model root");
    widget_parent = new Pane();
    scroll_body = new Group(widget_parent);
    if (isEditMode()) {
        horiz_bound = new Line();
        horiz_bound.getStyleClass().add("display_model_bounds");
        horiz_bound.setStartX(0);
        vert_bound = new Line();
        vert_bound.getStyleClass().add("display_model_bounds");
        vert_bound.setStartY(0);
        scroll_body.getChildren().addAll(vert_bound, horiz_bound);
    }
    model_root = new ScrollPane(scroll_body);
    final InvalidationListener resized = prop -> handleViewportChanges();
    model_root.widthProperty().addListener(resized);
    model_root.heightProperty().addListener(resized);
    // Middle Button (Wheel press) drag panning started
    final EventHandler<MouseEvent> onMousePressedHandler = evt -> {
        if (evt.isMiddleButtonDown()) {
            lastMouseCoordinates.set(new Point2D(evt.getX(), evt.getY()));
            scroll_body.setCursor(Cursor.CLOSED_HAND);
            evt.consume();
        }
    };
    if (isEditMode())
        scroll_body.addEventFilter(MouseEvent.MOUSE_PRESSED, onMousePressedHandler);
    else
        scroll_body.setOnMousePressed(onMousePressedHandler);
    // Middle Button (Wheel press) drag panning function
    final EventHandler<MouseEvent> onMouseDraggedHandler = evt -> {
        if (evt.isMiddleButtonDown()) {
            double deltaX = evt.getX() - lastMouseCoordinates.get().getX();
            double extraWidth = scroll_body.getLayoutBounds().getWidth() - model_root.getViewportBounds().getWidth();
            double deltaH = deltaX * (model_root.getHmax() - model_root.getHmin()) / extraWidth;
            double desiredH = model_root.getHvalue() - deltaH;
            model_root.setHvalue(Math.max(0, Math.min(model_root.getHmax(), desiredH)));
            double deltaY = evt.getY() - lastMouseCoordinates.get().getY();
            double extraHeight = scroll_body.getLayoutBounds().getHeight() - model_root.getViewportBounds().getHeight();
            double deltaV = deltaY * (model_root.getHmax() - model_root.getHmin()) / extraHeight;
            double desiredV = model_root.getVvalue() - deltaV;
            model_root.setVvalue(Math.max(0, Math.min(model_root.getVmax(), desiredV)));
            evt.consume();
        }
    };
    if (isEditMode())
        scroll_body.addEventFilter(MouseEvent.MOUSE_DRAGGED, onMouseDraggedHandler);
    else
        scroll_body.setOnMouseDragged(onMouseDraggedHandler);
    // Middle Button (Wheel press) drag panning finished
    final EventHandler<MouseEvent> onMouseReleasedHandler = evt -> {
        if (scroll_body.getCursor() == Cursor.CLOSED_HAND) {
            scroll_body.setCursor(Cursor.DEFAULT);
            evt.consume();
        }
    };
    if (isEditMode())
        scroll_body.addEventFilter(MouseEvent.MOUSE_RELEASED, onMouseReleasedHandler);
    else
        scroll_body.setOnMouseReleased(onMouseReleasedHandler);
    // also handle the wheel
    if (isEditMode())
        model_root.addEventFilter(ScrollEvent.ANY, evt -> {
            if (evt.isControlDown()) {
                evt.consume();
                doWheelZoom(evt.getDeltaY(), evt.getX(), evt.getY());
            }
        });
    else
        widget_parent.addEventHandler(ScrollEvent.ANY, evt -> {
            if (evt.isControlDown()) {
                evt.consume();
                ScrollEvent gevt = evt.copyFor(model_root, scroll_body);
                doWheelZoom(evt.getDeltaY(), gevt.getX(), gevt.getY());
            }
        });
    return model_root;
}
Also used : Line(javafx.scene.shape.Line) Color(java.awt.Color) PredefinedColorMaps(org.csstudio.display.builder.model.properties.PredefinedColorMaps) GaugeWidget(org.csstudio.display.builder.model.widgets.GaugeWidget) PictureWidget(org.csstudio.display.builder.model.widgets.PictureWidget) RegistryFactory(org.eclipse.core.runtime.RegistryFactory) EllipseWidget(org.csstudio.display.builder.model.widgets.EllipseWidget) TextEntryRepresentation(org.csstudio.display.builder.representation.javafx.widgets.TextEntryRepresentation) TextUpdateWidget(org.csstudio.display.builder.model.widgets.TextUpdateWidget) ScrollBarRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ScrollBarRepresentation) Line(javafx.scene.shape.Line) Future(java.util.concurrent.Future) TankWidget(org.csstudio.display.builder.model.widgets.TankWidget) XYPlotWidget(org.csstudio.display.builder.model.widgets.plots.XYPlotWidget) ScrollPane(javafx.scene.control.ScrollPane) XYPlotRepresentation(org.csstudio.display.builder.representation.javafx.widgets.plots.XYPlotRepresentation) Map(java.util.Map) MultiStateLEDWidget(org.csstudio.display.builder.model.widgets.MultiStateLEDWidget) Point2D(javafx.geometry.Point2D) WidgetRepresentation(org.csstudio.display.builder.representation.WidgetRepresentation) Transform(javafx.scene.transform.Transform) ThermometerWidget(org.csstudio.display.builder.model.widgets.ThermometerWidget) NamedColorMappings(org.csstudio.javafx.rtplot.NamedColorMappings) LinearMeterWidget(org.csstudio.display.builder.model.widgets.LinearMeterWidget) PolygonWidget(org.csstudio.display.builder.model.widgets.PolygonWidget) TabsWidget(org.csstudio.display.builder.model.widgets.TabsWidget) ScaledSliderRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ScaledSliderRepresentation) BoolButtonWidget(org.csstudio.display.builder.model.widgets.BoolButtonWidget) ArcRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ArcRepresentation) Group(javafx.scene.Group) Platform(javafx.application.Platform) CountDownLatch(java.util.concurrent.CountDownLatch) LEDRepresentation(org.csstudio.display.builder.representation.javafx.widgets.LEDRepresentation) RadioRepresentation(org.csstudio.display.builder.representation.javafx.widgets.RadioRepresentation) TabsRepresentation(org.csstudio.display.builder.representation.javafx.widgets.TabsRepresentation) ColorMappingFunction(org.csstudio.javafx.rtplot.ColorMappingFunction) BasicStroke(java.awt.BasicStroke) ObservableList(javafx.collections.ObservableList) CheckBoxWidget(org.csstudio.display.builder.model.widgets.CheckBoxWidget) TableWidget(org.csstudio.display.builder.model.widgets.TableWidget) Bounds(javafx.geometry.Bounds) ClockRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ClockRepresentation) ArcWidget(org.csstudio.display.builder.model.widgets.ArcWidget) JFXBaseRepresentation(org.csstudio.display.builder.representation.javafx.widgets.JFXBaseRepresentation) EmbeddedDisplayRepresentation(org.csstudio.display.builder.representation.javafx.widgets.EmbeddedDisplayRepresentation) KnobWidget(org.csstudio.display.builder.model.widgets.KnobWidget) GroupRepresentation(org.csstudio.display.builder.representation.javafx.widgets.GroupRepresentation) ThumbWheelWidget(org.csstudio.display.builder.model.widgets.ThumbWheelWidget) ImageWidget(org.csstudio.display.builder.model.widgets.plots.ImageWidget) TextSymbolWidget(org.csstudio.display.builder.model.widgets.TextSymbolWidget) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) RectangleRepresentation(org.csstudio.display.builder.representation.javafx.widgets.RectangleRepresentation) LabelWidget(org.csstudio.display.builder.model.widgets.LabelWidget) TextEntryWidget(org.csstudio.display.builder.model.widgets.TextEntryWidget) EllipseRepresentation(org.csstudio.display.builder.representation.javafx.widgets.EllipseRepresentation) MeterWidget(org.csstudio.display.builder.model.widgets.MeterWidget) Node(javafx.scene.Node) ImagePattern(javafx.scene.paint.ImagePattern) TableRepresentation(org.csstudio.display.builder.representation.javafx.widgets.TableRepresentation) Background(javafx.scene.layout.Background) File(java.io.File) ImageRepresentation(org.csstudio.display.builder.representation.javafx.widgets.plots.ImageRepresentation) ExecutionException(java.util.concurrent.ExecutionException) ArrayWidget(org.csstudio.display.builder.model.widgets.ArrayWidget) Cursor(javafx.scene.Cursor) FileChooser(javafx.stage.FileChooser) ComboWidget(org.csstudio.display.builder.model.widgets.ComboWidget) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) GaugeRepresentation(org.csstudio.display.builder.representation.javafx.widgets.GaugeRepresentation) Widget(org.csstudio.display.builder.model.Widget) NamedColorMapping(org.csstudio.javafx.rtplot.NamedColorMapping) EventHandler(javafx.event.EventHandler) ToolkitRepresentation(org.csstudio.display.builder.representation.ToolkitRepresentation) ComboRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ComboRepresentation) LinearMeterRepresentation(org.csstudio.display.builder.representation.javafx.widgets.LinearMeterRepresentation) WebBrowserRepresentation(org.csstudio.display.builder.representation.javafx.widgets.WebBrowserRepresentation) TimeoutException(java.util.concurrent.TimeoutException) RenderingHints(java.awt.RenderingHints) ChoiceDialog(javafx.scene.control.ChoiceDialog) ClockWidget(org.csstudio.display.builder.model.widgets.ClockWidget) ProgressBarWidget(org.csstudio.display.builder.model.widgets.ProgressBarWidget) InvalidationListener(javafx.beans.InvalidationListener) PictureRepresentation(org.csstudio.display.builder.representation.javafx.widgets.PictureRepresentation) Parent(javafx.scene.Parent) RectangleWidget(org.csstudio.display.builder.model.widgets.RectangleWidget) IExtensionRegistry(org.eclipse.core.runtime.IExtensionRegistry) ActionButtonRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ActionButtonRepresentation) SpinnerRepresentation(org.csstudio.display.builder.representation.javafx.widgets.SpinnerRepresentation) WidgetRepresentationFactory(org.csstudio.display.builder.representation.WidgetRepresentationFactory) Status(javafx.scene.media.MediaPlayer.Status) Pane(javafx.scene.layout.Pane) Alert(javafx.scene.control.Alert) MeterRepresentation(org.csstudio.display.builder.representation.javafx.widgets.MeterRepresentation) BufferedImage(java.awt.image.BufferedImage) ArrayRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ArrayRepresentation) PolylineWidget(org.csstudio.display.builder.model.widgets.PolylineWidget) ThermometerRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ThermometerRepresentation) List(java.util.List) ByteMonitorWidget(org.csstudio.display.builder.model.widgets.ByteMonitorWidget) RadioWidget(org.csstudio.display.builder.model.widgets.RadioWidget) LabelRepresentation(org.csstudio.display.builder.representation.javafx.widgets.LabelRepresentation) GroupWidget(org.csstudio.display.builder.model.widgets.GroupWidget) Scale(javafx.scene.transform.Scale) Optional(java.util.Optional) ThumbWheelRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ThumbWheelRepresentation) Media(javafx.scene.media.Media) NavigationTabsWidget(org.csstudio.display.builder.model.widgets.NavigationTabsWidget) ProgressBarRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ProgressBarRepresentation) NavigationTabsRepresentation(org.csstudio.display.builder.representation.javafx.widgets.NavigationTabsRepresentation) CornerRadii(javafx.scene.layout.CornerRadii) Scene(javafx.scene.Scene) DisplayModel(org.csstudio.display.builder.model.DisplayModel) LEDWidget(org.csstudio.display.builder.model.widgets.LEDWidget) ButtonType(javafx.scene.control.ButtonType) MouseEvent(javafx.scene.input.MouseEvent) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) Level(java.util.logging.Level) Insets(javafx.geometry.Insets) Graphics2D(java.awt.Graphics2D) ScrollBarWidget(org.csstudio.display.builder.model.widgets.ScrollBarWidget) WidgetColor(org.csstudio.display.builder.model.properties.WidgetColor) TextUpdateRepresentation(org.csstudio.display.builder.representation.javafx.widgets.TextUpdateRepresentation) BackgroundFill(javafx.scene.layout.BackgroundFill) TankRepresentation(org.csstudio.display.builder.representation.javafx.widgets.TankRepresentation) DigitalClockRepresentation(org.csstudio.display.builder.representation.javafx.widgets.DigitalClockRepresentation) WebBrowserWidget(org.csstudio.display.builder.model.widgets.WebBrowserWidget) DigitalClockWidget(org.csstudio.display.builder.model.widgets.DigitalClockWidget) TextSymbolRepresentation(org.csstudio.display.builder.representation.javafx.widgets.TextSymbolRepresentation) MediaPlayer(javafx.scene.media.MediaPlayer) ByteMonitorRepresentation(org.csstudio.display.builder.representation.javafx.widgets.ByteMonitorRepresentation) PolylineRepresentation(org.csstudio.display.builder.representation.javafx.widgets.PolylineRepresentation) ObjectProperty(javafx.beans.property.ObjectProperty) CheckBoxRepresentation(org.csstudio.display.builder.representation.javafx.widgets.CheckBoxRepresentation) SymbolRepresentation(org.csstudio.display.builder.representation.javafx.widgets.SymbolRepresentation) WritableImage(javafx.scene.image.WritableImage) EmbeddedDisplayWidget(org.csstudio.display.builder.model.widgets.EmbeddedDisplayWidget) SpinnerWidget(org.csstudio.display.builder.model.widgets.SpinnerWidget) SymbolWidget(org.csstudio.display.builder.model.widgets.SymbolWidget) ScrollEvent(javafx.scene.input.ScrollEvent) Styles(org.csstudio.javafx.Styles) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) ScaledSliderWidget(org.csstudio.display.builder.model.widgets.ScaledSliderWidget) BoolButtonRepresentation(org.csstudio.display.builder.representation.javafx.widgets.BoolButtonRepresentation) PolygonRepresentation(org.csstudio.display.builder.representation.javafx.widgets.PolygonRepresentation) ActionButtonWidget(org.csstudio.display.builder.model.widgets.ActionButtonWidget) KnobRepresentation(org.csstudio.display.builder.representation.javafx.widgets.KnobRepresentation) UntypedWidgetPropertyListener(org.csstudio.display.builder.model.UntypedWidgetPropertyListener) WidgetPropertyListener(org.csstudio.display.builder.model.WidgetPropertyListener) SwingFXUtils(javafx.embed.swing.SwingFXUtils) Window(javafx.stage.Window) DialogHelper(org.csstudio.javafx.DialogHelper) MultiStateLEDRepresentation(org.csstudio.display.builder.representation.javafx.widgets.MultiStateLEDRepresentation) Group(javafx.scene.Group) MouseEvent(javafx.scene.input.MouseEvent) Point2D(javafx.geometry.Point2D) ScrollEvent(javafx.scene.input.ScrollEvent) ScrollPane(javafx.scene.control.ScrollPane) InvalidationListener(javafx.beans.InvalidationListener) ScrollPane(javafx.scene.control.ScrollPane) Pane(javafx.scene.layout.Pane)

Example 18 with InvalidationListener

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

the class ZoomPan method createScene.

public static Scene createScene() {
    // Stuff to show as 'widgets'
    final Node[] stuff = new Node[3];
    for (int i = 0; i < stuff.length; ++i) {
        final Rectangle rect = new Rectangle(50 + i * 100, 100, 10 + i * 50, 20 + i * 40);
        rect.setFill(Color.BLUE);
        stuff[i] = rect;
    }
    // With 'Group', stuff would start in top-left (0, 0) corner,
    // not at (50, 100) based on its coordinates
    final Pane widgets = new Pane(stuff);
    widgets.setStyle("-fx-background-color: coral;");
    final ScrollPane scroll;
    if (true) {
        // Additional Group to help ScrollPane get correct bounds
        final Group scroll_content = new Group(widgets);
        scroll = new ScrollPane(scroll_content);
    } else
        scroll = new ScrollPane(widgets);
    final InvalidationListener resized = prop -> handleViewportChanges(scroll);
    scroll.widthProperty().addListener(resized);
    scroll.heightProperty().addListener(resized);
    System.out.println("Press 'space' to change zoom");
    final Scene scene = new Scene(scroll);
    scene.addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent event) -> {
        if (event.getCode() == KeyCode.SPACE) {
            zoom_in = !zoom_in;
            if (zoom_in)
                widgets.getTransforms().setAll(new Scale(2.5, 2.5));
            else
                widgets.getTransforms().setAll(new Scale(0.5, 0.5));
        }
    });
    return scene;
}
Also used : Scene(javafx.scene.Scene) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Node(javafx.scene.Node) Rectangle(javafx.scene.shape.Rectangle) KeyEvent(javafx.scene.input.KeyEvent) Group(javafx.scene.Group) InvalidationListener(javafx.beans.InvalidationListener) Application(javafx.application.Application) ScrollPane(javafx.scene.control.ScrollPane) Stage(javafx.stage.Stage) Scale(javafx.scene.transform.Scale) Pane(javafx.scene.layout.Pane) KeyEvent(javafx.scene.input.KeyEvent) Group(javafx.scene.Group) ScrollPane(javafx.scene.control.ScrollPane) Node(javafx.scene.Node) Rectangle(javafx.scene.shape.Rectangle) InvalidationListener(javafx.beans.InvalidationListener) Scale(javafx.scene.transform.Scale) Scene(javafx.scene.Scene) ScrollPane(javafx.scene.control.ScrollPane) Pane(javafx.scene.layout.Pane)

Example 19 with InvalidationListener

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

the class MacrosTable method fixup.

/**
 * Fix table: Delete empty rows in middle, but keep one empty final row
 *  @param changed_row Row to check, and remove if it's empty
 */
private void fixup(final int changed_row) {
    // Check if edited row is now empty and should be deleted
    if (changed_row < data.size()) {
        final MacroItem item = data.get(changed_row);
        final String name = item.getName().trim();
        final String value = item.getValue().trim();
        if (name.isEmpty() && value.isEmpty())
            data.remove(changed_row);
    }
    // Assert one empty row at bottom
    final int len = data.size();
    if (len <= 0 || (data.get(len - 1).getName().trim().length() > 0 && data.get(len - 1).getValue().trim().length() > 0))
        data.add(new MacroItem("", ""));
    for (InvalidationListener listener : listeners) listener.invalidated(data);
}
Also used : InvalidationListener(javafx.beans.InvalidationListener)

Example 20 with InvalidationListener

use of javafx.beans.InvalidationListener in project POL-POM-5 by PhoenicisOrg.

the class ApplicationPanel 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) 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) JavaFxSettingsManager(org.phoenicis.javafx.settings.JavaFxSettingsManager) DetailsView(org.phoenicis.javafx.views.common.widgets.lists.DetailsView) PhoenicisFilteredList(org.phoenicis.javafx.views.common.lists.PhoenicisFilteredList) 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)

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