Search in sources :

Example 1 with RuntimeViewPart

use of org.csstudio.display.builder.rcp.RuntimeViewPart 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 2 with RuntimeViewPart

use of org.csstudio.display.builder.rcp.RuntimeViewPart in project org.csstudio.display.builder by kasemir.

the class RCP_JFXRepresentation method openDisplayOnPage.

private ToolkitRepresentation<Parent, Node> openDisplayOnPage(final IWorkbenchPage page, final DisplayModel model, final Consumer<DisplayModel> close_handler) throws Exception {
    final DisplayInfo info = DisplayInfo.forModel(model);
    final RuntimeViewPart part = RuntimeViewPart.open(page, close_handler, info);
    final RCP_JFXRepresentation new_representation = part.getRepresentation();
    new_representation.representModel(part.getRoot(), model);
    return new_representation;
}
Also used : RuntimeViewPart(org.csstudio.display.builder.rcp.RuntimeViewPart) DisplayInfo(org.csstudio.display.builder.rcp.DisplayInfo)

Aggregations

RuntimeViewPart (org.csstudio.display.builder.rcp.RuntimeViewPart)2 DisplayModel (org.csstudio.display.builder.model.DisplayModel)1 Widget (org.csstudio.display.builder.model.Widget)1 EmbeddedDisplayWidget (org.csstudio.display.builder.model.widgets.EmbeddedDisplayWidget)1 DisplayInfo (org.csstudio.display.builder.rcp.DisplayInfo)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1