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;
}
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;
}
Aggregations