Search in sources :

Example 1 with DistributeType

use of org.csstudio.opibuilder.actions.DistributeWidgetsAction.DistributeType in project yamcs-studio by yamcs.

the class OPIEditor method createActions.

@SuppressWarnings("unchecked")
@Override
protected void createActions() {
    super.createActions();
    ((IContextService) getEditorSite().getService(IContextService.class)).activateContext(// $NON-NLS-1$
    "org.csstudio.opibuilder.opiEditor");
    ActionRegistry registry = getActionRegistry();
    IAction action;
    action = new CopyTemplateAction(this);
    registry.registerAction(action);
    action = new MatchWidthAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new MatchHeightAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new DirectEditAction((IWorkbenchPart) this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    String id = ActionFactory.DELETE.getId();
    action = getActionRegistry().getAction(id);
    // $NON-NLS-1$
    action.setActionDefinitionId("org.eclipse.ui.edit.delete");
    action = new PasteWidgetsAction(this);
    registry.registerAction(action);
    action = new CopyWidgetsAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new CutWidgetsAction(this, (DeleteAction) registry.getAction(ActionFactory.DELETE.getId()));
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new PrintDisplayAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    id = ActionFactory.SELECT_ALL.getId();
    action = getActionRegistry().getAction(id);
    // $NON-NLS-1$
    action.setActionDefinitionId("org.eclipse.ui.edit.selectAll");
    id = ActionFactory.UNDO.getId();
    action = getActionRegistry().getAction(id);
    // $NON-NLS-1$
    action.setActionDefinitionId("org.eclipse.ui.edit.undo");
    id = ActionFactory.REDO.getId();
    action = getActionRegistry().getAction(id);
    // $NON-NLS-1$
    action.setActionDefinitionId("org.eclipse.ui.edit.redo");
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.LEFT);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.RIGHT);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.TOP);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.BOTTOM);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.CENTER);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new AlignmentAction((IWorkbenchPart) this, PositionConstants.MIDDLE);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    for (DistributeType dt : DistributeType.values()) {
        action = new DistributeWidgetsAction((IWorkbenchPart) this, dt);
        registry.registerAction(action);
        getSelectionActions().add(action.getId());
    }
    for (OrderType orderType : OrderType.values()) {
        action = new ChangeOrderAction((IWorkbenchPart) this, orderType);
        registry.registerAction(action);
        getSelectionActions().add(action.getId());
    }
    for (OrientationType orientationType : OrientationType.values()) {
        action = new ChangeOrientationAction(this, orientationType);
        registry.registerAction(action);
        getSelectionActions().add(action.getId());
    }
    action = new RunOPIAction();
    registry.registerAction(action);
    PastePropertiesAction pastePropAction = new PastePropertiesAction(this);
    registry.registerAction(pastePropAction);
    getSelectionActions().add(pastePropAction.getId());
    action = new CopyPropertiesAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    action = new ReplaceWidgetsAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
}
Also used : CutWidgetsAction(org.csstudio.opibuilder.actions.CutWidgetsAction) CopyPropertiesAction(org.csstudio.opibuilder.actions.CopyPropertiesAction) MatchHeightAction(org.eclipse.gef.ui.actions.MatchHeightAction) ActionRegistry(org.eclipse.gef.ui.actions.ActionRegistry) ChangeOrientationAction(org.csstudio.opibuilder.actions.ChangeOrientationAction) OrderType(org.csstudio.opibuilder.actions.ChangeOrderAction.OrderType) OrientationType(org.csstudio.opibuilder.actions.ChangeOrientationAction.OrientationType) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DirectEditAction(org.eclipse.gef.ui.actions.DirectEditAction) IContextService(org.eclipse.ui.contexts.IContextService) ChangeOrderAction(org.csstudio.opibuilder.actions.ChangeOrderAction) RunOPIAction(org.csstudio.opibuilder.actions.RunOPIAction) IAction(org.eclipse.jface.action.IAction) RunOPIAction(org.csstudio.opibuilder.actions.RunOPIAction) PasteWidgetsAction(org.csstudio.opibuilder.actions.PasteWidgetsAction) CopyTemplateAction(org.eclipse.gef.ui.actions.CopyTemplateAction) MatchWidthAction(org.eclipse.gef.ui.actions.MatchWidthAction) CopyWidgetsAction(org.csstudio.opibuilder.actions.CopyWidgetsAction) AlignmentAction(org.eclipse.gef.ui.actions.AlignmentAction) DistributeType(org.csstudio.opibuilder.actions.DistributeWidgetsAction.DistributeType) ReplaceWidgetsAction(org.csstudio.opibuilder.actions.ReplaceWidgetsAction) DistributeWidgetsAction(org.csstudio.opibuilder.actions.DistributeWidgetsAction) PastePropertiesAction(org.csstudio.opibuilder.actions.PastePropertiesAction) DeleteAction(org.eclipse.gef.ui.actions.DeleteAction) PrintDisplayAction(org.csstudio.opibuilder.actions.PrintDisplayAction)

Example 2 with DistributeType

use of org.csstudio.opibuilder.actions.DistributeWidgetsAction.DistributeType in project yamcs-studio by yamcs.

the class OPIEditorActionBarContributor method buildActions.

@Override
protected void buildActions() {
    addRetargetAction(new UndoRetargetAction());
    addRetargetAction(new RedoRetargetAction());
    addRetargetAction(new DeleteRetargetAction());
    addRetargetAction(new ZoomInRetargetAction());
    addRetargetAction(new ZoomOutRetargetAction());
    addRetargetAction(new MatchWidthRetargetAction());
    addRetargetAction(new MatchHeightRetargetAction());
    addRetargetAction(new AlignmentRetargetAction(PositionConstants.TOP));
    addRetargetAction(new AlignmentRetargetAction(PositionConstants.MIDDLE));
    addRetargetAction(new AlignmentRetargetAction(PositionConstants.BOTTOM));
    addRetargetAction(new AlignmentRetargetAction(PositionConstants.LEFT));
    addRetargetAction(new AlignmentRetargetAction(PositionConstants.CENTER));
    addRetargetAction(new AlignmentRetargetAction(PositionConstants.RIGHT));
    RetargetAction a = new RetargetAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY, "Toggle Grid Visibility", IAction.AS_CHECK_BOX);
    a.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, // $NON-NLS-1$
    "icons/grid.png"));
    addRetargetAction(a);
    a = new RetargetAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY, "Toggle Snap To Geometry", IAction.AS_CHECK_BOX);
    a.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, "icons/snap2geometry.png"));
    addRetargetAction(a);
    a = new RetargetAction(GEFActionConstants.TOGGLE_RULER_VISIBILITY, "Toggle Ruler Visibility", IAction.AS_CHECK_BOX);
    a.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(OPIBuilderPlugin.PLUGIN_ID, "icons/ruler.png"));
    addRetargetAction(a);
    for (DistributeType dt : DistributeType.values()) {
        if (dt != DistributeType.HORIZONTAL_GAP) {
            a = new RetargetAction(dt.getActionID(), dt.getLabel());
            a.setImageDescriptor(dt.getImageDescriptor());
            addRetargetAction(a);
        }
    }
    // This is only for action displaying in toolbar
    a = new RetargetAction(DistributeType.HORIZONTAL_GAP.getActionID(), DistributeType.HORIZONTAL_GAP.getLabel(), IAction.AS_DROP_DOWN_MENU);
    a.setImageDescriptor(DistributeType.HORIZONTAL_GAP.getImageDescriptor());
    a.setMenuCreator(new IMenuCreator() {

        Menu menu;

        @Override
        public Menu getMenu(Menu parent) {
            return null;
        }

        @Override
        public Menu getMenu(Control parent) {
            if (menu != null)
                return menu;
            MenuManager manager = new MenuManager();
            for (DistributeType dt : DistributeType.values()) {
                if (dt != DistributeType.HORIZONTAL_GAP)
                    manager.add(getAction(dt.getActionID()));
            }
            menu = manager.createContextMenu(parent);
            return menu;
        }

        @Override
        public void dispose() {
            if (menu != null) {
                menu.dispose();
                menu = null;
            }
        }
    });
    addRetargetAction(a);
}
Also used : RedoRetargetAction(org.eclipse.gef.ui.actions.RedoRetargetAction) UndoRetargetAction(org.eclipse.gef.ui.actions.UndoRetargetAction) ZoomOutRetargetAction(org.eclipse.gef.ui.actions.ZoomOutRetargetAction) AlignmentRetargetAction(org.eclipse.gef.ui.actions.AlignmentRetargetAction) MatchHeightRetargetAction(org.eclipse.gef.ui.actions.MatchHeightRetargetAction) ZoomInRetargetAction(org.eclipse.gef.ui.actions.ZoomInRetargetAction) MatchWidthRetargetAction(org.eclipse.gef.ui.actions.MatchWidthRetargetAction) RetargetAction(org.eclipse.ui.actions.RetargetAction) RedoRetargetAction(org.eclipse.gef.ui.actions.RedoRetargetAction) DeleteRetargetAction(org.eclipse.gef.ui.actions.DeleteRetargetAction) IMenuCreator(org.eclipse.jface.action.IMenuCreator) DeleteRetargetAction(org.eclipse.gef.ui.actions.DeleteRetargetAction) MatchWidthRetargetAction(org.eclipse.gef.ui.actions.MatchWidthRetargetAction) ZoomInRetargetAction(org.eclipse.gef.ui.actions.ZoomInRetargetAction) DistributeType(org.csstudio.opibuilder.actions.DistributeWidgetsAction.DistributeType) MatchHeightRetargetAction(org.eclipse.gef.ui.actions.MatchHeightRetargetAction) Control(org.eclipse.swt.widgets.Control) AlignmentRetargetAction(org.eclipse.gef.ui.actions.AlignmentRetargetAction) UndoRetargetAction(org.eclipse.gef.ui.actions.UndoRetargetAction) MenuManager(org.eclipse.jface.action.MenuManager) ZoomOutRetargetAction(org.eclipse.gef.ui.actions.ZoomOutRetargetAction) Menu(org.eclipse.swt.widgets.Menu)

Aggregations

DistributeType (org.csstudio.opibuilder.actions.DistributeWidgetsAction.DistributeType)2 ChangeOrderAction (org.csstudio.opibuilder.actions.ChangeOrderAction)1 OrderType (org.csstudio.opibuilder.actions.ChangeOrderAction.OrderType)1 ChangeOrientationAction (org.csstudio.opibuilder.actions.ChangeOrientationAction)1 OrientationType (org.csstudio.opibuilder.actions.ChangeOrientationAction.OrientationType)1 CopyPropertiesAction (org.csstudio.opibuilder.actions.CopyPropertiesAction)1 CopyWidgetsAction (org.csstudio.opibuilder.actions.CopyWidgetsAction)1 CutWidgetsAction (org.csstudio.opibuilder.actions.CutWidgetsAction)1 DistributeWidgetsAction (org.csstudio.opibuilder.actions.DistributeWidgetsAction)1 PastePropertiesAction (org.csstudio.opibuilder.actions.PastePropertiesAction)1 PasteWidgetsAction (org.csstudio.opibuilder.actions.PasteWidgetsAction)1 PrintDisplayAction (org.csstudio.opibuilder.actions.PrintDisplayAction)1 ReplaceWidgetsAction (org.csstudio.opibuilder.actions.ReplaceWidgetsAction)1 RunOPIAction (org.csstudio.opibuilder.actions.RunOPIAction)1 ActionRegistry (org.eclipse.gef.ui.actions.ActionRegistry)1 AlignmentAction (org.eclipse.gef.ui.actions.AlignmentAction)1 AlignmentRetargetAction (org.eclipse.gef.ui.actions.AlignmentRetargetAction)1 CopyTemplateAction (org.eclipse.gef.ui.actions.CopyTemplateAction)1 DeleteAction (org.eclipse.gef.ui.actions.DeleteAction)1 DeleteRetargetAction (org.eclipse.gef.ui.actions.DeleteRetargetAction)1