Search in sources :

Example 1 with CreateGroupAction

use of org.csstudio.display.builder.editor.rcp.actions.CreateGroupAction in project org.csstudio.display.builder by kasemir.

the class DisplayEditorPart method createContextMenu.

private Menu createContextMenu(final Control parent) {
    final MenuManager mm = new MenuManager();
    final Action execute = new ExecuteDisplayAction(this);
    final MenuManager morph = new MorphWidgetMenuSupport(editor).getMenuManager();
    final ImageDescriptor icon = AbstractUIPlugin.imageDescriptorFromPlugin(ModelPlugin.ID, "icons/display.png");
    final Action perspective = new OpenPerspectiveAction(icon, Messages.OpenEditorPerspective, EditorPerspective.ID);
    final Action reload = new ReloadDisplayAction(this);
    mm.setRemoveAllWhenShown(true);
    mm.addMenuListener(manager -> {
        manager.add(execute);
        final List<Widget> selection = editor.getWidgetSelectionHandler().getSelection();
        if (!selection.isEmpty()) {
            if (selection.size() >= 1)
                manager.add(new CreateGroupAction(editor, selection));
            if (selection.size() == 1 && selection.get(0) instanceof GroupWidget)
                manager.add(new RemoveGroupAction(editor, (GroupWidget) selection.get(0)));
            if (selection.size() == 1 && selection.get(0) instanceof EmbeddedDisplayWidget)
                manager.add(new EditEmbeddedDisplayAction((EmbeddedDisplayWidget) selection.get(0)));
            manager.add(morph);
        }
        manager.add(reload);
        final DisplayModel model = editor.getModel();
        if (model != null && !model.isClassModel()) {
            manager.add(new ReloadClassesAction(this));
            if (selection.isEmpty())
                manager.add(new SetDisplaySize(editor));
        }
        manager.add(perspective);
    });
    return mm.createContextMenu(parent);
}
Also used : OpenPerspectiveAction(org.csstudio.ui.util.perspective.OpenPerspectiveAction) IAction(org.eclipse.jface.action.IAction) RedoAction(org.csstudio.display.builder.editor.rcp.actions.RedoAction) CutDeleteAction(org.csstudio.display.builder.editor.rcp.actions.CutDeleteAction) PasteAction(org.csstudio.display.builder.editor.rcp.actions.PasteAction) OpenPerspectiveAction(org.csstudio.ui.util.perspective.OpenPerspectiveAction) ReloadDisplayAction(org.csstudio.display.builder.editor.rcp.actions.ReloadDisplayAction) RemoveGroupAction(org.csstudio.display.builder.editor.rcp.actions.RemoveGroupAction) ExecuteDisplayAction(org.csstudio.display.builder.editor.rcp.actions.ExecuteDisplayAction) CreateGroupAction(org.csstudio.display.builder.editor.rcp.actions.CreateGroupAction) SelectAllAction(org.csstudio.display.builder.editor.rcp.actions.SelectAllAction) CopyAction(org.csstudio.display.builder.editor.rcp.actions.CopyAction) Action(org.eclipse.jface.action.Action) ReloadClassesAction(org.csstudio.display.builder.editor.rcp.actions.ReloadClassesAction) UndoAction(org.csstudio.display.builder.editor.rcp.actions.UndoAction) CreateGroupAction(org.csstudio.display.builder.editor.rcp.actions.CreateGroupAction) GroupWidget(org.csstudio.display.builder.model.widgets.GroupWidget) EmbeddedDisplayWidget(org.csstudio.display.builder.model.widgets.EmbeddedDisplayWidget) Widget(org.csstudio.display.builder.model.Widget) ReloadClassesAction(org.csstudio.display.builder.editor.rcp.actions.ReloadClassesAction) ReloadDisplayAction(org.csstudio.display.builder.editor.rcp.actions.ReloadDisplayAction) ExecuteDisplayAction(org.csstudio.display.builder.editor.rcp.actions.ExecuteDisplayAction) DisplayModel(org.csstudio.display.builder.model.DisplayModel) EmbeddedDisplayWidget(org.csstudio.display.builder.model.widgets.EmbeddedDisplayWidget) MenuManager(org.eclipse.jface.action.MenuManager) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) RemoveGroupAction(org.csstudio.display.builder.editor.rcp.actions.RemoveGroupAction) GroupWidget(org.csstudio.display.builder.model.widgets.GroupWidget)

Aggregations

CopyAction (org.csstudio.display.builder.editor.rcp.actions.CopyAction)1 CreateGroupAction (org.csstudio.display.builder.editor.rcp.actions.CreateGroupAction)1 CutDeleteAction (org.csstudio.display.builder.editor.rcp.actions.CutDeleteAction)1 ExecuteDisplayAction (org.csstudio.display.builder.editor.rcp.actions.ExecuteDisplayAction)1 PasteAction (org.csstudio.display.builder.editor.rcp.actions.PasteAction)1 RedoAction (org.csstudio.display.builder.editor.rcp.actions.RedoAction)1 ReloadClassesAction (org.csstudio.display.builder.editor.rcp.actions.ReloadClassesAction)1 ReloadDisplayAction (org.csstudio.display.builder.editor.rcp.actions.ReloadDisplayAction)1 RemoveGroupAction (org.csstudio.display.builder.editor.rcp.actions.RemoveGroupAction)1 SelectAllAction (org.csstudio.display.builder.editor.rcp.actions.SelectAllAction)1 UndoAction (org.csstudio.display.builder.editor.rcp.actions.UndoAction)1 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 GroupWidget (org.csstudio.display.builder.model.widgets.GroupWidget)1 OpenPerspectiveAction (org.csstudio.ui.util.perspective.OpenPerspectiveAction)1 Action (org.eclipse.jface.action.Action)1 IAction (org.eclipse.jface.action.IAction)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)1