Java Code Examples for org.eclipse.ui.commands.ICommandService#getDefinedCommandIds()
The following examples show how to use
org.eclipse.ui.commands.ICommandService#getDefinedCommandIds() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CorrectionCommandInstaller.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void registerCommands(CompilationUnitEditor editor) { IWorkbench workbench= PlatformUI.getWorkbench(); ICommandService commandService= (ICommandService) workbench.getAdapter(ICommandService.class); IHandlerService handlerService= (IHandlerService) workbench.getAdapter(IHandlerService.class); if (commandService == null || handlerService == null) { return; } if (fCorrectionHandlerActivations != null) { JavaPlugin.logErrorMessage("correction handler activations not released"); //$NON-NLS-1$ } fCorrectionHandlerActivations= new ArrayList<IHandlerActivation>(); Collection<String> definedCommandIds= commandService.getDefinedCommandIds(); for (Iterator<String> iter= definedCommandIds.iterator(); iter.hasNext();) { String id= iter.next(); if (id.startsWith(ICommandAccess.COMMAND_ID_PREFIX)) { boolean isAssist= id.endsWith(ICommandAccess.ASSIST_SUFFIX); CorrectionCommandHandler handler= new CorrectionCommandHandler(editor, id, isAssist); IHandlerActivation activation= handlerService.activateHandler(id, handler, new LegacyHandlerSubmissionExpression(null, null, editor.getSite())); fCorrectionHandlerActivations.add(activation); } } }
Example 2
Source File: KbdMacroLoadHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Verify statically that this macro will execute properly * - Ensure the current Eclipse defines the commands used by the macro * * @param editor * @param kbdMacro * @return true if validates, else false */ private String checkMacro(ITextEditor editor, KbdMacro kbdMacro) { String result = null; ICommandService ics = (editor != null ) ? (ICommandService) editor.getSite().getService(ICommandService.class) : (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); @SuppressWarnings("unchecked") // Eclipse documents the type Collection<String> cmdIds = (Collection<String>)ics.getDefinedCommandIds(); for (KbdEvent e : kbdMacro.getKbdMacro()) { String cmdId; if ((cmdId = e.getCmd()) != null) { if (!cmdIds.contains(cmdId)) { result = cmdId; break; } } } return result; }
Example 3
Source File: KeysPreferencePage.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public void init(IWorkbench workbench) { keyController = new KeyController2(); keyController.init(workbench, lstRemove); model = keyController.getBindingModel(); commandService = (ICommandService) workbench.getService(ICommandService.class); Collection definedCommandIds = commandService.getDefinedCommandIds(); fDefaultCategory = commandService.getCategory(null); fBindingService = (IBindingService) workbench.getService(IBindingService.class); commandImageService = (ICommandImageService) workbench.getService(ICommandImageService.class); }
Example 4
Source File: KeysPreferencePage.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public void init(IWorkbench workbench) { keyController = new KeyController2(); keyController.init(workbench, lstRemove); model = keyController.getBindingModel(); commandService = (ICommandService) workbench.getService(ICommandService.class); Collection definedCommandIds = commandService.getDefinedCommandIds(); fDefaultCategory = commandService.getCategory(null); fBindingService = (IBindingService) workbench.getService(IBindingService.class); commandImageService = (ICommandImageService) workbench.getService(ICommandImageService.class); }
Example 5
Source File: KeysPreferencePage.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public void init(IWorkbench workbench) { keyController = new KeyController2(); keyController.init(workbench, lstRemove); model = keyController.getBindingModel(); commandService = (ICommandService) workbench.getService(ICommandService.class); Collection definedCommandIds = commandService.getDefinedCommandIds(); fDefaultCategory = commandService.getCategory(null); fBindingService = (IBindingService) workbench.getService(IBindingService.class); commandImageService = (ICommandImageService) workbench.getService(ICommandImageService.class); }
Example 6
Source File: FirstCharAction.java From Pydev with Eclipse Public License 1.0 | 4 votes |
/** * Creates a handler that will properly treat home considering python code (if it's still not defined * by the platform -- otherwise, just go with what the platform provides). */ public static VerifyKeyListener createVerifyKeyListener(final SourceViewer viewer, final IWorkbenchPartSite site, boolean forceCreation) { // This only needs to be done for eclipse 3.2 (where line start is not // defined). // Eclipse 3.3 onwards already defines the home key in the text editor. final boolean isDefined; if (site != null) { ICommandService commandService = (ICommandService) site.getService(ICommandService.class); Collection definedCommandIds = commandService.getDefinedCommandIds(); isDefined = definedCommandIds.contains("org.eclipse.ui.edit.text.goto.lineStart"); } else { isDefined = false; } if (forceCreation || !isDefined) { return new VerifyKeyListener() { @Override public void verifyKey(VerifyEvent event) { if (event.doit) { boolean isHome; if (isDefined) { isHome = KeyBindingHelper.matchesKeybinding(event.keyCode, event.stateMask, "org.eclipse.ui.edit.text.goto.lineStart"); } else { isHome = event.keyCode == SWT.HOME && event.stateMask == 0; } if (isHome) { ISelection selection = viewer.getSelection(); if (selection instanceof ITextSelection) { FirstCharAction firstCharAction = new FirstCharAction(); firstCharAction.viewer = viewer; firstCharAction.perform(viewer.getDocument(), (ITextSelection) selection); event.doit = false; } } } } }; } return null; }