Search in sources :

Example 1 with RuntimeAction

use of org.csstudio.display.builder.runtime.RuntimeAction in project org.csstudio.display.builder by kasemir.

the class ContextMenuSupport method fillContextMenu.

private void fillContextMenu(final IMenuManager manager) {
    final Widget context_menu_widget = view.getActiveWidget();
    if (context_menu_widget == null) {
        logger.log(Level.WARNING, "Missing context_menu_widget");
        manager.add(new Action("No widget") {
        });
    } else {
        // Widget info
        manager.add(new WidgetInfoAction(context_menu_widget));
        // Actions of the widget
        for (ActionInfo info : context_menu_widget.propActions().getValue().getActions()) {
            if (info.getType() == ActionType.OPEN_DISPLAY) {
                // Add variant for all the available Target types: Replace, new Tab, ...
                final OpenDisplayActionInfo open_info = (OpenDisplayActionInfo) info;
                for (Target target : Target.values()) {
                    // STANDALONE can be achieved via StandaloneAction on new display
                    if (target == Target.STANDALONE)
                        continue;
                    final String desc = target == Target.REPLACE ? open_info.getDescription() : open_info.getDescription() + " (" + target + ")";
                    manager.add(new ActionInfoWrapper(context_menu_widget, new OpenDisplayActionInfo(desc, open_info.getFile(), open_info.getMacros(), target)));
                }
            } else
                manager.add(new ActionInfoWrapper(context_menu_widget, info));
        }
        // Actions of the widget runtime
        final WidgetRuntime<Widget> runtime = RuntimeUtil.getRuntime(context_menu_widget);
        if (runtime == null)
            throw new NullPointerException("Missing runtime for " + context_menu_widget);
        for (RuntimeAction info : runtime.getRuntimeActions()) manager.add(new RuntimeActionWrapper(context_menu_widget, info));
    }
    // Placeholder for ProcessVariable object contributions
    manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    manager.add(new Separator());
    if (context_menu_widget != null) {
        final Node node = JFXBaseRepresentation.getJFXNode(context_menu_widget);
        final Scene scene = node.getScene();
        manager.add(new SaveSnapshotAction(shell, scene));
        manager.add(new PrintAction(shell, scene));
        manager.add(new SendEMailAction(shell, scene));
        manager.add(new SendLogbookAction(shell, scene));
        manager.add(new FullScreenAction(view.getSite().getPage()));
        if (support_standalone)
            manager.add(new StandaloneAction(view));
    }
    // Placeholder for the display editor.
    // If editor.rcp plugin is included, it adds "Open in editor"
    manager.add(new Separator("display_editor"));
    manager.add(new ReloadDisplayAction());
}
Also used : Action(org.eclipse.jface.action.Action) RuntimeAction(org.csstudio.display.builder.runtime.RuntimeAction) Node(javafx.scene.Node) Widget(org.csstudio.display.builder.model.Widget) ActionInfo(org.csstudio.display.builder.model.properties.ActionInfo) OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo) Scene(javafx.scene.Scene) OpenDisplayActionInfo(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo) Target(org.csstudio.display.builder.model.properties.OpenDisplayActionInfo.Target) GroupMarker(org.eclipse.jface.action.GroupMarker) RuntimeAction(org.csstudio.display.builder.runtime.RuntimeAction) Separator(org.eclipse.jface.action.Separator)

Aggregations

Node (javafx.scene.Node)1 Scene (javafx.scene.Scene)1 Widget (org.csstudio.display.builder.model.Widget)1 ActionInfo (org.csstudio.display.builder.model.properties.ActionInfo)1 OpenDisplayActionInfo (org.csstudio.display.builder.model.properties.OpenDisplayActionInfo)1 Target (org.csstudio.display.builder.model.properties.OpenDisplayActionInfo.Target)1 RuntimeAction (org.csstudio.display.builder.runtime.RuntimeAction)1 Action (org.eclipse.jface.action.Action)1 GroupMarker (org.eclipse.jface.action.GroupMarker)1 Separator (org.eclipse.jface.action.Separator)1