Search in sources :

Example 61 with DisplayModel

use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.

the class PropertyPanel method setSelectedWidgets.

/**
 * Populate UI with properties of widgets
 *  @param widgets Widgets to configure
 */
private void setSelectedWidgets(final List<Widget> widgets) {
    final DisplayModel model = editor.getModel();
    searchField.setDisable(widgets.isEmpty() && model == null);
    if (widgets.isEmpty()) {
        // Use the DisplayModel
        if (model != null)
            updatePropertiesView(model.getProperties(), Collections.emptyList());
    } else {
        // Determine common properties
        final List<Widget> other = new ArrayList<>(widgets);
        final Widget primary = other.remove(0);
        final Set<WidgetProperty<?>> properties = commonProperties(primary, other);
        updatePropertiesView(properties, other);
    }
}
Also used : WidgetProperty(org.csstudio.display.builder.model.WidgetProperty) DisplayModel(org.csstudio.display.builder.model.DisplayModel) Widget(org.csstudio.display.builder.model.Widget) ArrayList(java.util.ArrayList)

Example 62 with DisplayModel

use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.

the class FilenameSupport method promptForRelativePath.

/**
 * Prompt for file name
 *  @param widget Widget that needs a file name
 *  @param initial Initial value
 *  @return Selected file name or <code>null</code>
 */
public static String promptForRelativePath(final Widget widget, final String initial) throws Exception {
    final String filename = file_prompt.apply(widget, initial);
    if (filename == null)
        return null;
    final DisplayModel model = widget.getDisplayModel();
    final String parent_file = model.getUserData(DisplayModel.USER_DATA_INPUT_FILE);
    return ModelResourceUtil.getRelativePath(parent_file, filename);
}
Also used : DisplayModel(org.csstudio.display.builder.model.DisplayModel)

Example 63 with DisplayModel

use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.

the class JFXStageRepresentation method handleCloseRequest.

private void handleCloseRequest(final Scene scene, final Consumer<DisplayModel> close_request_handler) {
    final Parent root = getModelParent();
    final DisplayModel model = (DisplayModel) root.getProperties().get(ACTIVE_MODEL);
    try {
        if (model != null)
            close_request_handler.accept(model);
    } catch (final Exception ex) {
        logger.log(Level.WARNING, "Close request handler failed", ex);
    }
    shutdown();
}
Also used : Parent(javafx.scene.Parent) DisplayModel(org.csstudio.display.builder.model.DisplayModel)

Example 64 with DisplayModel

use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.

the class DataBrowserWidget method getExpandedFilename.

public String getExpandedFilename(String base_path) throws Exception {
    // expand macros in the file name
    final String expanded_path = MacroHandler.replace(this.getMacrosOrProperties(), base_path);
    // Resolve new image file relative to the source widget model (not 'top'!)
    // Get the display model from the widget tied to this representation
    final DisplayModel widget_model = this.getDisplayModel();
    // Resolve the path using the parent model file path
    return ModelResourceUtil.resolveResource(widget_model, expanded_path);
}
Also used : DisplayModel(org.csstudio.display.builder.model.DisplayModel)

Example 65 with DisplayModel

use of org.csstudio.display.builder.model.DisplayModel in project org.csstudio.display.builder by kasemir.

the class JFXRepresentation method handleViewportChanges.

/**
 * Handle changes in on-screen size of this representation
 */
private void handleViewportChanges() {
    final int view_width = (int) model_root.getWidth();
    final int view_height = (int) model_root.getHeight();
    final int model_width, model_height;
    final DisplayModel copy = model;
    if (copy == null)
        model_width = model_height = 0;
    else {
        model_width = copy.propWidth().getValue();
        model_height = copy.propHeight().getValue();
    }
    // If on-screen viewport is larger than model,
    // grow the scroll_body so that the complete area is
    // filled with the background color
    // and - in edit mode - the grid.
    // If the viewport is smaller, use the model's size
    // to get appropriate scrollbars.
    final int show_x = view_width >= model_width ? view_width - SCROLLBAR_ADJUST : model_width;
    final int show_y = view_height >= model_height ? view_height - SCROLLBAR_ADJUST : model_height;
    // Does not consider zooming.
    // If the widget_parent is zoomed 'out', e.g. 50%,
    // the widget_parent will only be half as large
    // as we specify here in pixels
    // -> Ignore. If user zooms out a lot, there'll be an
    // area a gray area at the right and bottom of the display.
    // But user tends to zoom out to see the complete set of widgets,
    // so there is very little gray area.
    // widget_parent.setMinWidth(show_x / zoom);
    // widget_parent.setMinHeight(show_y / zoom);
    widget_parent.setMinSize(show_x, show_y);
}
Also used : DisplayModel(org.csstudio.display.builder.model.DisplayModel)

Aggregations

DisplayModel (org.csstudio.display.builder.model.DisplayModel)73 Widget (org.csstudio.display.builder.model.Widget)15 Test (org.junit.Test)10 LabelWidget (org.csstudio.display.builder.model.widgets.LabelWidget)9 GroupWidget (org.csstudio.display.builder.model.widgets.GroupWidget)7 EmbeddedDisplayRepresentationUtil.loadDisplayModel (org.csstudio.display.builder.representation.EmbeddedDisplayRepresentationUtil.loadDisplayModel)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 EmbeddedDisplayWidget (org.csstudio.display.builder.model.widgets.EmbeddedDisplayWidget)5 Image (javafx.scene.image.Image)4 File (java.io.File)3 InputStream (java.io.InputStream)3 Parent (javafx.scene.Parent)3 Macros (org.csstudio.display.builder.model.macros.Macros)3 PictureWidget (org.csstudio.display.builder.model.widgets.PictureWidget)3 FileInputStream (java.io.FileInputStream)2 ArrayList (java.util.ArrayList)2 Rectangle2D (javafx.geometry.Rectangle2D)2 WidgetFactoryUnitTest (org.csstudio.display.builder.model.WidgetFactoryUnitTest)2 WidgetProperty (org.csstudio.display.builder.model.WidgetProperty)2 ModelWriter (org.csstudio.display.builder.model.persist.ModelWriter)2