List of usage examples for org.eclipse.jface.action IAction getActionDefinitionId
String getActionDefinitionId();
From source file:ch.elexis.actions.GlobalActions.java
License:Open Source License
/** * Creates an ActionHandler for the given IAction and registers it to the Site's HandlerService, * i. e. binds the action to the command so that key bindings get activated. You need to set the * action's actionDefinitionId to the command id. * /*from ww w. j a va2 s. c o m*/ * @param action * the action to activate. The action's actionDefinitionId must have been set to the * command's id (using <code>setActionDefinitionId()</code>) * @param part * the view this action should be registered for */ public static void registerActionHandler(final ViewPart part, final IAction action) { String commandId = action.getActionDefinitionId(); if (!StringTool.isNothing(commandId)) { IHandlerService handlerService = (IHandlerService) part.getSite().getService(IHandlerService.class); IHandler handler = new ActionHandler(action); handlerService.activateHandler(commandId, handler); } }
From source file:ch.elexis.core.ui.actions.GlobalActions.java
License:Open Source License
/** * Creates an ActionHandler for the given IAction and registers it to the Site's HandlerService, * i. e. binds the action to the command so that key bindings get activated. You need to set the * action's actionDefinitionId to the command id. * /*from ww w . j av a 2s. co m*/ * @param action * the action to activate. The action's actionDefinitionId must have been set to the * command's id (using <code>setActionDefinitionId()</code>) * @param part * the view this action should be registered for */ public static void registerActionHandler(final ViewPart part, final IAction action) { String commandId = action.getActionDefinitionId(); if (!StringTool.isNothing(commandId)) { IHandlerService handlerService = part.getSite().getService(IHandlerService.class); IHandler handler = new ActionHandler(action); handlerService.activateHandler(commandId, handler); } }
From source file:com.aptana.ide.server.ui.actions.RunServerToolbarAction.java
License:Open Source License
/** * Launch the last launch, or open the launch config dialog if none. * /*from ww w.j a v a 2s . co m*/ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { launchMode = action.getActionDefinitionId(); ILaunchConfiguration configuration = getLastLaunch(); if (configuration == null) { try { launchDefaultServer(); } catch (CoreException e) { IdeLog.logError(ServerUIPlugin.getDefault(), Messages.RunServerToolbarAction_ERR_CreateConfig, e); super.run(action); } } else { super.run(action); } }
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 ww .j a 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.github.haixing_hu.swt.action.ActionContributionItemEx.java
License:Open Source License
/** * Returns whether the command corresponding to this action is active. *///w w w . ja v a2 s . c o m private boolean isCommandActive() { final IAction actionToCheck = getAction(); if (actionToCheck != null) { final String commandId = actionToCheck.getActionDefinitionId(); final ExternalActionManager.ICallback callback = ExternalActionManager.getInstance().getCallback(); if (callback != null) { return callback.isActive(commandId); } } return true; }
From source file:com.microsoft.tfs.client.common.ui.framework.action.keybinding.LegacyActionKeyBindingSupport.java
License:Open Source License
@Override public void addAction(final IAction action) { Check.notNull(action, "action"); //$NON-NLS-1$ final String commandId = action.getActionDefinitionId(); if (commandId == null) { throw new IllegalArgumentException("action does not have an action definition ID set"); //$NON-NLS-1$ }//from w w w .ja v a 2s. c o m final IHandler handler = new ActionHandler(action); final HandlerSubmission handlerSubmission = new HandlerSubmission(null, shell, site, commandId, handler, Priority.MEDIUM); workbenchCommandSupport.addHandlerSubmission(handlerSubmission); handlerSubmissions.add(handlerSubmission); }
From source file:com.microsoft.tfs.client.common.ui.framework.action.keybinding.ModernActionKeyBindingSupport.java
License:Open Source License
@Override public void addAction(final IAction action) { Check.notNull(action, "action"); //$NON-NLS-1$ final String commandId = action.getActionDefinitionId(); if (commandId == null) { throw new IllegalArgumentException("action does not have an action definition ID set"); //$NON-NLS-1$ }//w w w . j a va 2 s . com final TriggerSequence[] bindings = bindingService.getActiveBindingsFor(commandId); if (bindings.length > 0) { final IHandler handler = new ActionHandler(action); /* * Call this deprecated overload for 3.1 support */ final IHandlerActivation activation = handlerService.activateHandler(commandId, handler, expression, sourcePriorities); handlerActivations.add(activation); } }
From source file:com.mousefeed.eclipse.ActionActionDescGenerator.java
License:Open Source License
/** * Scans action for data to populate action description. * //ww w.ja v a 2s .co m * @param action * the action to search accelerator for. Not <code>null</code>. */ public void extractActionData(final IAction action) { notNull(action); fromActionAccelerator(action.getAccelerator()); fromActionDefinition(action.getActionDefinitionId()); // retarget action? if (action instanceof RetargetAction) { final RetargetAction a = (RetargetAction) action; if (a.getActionHandler() != null) { extractActionData(a.getActionHandler()); } } fromActionBinding(action); }
From source file:com.siteview.mde.internal.runtime.spy.sections.ActiveMenuSection.java
License:Open Source License
private void createActionContributionItemText(Object object, StringBuffer buffer, SpyFormToolkit toolkit, FormText text) {/* w ww .j a v a 2 s .com*/ ActionContributionItem actionItem = (ActionContributionItem) object; IAction action = actionItem.getAction(); String id = action.getActionDefinitionId(); if (id != null) { buffer.append(toolkit.createIdentifierSection(text, MDERuntimeMessages.ActiveMenuSection_4, new String[] { action.getActionDefinitionId() })); } if (action instanceof PluginAction) { PluginAction pluginAction = (PluginAction) action; Class clazz = pluginAction.getClass(); createActionContributionItemText(object, buffer, toolkit, text, clazz, pluginAction); } else { // normal JFace Actions Class clazz = action.getClass(); buffer.append(toolkit.createClassSection(text, MDERuntimeMessages.ActiveMenuSection_5, new Class[] { clazz })); PackageAdmin admin = PDERuntimePlugin.getDefault().getPackageAdmin(); Bundle bundle = admin.getBundle(clazz); toolkit.generatePluginDetailsText(bundle, null, "meow", buffer, text); //$NON-NLS-1$ } }
From source file:com.vectrace.MercurialEclipse.synchronize.actions.MercurialSynchronizePageActionGroup.java
License:Open Source License
/** * Replaces default "OpenInCompareAction" action with our custom, moves delete action * * @see OpenInCompareAction/*from ww w . j a va 2s . c om*/ * @see ModelSynchronizeParticipantActionGroup * @see HgChangeSetActionProvider */ private void replaceCompareAndMoveDeleteAction(IMenuManager menu) { if (openAction == null) { return; } Object[] elements = ((IStructuredSelection) getContext().getSelection()).toArray(); if (elements.length == 0) { return; } IContributionItem fileGroup = findGroup(menu, ISynchronizePageConfiguration.FILE_GROUP); if (fileGroup == null) { return; } IContributionItem[] items = menu.getItems(); for (IContributionItem ci : items) { if (!(ci instanceof ActionContributionItem)) { continue; } ActionContributionItem ai = (ActionContributionItem) ci; IAction action = ai.getAction(); if (action instanceof OpenInCompareAction) { menu.remove(ai); openAction.setImageDescriptor(action.getImageDescriptor()); openAction.setText(action.getText()); menu.prependToGroup(fileGroup.getId(), openAction); } else if (EDIT_DELETE.equals(action.getActionDefinitionId())) { menu.remove(ai); menu.appendToGroup(DeleteAction.HG_DELETE_GROUP, ai); } } }