Search in sources :

Example 56 with DisplayModel

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

the class DisplayEditorPart method loadWidgetClasses.

/**
 * Re-load widget classes and apply to model
 */
public void loadWidgetClasses() {
    // Trigger re-load of classes
    org.csstudio.display.builder.rcp.Plugin.reloadConfigurationFiles();
    // On separate thread..
    ModelThreadPool.getExecutor().execute(() -> {
        // get widget classes and apply to model
        final DisplayModel model = editor.getModel();
        if (model != null)
            WidgetClassesService.getWidgetClasses().apply(model);
    });
}
Also used : DisplayModel(org.csstudio.display.builder.model.DisplayModel)

Example 57 with DisplayModel

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

the class DisplayEditorPart method doLoadModel.

private DisplayModel doLoadModel(final IFile file) {
    try {
        final String ws_location = file.getFullPath().toOSString();
        final DisplayModel new_model = ModelLoader.loadModel(ws_location);
        modification_marker = file.getModificationStamp();
        return new_model;
    } catch (Exception ex) {
        final String message = "Cannot load display " + file;
        logger.log(Level.WARNING, message, ex);
        final Shell shell = getSite().getShell();
        // Also show error to user
        shell.getDisplay().asyncExec(() -> ExceptionDetailsErrorDialog.openError(shell, message, ex));
        return null;
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) DisplayModel(org.csstudio.display.builder.model.DisplayModel) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException)

Example 58 with DisplayModel

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

the class OpenDisplayInEditor method execute.

@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final RuntimeViewPart view = RuntimeViewPart.getActiveDisplay();
    if (view != null) {
        try {
            final Widget widget = view.getActiveWidget();
            final DisplayModel model = widget.getDisplayModel();
            final String path;
            // Options:
            if (widget instanceof EmbeddedDisplayWidget) {
                // c) Widget is an embedded widget.
                // -> User probably wanted to edit the _body_ of that embedded widget
                final EmbeddedDisplayWidget embedded = (EmbeddedDisplayWidget) widget;
                path = ModelResourceUtil.resolveResource(model, embedded.propFile().getValue());
            } else {
                // b) Widget is one of the widgets in the body of an embedded widget:
                // -> Get the body display, _not_ the top-level display
                // a) Widget is in the top-level display, or the display itself:
                // -> Use that that
                path = model.getUserData(DisplayModel.USER_DATA_INPUT_FILE);
            }
            try {
                open(path);
            } catch (Exception ex) {
                logger.log(Level.WARNING, "Cannot open in editor: " + path, ex);
            }
        } catch (Exception ex) {
            logger.log(Level.WARNING, "Cannot open display in editor", ex);
        }
    }
    return null;
}
Also used : RuntimeViewPart(org.csstudio.display.builder.rcp.RuntimeViewPart) DisplayModel(org.csstudio.display.builder.model.DisplayModel) EmbeddedDisplayWidget(org.csstudio.display.builder.model.widgets.EmbeddedDisplayWidget) EmbeddedDisplayWidget(org.csstudio.display.builder.model.widgets.EmbeddedDisplayWidget) Widget(org.csstudio.display.builder.model.Widget) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 59 with DisplayModel

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

the class SetDisplaySize method run.

@Override
public void run() {
    final DisplayModel model = editor.getModel();
    final Rectangle2D bounds = GeometryTools.getBounds(model.getChildren());
    final CompoundUndoableAction resize = new CompoundUndoableAction(getText());
    resize.add(new SetWidgetPropertyAction<Integer>(model.propWidth(), (int) (2 * bounds.getMinX() + bounds.getWidth())));
    resize.add(new SetWidgetPropertyAction<Integer>(model.propHeight(), (int) (2 * bounds.getMinY() + bounds.getHeight())));
    editor.getUndoableActionManager().execute(resize);
}
Also used : DisplayModel(org.csstudio.display.builder.model.DisplayModel) CompoundUndoableAction(org.csstudio.display.builder.util.undo.CompoundUndoableAction) Rectangle2D(javafx.geometry.Rectangle2D)

Example 60 with DisplayModel

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

the class PropertyPanel method updatePropertiesView.

private void updatePropertiesView(final Set<WidgetProperty<?>> properties, final List<Widget> other) {
    final String search = searchField.getText().trim();
    final Set<WidgetProperty<?>> filtered;
    if (search.trim().isEmpty())
        filtered = properties;
    else {
        // Filter properties, but preserve order (LinkedHashSet)
        filtered = new LinkedHashSet<>();
        for (WidgetProperty<?> prop : properties) if (prop.getDescription().toLowerCase().contains(search.toLowerCase()))
            filtered.add(prop);
    }
    final DisplayModel model = editor.getModel();
    section.clear();
    section.setClassMode(model != null && model.isClassModel());
    section.fill(editor.getUndoableActionManager(), filtered, other);
}
Also used : WidgetProperty(org.csstudio.display.builder.model.WidgetProperty) 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