Example usage for org.eclipse.jface.action IAction setId

List of usage examples for org.eclipse.jface.action IAction setId

Introduction

In this page you can find the example usage for org.eclipse.jface.action IAction setId.

Prototype

void setId(String id);

Source Link

Document

Sets the unique identifier for this action.

Usage

From source file:cn.edu.pku.ogeditor.ShapesEditor.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from   w  ww .  ja  v a 2  s.  co  m
protected void createActions() {
    super.createActions();
    IAction action = new RelocateAction(this);
    action.setId(ActionConstant.RELOCATE_ID);
    getActionRegistry().registerAction(action);
    getSelectionActions().add(action.getId());
    action = new ConceptFilterAction(this);
    action.setId(ActionConstant.CONCEPTFILTER_ID);
    getActionRegistry().registerAction(action);
    getSelectionActions().add(action.getId());
    action = new RelationFilterAction(this);
    action.setId(ActionConstant.RELATIONFILTER_ID);
    getActionRegistry().registerAction(action);
    getSelectionActions().add(action.getId());

    action = new OWLGenerationAction(this);
    action.setId(ActionConstant.OWLGENERATION_ID);
    getActionRegistry().registerAction(action);
    getSelectionActions().add(action.getId());
    action = new SystemGenerationAction(this);
    action.setId(ActionConstant.SYSTEMGENERATION_ID);
    getActionRegistry().registerAction(action);
    getSelectionActions().add(action.getId());

    action = new DeployAction(this);
    action.setId(ActionConstant.DEPLOY_ID);
    getActionRegistry().registerAction(action);
    getSelectionActions().add(action.getId());
    action = new StopDeployAction(this);
    action.setId(ActionConstant.STOP_DEPLOY_ID);
    getActionRegistry().registerAction(action);
    getSelectionActions().add(action.getId());
}

From source file:com.android.ide.eclipse.adt.internal.editors.layout.gle2.DynamicContextMenu.java

License:Open Source License

private IAction createPlainAction(final RuleAction action, final List<INode> nodes, final String defaultId) {
    IAction a = new Action(action.getTitle(), IAction.AS_PUSH_BUTTON) {
        @Override/* www .  j  a v  a  2 s . co m*/
        public void run() {
            String label = createActionLabel(action, nodes);
            mEditorDelegate.getEditor().wrapUndoEditXmlModel(label, new Runnable() {
                @Override
                public void run() {
                    action.getCallback().action(action, nodes, null, Boolean.TRUE);
                    applyPendingChanges();
                }
            });
        }
    };

    String id = action.getId();
    if (defaultId != null && id.equals(defaultId)) {
        a.setAccelerator(DEFAULT_ACTION_KEY);
        String text = a.getText();
        text = text + '\t' + DEFAULT_ACTION_SHORTCUT;
        a.setText(text);

    } else if (ATTR_ID.equals(id)) {
        // Keep in sync with {@link LayoutCanvas#handleKeyPressed}
        if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_DARWIN) {
            a.setAccelerator('R' | SWT.MOD1 | SWT.MOD3);
            // Option+Command
            a.setText(a.getText().trim() + "\t\u2325\u2318R"); //$NON-NLS-1$
        } else if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_LINUX) {
            a.setAccelerator('R' | SWT.MOD2 | SWT.MOD3);
            a.setText(a.getText() + "\tShift+Alt+R"); //$NON-NLS-1$
        } else {
            a.setAccelerator('R' | SWT.MOD2 | SWT.MOD3);
            a.setText(a.getText() + "\tAlt+Shift+R"); //$NON-NLS-1$
        }
    }
    a.setId(id);
    return a;
}

From source file:com.android.ide.eclipse.auidt.internal.editors.layout.gle2.DynamicContextMenu.java

License:Open Source License

private IAction createPlainAction(final RuleAction action, final List<INode> nodes) {
    IAction a = new Action(action.getTitle(), IAction.AS_PUSH_BUTTON) {
        @Override//from ww  w . j a va 2  s  .c  o  m
        public void run() {
            String label = createActionLabel(action, nodes);
            mEditorDelegate.getEditor().wrapUndoEditXmlModel(label, new Runnable() {
                @Override
                public void run() {
                    action.getCallback().action(action, nodes, null, Boolean.TRUE);
                    applyPendingChanges();
                }
            });
        }
    };
    a.setId(action.getId());
    return a;
}

From source file:com.archimatetool.editor.diagram.AbstractDiagramEditor.java

License:Open Source License

/**
 * Add some extra Actions - *after* the graphical viewer has been created
 *//*from  w w w.ja  v  a  2 s  . c o  m*/
@SuppressWarnings("unchecked")
protected void createActions(GraphicalViewer viewer) {
    ActionRegistry registry = getActionRegistry();
    IAction action;

    // Zoom Manager tweaking
    ZoomManager zoomManager = (ZoomManager) getAdapter(ZoomManager.class);
    double[] zoomLevels = { .25, .5, .75, 1, 1.5, 2, 3, 4, 6, 8 };
    zoomManager.setZoomLevels(zoomLevels);
    List<String> zoomContributionLevels = new ArrayList<String>();
    zoomContributionLevels.add(ZoomManager.FIT_ALL);
    zoomContributionLevels.add(ZoomManager.FIT_WIDTH);
    zoomContributionLevels.add(ZoomManager.FIT_HEIGHT);
    zoomManager.setZoomLevelContributions(zoomContributionLevels);

    // Zoom Actions
    IAction zoomIn = new ZoomInAction(zoomManager);
    IAction zoomOut = new ZoomOutAction(zoomManager);
    registry.registerAction(zoomIn);
    registry.registerAction(zoomOut);

    // Add these zoom actions to the key binding service
    IHandlerService service = (IHandlerService) getEditorSite().getService(IHandlerService.class);
    service.activateHandler(zoomIn.getActionDefinitionId(), new ActionHandler(zoomIn));
    service.activateHandler(zoomOut.getActionDefinitionId(), new ActionHandler(zoomOut));

    // Add our own Select All Action so we can select connections as well
    action = new SelectAllAction(this);
    registry.registerAction(action);

    // Add our own Print Action
    action = new PrintDiagramAction(this);
    registry.registerAction(action);

    // Direct Edit Rename
    action = new DirectEditAction(this);
    action.setId(ActionFactory.RENAME.getId()); // Set this for Global Handler
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Change the Delete Action label
    action = registry.getAction(ActionFactory.DELETE.getId());
    action.setText(Messages.AbstractDiagramEditor_2);
    action.setToolTipText(action.getText());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Paste
    PasteAction pasteAction = new PasteAction(this, viewer);
    registry.registerAction(pasteAction);
    getSelectionActions().add(pasteAction.getId());

    // Cut
    action = new CutAction(this, pasteAction);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Copy
    action = new CopyAction(this, pasteAction);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Use Grid Action
    action = new ToggleGridEnabledAction();
    registry.registerAction(action);

    // Show Grid Action
    action = new ToggleGridVisibleAction();
    registry.registerAction(action);

    // Snap to Alignment Guides
    action = new ToggleSnapToAlignmentGuidesAction();
    registry.registerAction(action);

    // Ruler
    //IAction showRulers = new ToggleRulerVisibilityAction(getGraphicalViewer());
    //registry.registerAction(showRulers);

    action = new MatchWidthAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());

    action = new MatchHeightAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());

    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());

    // Default Size
    action = new DefaultEditPartSizeAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Reset Aspect Ratio
    action = new ResetAspectRatioAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Properties
    action = new PropertiesAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());

    // Fill Colour
    action = new FillColorAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Connection Line Width
    action = new ConnectionLineWidthAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Connection Line Color
    action = new LineColorAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Font
    action = new FontAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Font Colour
    action = new FontColorAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Export As Image
    action = new ExportAsImageAction(viewer);
    registry.registerAction(action);

    // Export As Image to Clipboard
    action = new ExportAsImageToClipboardAction(viewer);
    registry.registerAction(action);

    // Connection Router types
    action = new ConnectionRouterAction.BendPointConnectionRouterAction(this);
    registry.registerAction(action);
    action = new ConnectionRouterAction.ShortestPathConnectionRouterAction(this);
    registry.registerAction(action);
    action = new ConnectionRouterAction.ManhattanConnectionRouterAction(this);
    registry.registerAction(action);

    // Send Backward
    action = new SendBackwardAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Bring Forward
    action = new BringForwardAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Send to Back
    action = new SendToBackAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Bring To Front
    action = new BringToFrontAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Text Alignment Actions
    for (TextAlignmentAction a : TextAlignmentAction.createActions(this)) {
        registry.registerAction(a);
        getSelectionActions().add(a.getId());
        getUpdateCommandStackActions().add(a);
    }

    // Text Position Actions
    for (TextPositionAction a : TextPositionAction.createActions(this)) {
        registry.registerAction(a);
        getSelectionActions().add(a.getId());
        getUpdateCommandStackActions().add(a);
    }

    // Lock Object
    action = new LockObjectAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Border Color
    action = new BorderColorAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
    getUpdateCommandStackActions().add((UpdateAction) action);

    // Full Screen
    if (!PlatformUtils.supportsMacFullScreen()) {
        action = new FullScreenAction(this);
        registry.registerAction(action);
    }

    // Select Element in Tree
    action = new SelectElementInTreeAction(this);
    registry.registerAction(action);
    getSelectionActions().add(action.getId());
}

From source file:com.centurylink.mdw.plugin.designer.views.AutomatedTestActionGroup.java

License:Apache License

private IAction createRerunAction() {
    IAction action = new Action() {
        public void run() {
            view.handleRerun();/*ww w .  j  a  va 2  s . c o  m*/
        }
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "rerun.tests");
    action.setText("Rerun Test(s)");
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/rerun.gif");
    action.setImageDescriptor(imageDesc);
    ImageDescriptor disabledImageDesc = MdwPlugin.getImageDescriptor("icons/rerun_disabled.gif");
    action.setDisabledImageDescriptor(disabledImageDesc);
    return action;
}

From source file:com.centurylink.mdw.plugin.designer.views.AutomatedTestActionGroup.java

License:Apache License

private IAction createRerunSelectionAction() {
    IAction action = new Action() {
        public void run() {
            view.handleRerunSelection();
        }/*  w w w  . ja va 2s  .  com*/
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "rerun.selected.tests");
    action.setText("Rerun Test(s)");
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/rerun.gif");
    action.setImageDescriptor(imageDesc);
    return action;
}

From source file:com.centurylink.mdw.plugin.designer.views.AutomatedTestActionGroup.java

License:Apache License

private IAction createStopAction() {
    IAction action = new Action() {
        public void run() {
            view.handleStop();/*from ww w .j a  v  a  2 s  . c o m*/
        }
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "stop.tests");
    action.setText("Stop Test(s)");
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/stop.gif");
    action.setImageDescriptor(imageDesc);
    ImageDescriptor disabledImageDesc = MdwPlugin.getImageDescriptor("icons/stop_disabled.gif");
    action.setDisabledImageDescriptor(disabledImageDesc);
    return action;
}

From source file:com.centurylink.mdw.plugin.designer.views.AutomatedTestActionGroup.java

License:Apache License

private IAction createFormatFunctionTestResultsAction() {
    IAction action = new Action() {
        public void run() {
            actionHandler.formatResults(view.getTestSuite().getProject(), AutomatedTestCase.FUNCTION_TEST);
        }/*from w w  w. ja va 2 s.  c o m*/
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "format.function.test.results");
    action.setText("Format Function Test Results");
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/auto_test.gif");
    action.setImageDescriptor(imageDesc);
    return action;
}

From source file:com.centurylink.mdw.plugin.designer.views.AutomatedTestActionGroup.java

License:Apache License

private IAction createFormatLoadTestResultsAction() {
    IAction action = new Action() {
        public void run() {
            actionHandler.formatResults(view.getTestSuite().getProject(), AutomatedTestCase.LOAD_TEST);
        }// www  .  ja v  a 2 s . co m
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "format.load.test.results");
    action.setText("Format Load Test Results");
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/load_test.gif");
    action.setImageDescriptor(imageDesc);
    return action;
}

From source file:com.centurylink.mdw.plugin.designer.views.AutomatedTestActionGroup.java

License:Apache License

private IAction createOpenTestCaseAction() {
    IAction action = new Action() {
        public void run() {
            if (openTestCaseApplies(view.getSelectedItem()))
                actionHandler.open(view.getSelectedItem());
        }/*from   ww w .j  ava 2  s.com*/
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "open.test.case");
    action.setText("Open Test Case");
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/test.gif");
    action.setImageDescriptor(imageDesc);
    return action;
}