use of org.csstudio.display.builder.rcp.run.ContextMenuSupport in project org.csstudio.display.builder by kasemir.
the class RuntimeViewPart method createPartControl.
@Override
public void createPartControl(final Composite parent) {
RCPHacks.hideUnrelatedUI(getSite().getPage());
parent.setLayout(new FillLayout());
// This calls createFxScene()
super.createPartControl(parent);
// The child added last should be the new FXCanvas
final Control[] children = parent.getChildren();
final Control fx_canvas = children[children.length - 1];
if (!fx_canvas.getClass().getName().contains("FXCanvas"))
throw new IllegalStateException("Expected FXCanvas, got " + fx_canvas);
JFXCursorFix.apply(scene, parent.getDisplay());
createToolbarItems();
new ContextMenuSupport(this, fx_canvas, representation);
parent.addDisposeListener(e -> onDispose());
// Load persisted DisplayInfo?
if (display_info.isPresent()) {
loadDisplayFile(display_info.get());
// This view was restored by Eclipse after a restart.
// It's not opened from an action,
// so nobody else will hook the runtime listener:
RuntimeUtil.hookRepresentationListener(representation);
}
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, "org.csstudio.display.builder.editor.rcp.display_builder");
// Representation for each widget adds a context menu just for the widget.
// Add context menu to scene, tied to the model.
scene.setOnContextMenuRequested(event -> {
final DisplayModel model = active_model;
if (model != null) {
event.consume();
representation.fireContextMenu(model);
}
});
// Track when view is hidden/restored
// Only add once, so remove previous one
getSite().getPage().removePartListener(show_hide_listener);
getSite().getPage().addPartListener(show_hide_listener);
}
Aggregations