org.eclipse.ui.commands.ICommandService Java Examples
The following examples show how to use
org.eclipse.ui.commands.ICommandService.
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: EditEigenleistungUi.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
public static void executeWithParams(PersistentObject parameter){ try { // get the command IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ICommandService cmdService = (ICommandService) window.getService(ICommandService.class); Command cmd = cmdService.getCommand(EditEigenleistungUi.COMMANDID); // create the parameter HashMap<String, Object> param = new HashMap<String, Object>(); param.put(EditEigenleistungUi.PARAMETERID, parameter); // build the parameterized command ParameterizedCommand pc = ParameterizedCommand.generateCommand(cmd, param); // execute the command IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getService(IHandlerService.class); handlerService.executeCommand(pc, null); } catch (Exception ex) { throw new RuntimeException(EditEigenleistungUi.COMMANDID, ex); } }
Example #2
Source File: EditLocalDocumentUtil.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
/** * If {@link Preferences#P_TEXT_EDIT_LOCAL} is set, the * <code> ch.elexis.core.ui.command.startEditLocalDocument </code> command is called with the * provided {@link Brief}, and the provided {@link IViewPart} is hidden. * * @param view * @param brief * @return returns true if edit local is started and view is hidden */ public static boolean startEditLocalDocument(IViewPart view, Brief brief){ if (CoreHub.localCfg.get(Preferences.P_TEXT_EDIT_LOCAL, false) && brief != null) { // open for editing ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command command = commandService.getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); //$NON-NLS-1$ PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(command.getId().concat(".selection"), new StructuredSelection(brief)); try { command.executeWithChecks( new ExecutionEvent(command, Collections.EMPTY_MAP, view, null)); } catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e) { MessageDialog.openError(view.getSite().getShell(), Messages.TextView_errortitle, Messages.TextView_errorlocaleditmessage); } view.getSite().getPage().hideView(view); return true; } return false; }
Example #3
Source File: PCalTranslateAutomaticallyHandler.java From tlaplus with MIT License | 6 votes |
@Inject public void initializeAtStartup(final IWorkbench workbench, final ICommandService commandService) { /* * Check the UI state of the IHandler/Command which indicates if the user * enabled automatic PlusCal conversion. */ final Command command = commandService.getCommand("toolbox.command.module.translate.automatially"); final State state = command.getState(RegistryToggleState.STATE_ID); if (!((Boolean) state.getValue()).booleanValue()) { return; } // This IHander is stateful even across Toolbox restarts. In other words, if the // user enables automatic PlusCal translation, it will remain enabled even after // a Toolbox restart. This means we have to register this EventHandler at the // IEventBroker during Toolbox startup. // It is vital that we use the Workbench's IEventBroker instance. If e.g. we // would use an IEventBroker from higher up the IEclipseContext hierarchy, the // broker would be disposed when a new spec gets opened while the IHandler's state // remains enabled. workbench.getService(IEventBroker.class).unsubscribe(this); Assert.isTrue(workbench.getService(IEventBroker.class).subscribe(TLAEditor.PRE_SAVE_EVENT, this)); }
Example #4
Source File: BonitaAppearancePreferencePage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public boolean performOk() { if (super.performOk()) { final String value = BonitaStudioPreferencesPlugin.getDefault().getPreferenceStore() .getString(BonitaCoolBarPreferenceConstant.COOLBAR_DEFAULT_SIZE); try { final ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); if (value.equals(BonitaCoolBarPreferenceConstant.SMALL)) { service.getCommand("org.bonitasoft.studio.application.smallCoolbar").executeWithChecks(new ExecutionEvent()); } else if (value.equals(BonitaCoolBarPreferenceConstant.NORMAL)) { service.getCommand("org.bonitasoft.studio.application.normalCoolbar").executeWithChecks(new ExecutionEvent()); } } catch (final Exception e) { BonitaStudioLog.error(e); } } return false; }
Example #5
Source File: Utils.java From EasyShell with Eclipse Public License 2.0 | 6 votes |
private static void executeCommand(IWorkbench workbench, String commandName, Map<String, Object> params) { if (workbench == null) { workbench = PlatformUI.getWorkbench(); } // get command ICommandService commandService = (ICommandService)workbench.getService(ICommandService.class); Command command = commandService != null ? commandService.getCommand(commandName) : null; // get handler service //IBindingService bindingService = (IBindingService)workbench.getService(IBindingService.class); //TriggerSequence[] triggerSequenceArray = bindingService.getActiveBindingsFor("de.anbos.eclipse.easyshell.plugin.commands.open"); IHandlerService handlerService = (IHandlerService)workbench.getService(IHandlerService.class); if (command != null && handlerService != null) { ParameterizedCommand paramCommand = ParameterizedCommand.generateCommand(command, params); try { handlerService.executeCommand(paramCommand, null); } catch (Exception e) { Activator.logError(Activator.getResourceString("easyshell.message.error.handlerservice.execution"), paramCommand.toString(), e, true); } } }
Example #6
Source File: CompareWithRouteAction.java From eip-designer with Apache License 2.0 | 6 votes |
@Override public void run(IAction action) { System.err.println("In run(IACtion)"); if (serviceLocator == null) { serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); } // Create an ExecutionEvent using Eclipse machinery. ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class); IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class); ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.COMPARE_WITH_ROUTE_ACTION), null); // Fill it my current active selection. if (event.getApplicationContext() instanceof IEvaluationContext) { ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection); } try { handler.execute(event); } catch (ExecutionException e) { Activator.handleError(e.getMessage(), e, true); } }
Example #7
Source File: PersistToRouteModelAction.java From eip-designer with Apache License 2.0 | 6 votes |
@Override public void run(IAction action) { if (serviceLocator == null) { serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); } // Create an ExecutionEvent using Eclipse machinery. ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class); IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class); ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.PERSIST_TO_ROUTE_MODEL_ACTION), null); // Fill it my current active selection. if (event.getApplicationContext() instanceof IEvaluationContext) { ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection); } try { handler.execute(event); } catch (ExecutionException e) { Activator.handleError(e.getMessage(), e, true); } }
Example #8
Source File: CompareWithRouteAction.java From eip-designer with Apache License 2.0 | 6 votes |
@Override public void run(IAction action) { System.err.println("In run(IACtion)"); if (serviceLocator == null) { serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); } // Create an ExecutionEvent using Eclipse machinery. ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class); IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class); ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.COMPARE_WITH_ROUTE_ACTION), null); // Fill it my current active selection. if (event.getApplicationContext() instanceof IEvaluationContext) { ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection); } try { handler.execute(event); } catch (ExecutionException e) { Activator.handleError(e.getMessage(), e, true); } }
Example #9
Source File: PersistToRouteModelAction.java From eip-designer with Apache License 2.0 | 6 votes |
@Override public void run(IAction action) { if (serviceLocator == null) { serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); } // Create an ExecutionEvent using Eclipse machinery. ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class); IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class); ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.PERSIST_TO_ROUTE_MODEL_ACTION), null); // Fill it my current active selection. if (event.getApplicationContext() instanceof IEvaluationContext) { ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection); } try { handler.execute(event); } catch (ExecutionException e) { Activator.handleError(e.getMessage(), e, true); } }
Example #10
Source File: ExecutionListenerRegistrant.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * setup */ private void setup() { try { // listen for execution events Object service = PlatformUI.getWorkbench().getService(ICommandService.class); if (service instanceof ICommandService) { ICommandService commandService = (ICommandService) service; commandService.addExecutionListener(this); } } catch (IllegalStateException e) { // workbench not yet started, or may be running headless (like in core unit tests) } // listen for element visibility events BundleManager manager = BundleManager.getInstance(); manager.addElementVisibilityListener(this); }
Example #11
Source File: ExecutionListenerRegistrant.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * tearDown */ private void tearDown() { // stop listening for visibility events BundleManager manager = BundleManager.getInstance(); manager.removeElementVisibilityListener(this); // stop listening for execution events Object service = PlatformUI.getWorkbench().getService(ICommandService.class); if (service instanceof ICommandService) { ICommandService commandService = (ICommandService) service; commandService.removeExecutionListener(this); } // drop all references this._commandToIdsMap.clear(); this._idToCommandsMap.clear(); this._nonlimitedCommands.clear(); }
Example #12
Source File: EditEigenartikelUi.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
public static void executeWithParams(PersistentObject parameter){ try { // get the command IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ICommandService cmdService = (ICommandService) window.getService(ICommandService.class); Command cmd = cmdService.getCommand(EditEigenartikelUi.COMMANDID); // create the parameter HashMap<String, Object> param = new HashMap<String, Object>(); param.put(EditEigenartikelUi.PARAMETERID, parameter); // build the parameterized command ParameterizedCommand pc = ParameterizedCommand.generateCommand(cmd, param); // execute the command IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getService(IHandlerService.class); handlerService.executeCommand(pc, null); } catch (Exception ex) { throw new RuntimeException(EditEigenleistungUi.COMMANDID, ex); } }
Example #13
Source File: CommandsPropertyTester.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) { if (receiver instanceof IServiceLocator && args.length == 1 && args[0] instanceof String) { final IServiceLocator locator = (IServiceLocator) receiver; if (TOGGLE_PROPERTY_NAME.equals(property)) { final String commandId = args[0].toString(); final ICommandService commandService = (ICommandService) locator .getService(ICommandService.class); final Command command = commandService.getCommand(commandId); final State state = command .getState(RegistryToggleState.STATE_ID); if (state != null) { return state.getValue().equals(expectedValue); } } } return false; }
Example #14
Source File: ErstelleRnnCommand.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
public static Object ExecuteWithParams(IViewSite origin, Tree<?> tSelection){ IHandlerService handlerService = (IHandlerService) origin.getService(IHandlerService.class); ICommandService cmdService = (ICommandService) origin.getService(ICommandService.class); try { Command command = cmdService.getCommand(ID); Parameterization px = new Parameterization(command.getParameter("ch.elexis.RechnungErstellen.parameter"), //$NON-NLS-1$ new TreeToStringConverter().convertToString(tSelection)); ParameterizedCommand parmCommand = new ParameterizedCommand(command, new Parameterization[] { px }); return handlerService.executeCommand(parmCommand, null); } catch (Exception ex) { throw new RuntimeException("add.command not found"); //$NON-NLS-1$ } }
Example #15
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 #16
Source File: KbdMacroDefineHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Define the Command to be used when executing the named kbd macro * * @param editor * @param id - the full command id * @param name - the short name * @param category - the category to use in the definition * @return the Command */ Command defineKbdMacro(ITextEditor editor, String id, String name, String category) { Command command = null; if (id != null) { // Now create the executable command ICommandService ics = (editor != null ) ? (ICommandService) editor.getSite().getService(ICommandService.class) : (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); command = ics.getCommand(id); IParameter[] parameters = null; try { // kludge: Eclipse has no way to dynamically define a parameter, so grab it from a known command IParameter p = ics.getCommand(PARAMETER_CMD).getParameter(PARAMETER); parameters = new IParameter[] { p }; } catch (Exception e) { } command.define(name, String.format(KBD_DESCRIPTION,name), ics.getCategory(category), parameters); command.setHandler(new KbdMacroNameExecuteHandler(name)); } return command; }
Example #17
Source File: FindingsUiUtil.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
/** * Execute the UI command found by the commandId, using the {@link ICommandService}. * * @param commandId * @param selection * @return */ public static Object executeCommand(String commandId, IFinding selection){ try { ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); Command cmd = commandService.getCommand(commandId); if(selection != null) { PlatformUI.getWorkbench().getService(IEclipseContext.class) .set(commandId.concat(".selection"), new StructuredSelection(selection)); } ExecutionEvent ee = new ExecutionEvent(cmd, Collections.EMPTY_MAP, null, null); return cmd.executeWithChecks(ee); } catch (Exception e) { LoggerFactory.getLogger(FindingsUiUtil.class) .error("cannot execute command with id: " + commandId, e); } return null; }
Example #18
Source File: KbdMacroSupport.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Start the definition of a keyboard macro * * @param editor * @param append - if true, append to the current definition */ public void startKbdMacro(ITextEditor editor, boolean append) { if (!isExecuting()) { setEditor(editor); isdefining = true; ics = (ICommandService) editor.getSite().getService(ICommandService.class); // listen for command executions ics.addExecutionListener(this); addDocumentListener(editor); if (!append || kbdMacro == null) { kbdMacro = new KbdMacro(); } setViewer(findSourceViewer(editor)); if (viewer instanceof ITextViewerExtension) { ((ITextViewerExtension) viewer).prependVerifyKeyListener(whileDefining); } else { viewer = null; } // add a listener for ^G Beeper.addBeepListener(KbdMacroBeeper.beeper); currentCommand = null; } }
Example #19
Source File: CommandSupport.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Get the current set of defined categories corresponding to the included category names * * @param ics * @return the filtered set of categories * * @throws NotDefinedException */ private HashSet<Category> getCategories(ICommandService ics) throws NotDefinedException { if (catHash.isEmpty() && catIncludes != null) { Category[] cats = ics.getDefinedCategories(); for (int i = 0; i < cats.length; i++) { for (int j = 0; j < catIncludes.length; j++) { if (catIncludes[j].equals(cats[i].getId())) { catHash.add(cats[i]); break; } } } } return catHash; }
Example #20
Source File: UIUtils.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public static void setCoolBarVisibility(boolean visible) { IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow(); if (activeWorkbenchWindow instanceof WorkbenchWindow) { WorkbenchWindow workbenchWindow = (WorkbenchWindow) activeWorkbenchWindow; workbenchWindow.setCoolBarVisible(visible); workbenchWindow.setPerspectiveBarVisible(visible); // Try to force a refresh of the text on the action IWorkbenchPart activePart = getActivePart(); if (activePart != null) { ICommandService cmdService = (ICommandService) activePart.getSite().getService(ICommandService.class); cmdService.refreshElements("org.eclipse.ui.ToggleCoolbarAction", null); //$NON-NLS-1$ } } }
Example #21
Source File: TestFullScenario.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @throws ExecutionException */ public void editAndSave() throws Exception { processEditor = getTheOnlyOneEditor(); processEditor.getEditingDomain().getCommandStack().execute( new SetCommand(processEditor.getEditingDomain(), task, ProcessPackage.Literals.ELEMENT__NAME, TESTNAME)); final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class); final ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); final Command saveCommand = commandService.getCommand("org.eclipse.ui.file.save"); final ExecutionEvent executionEvent = new ExecutionEvent(saveCommand, Collections.EMPTY_MAP, null, handlerService.getClass()); saveCommand.executeWithChecks(executionEvent); }
Example #22
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 #23
Source File: OpenToolBarHandler.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindowChecked(event); if (activeWorkbenchWindow instanceof WorkbenchWindow) { WorkbenchWindow window = (WorkbenchWindow) activeWorkbenchWindow; window.toggleToolbarVisibility(); } ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); commandService.refreshElements(event.getCommand().getId(), null); return null; }
Example #24
Source File: OpenStatusBarHandler.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); boolean oldValue = preferenceStore.getBoolean(TsPreferencesConstant.TS_statusBar_status); ApplicationWorkbenchWindowAdvisor configurer = ApplicationWorkbenchAdvisor.WorkbenchWindowAdvisor; configurer.setStatusVisible(!oldValue); preferenceStore.setValue(TsPreferencesConstant.TS_statusBar_status, !oldValue); ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); commandService.refreshElements(event.getCommand().getId(), null); return null; }
Example #25
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 #26
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 #27
Source File: AbstractShieldCommandStartup.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public void earlyStartup() { final IWorkbench workbench = PlatformUI.getWorkbench(); workbench.getDisplay().asyncExec(new Runnable() { public void run() { Set<String> unusedCommand = getUnusedCommandSet(); ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class); Command command; for (String commandId : unusedCommand) { command = commandService.getCommand(commandId); command.undefine(); } } }); }
Example #28
Source File: KeyboardBindingsTask.java From workspacemechanic with Eclipse Public License 1.0 | 5 votes |
KeyboardBindingsTask( MechanicLog log, IWorkbench workbench, ICommandService commandService, IBindingService bindingService, KeyBindingsModel model, String id) { this.log = log; this.workbench = workbench; this.commandService = commandService; this.bindingService = bindingService; this.model = Preconditions.checkNotNull(model); this.id = id; }
Example #29
Source File: KbdMacroBindHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Add the binding to the Emacs+ scheme * * @param editor * @param bindingResult */ private void addBinding(ITextEditor editor, IBindingResult bindingResult, String name) { IBindingService service = (IBindingService) editor.getSite().getService(IBindingService.class); if (service instanceof BindingService) { try { BindingService bindingMgr = (BindingService) service; if (bindingResult.getKeyBinding() != null) { // we're overwriting a binding, out with the old bindingMgr.removeBinding(bindingResult.getKeyBinding()); } Command command = null; if (name != null) { ICommandService ics = (ICommandService) editor.getSite().getService(ICommandService.class); String id = EmacsPlusUtils.kbdMacroId(name); // check first, as getCommand will create it if it doesn't already exist if (ics.getDefinedCommandIds().contains(id)) { command = ics.getCommand(id); } } else { // use the unexposed category command = nameKbdMacro(KBD_LNAME + nameid++, editor, KBD_GAZONK); } if (command != null) { Binding binding = new KeyBinding(bindingResult.getTrigger(), new ParameterizedCommand(command, null), KBD_SCHEMEID, KBD_CONTEXTID, null, null, null, Binding.USER); bindingMgr.addBinding(binding); asyncShowMessage(editor, String.format(BOUND, bindingResult.getKeyString()), false); } else { asyncShowMessage(editor, String.format(NO_NAME_UNO, name), true); } } catch (Exception e) { asyncShowMessage(editor, String.format(ABORT, bindingResult.getKeyString()), true); } } }
Example #30
Source File: FallDetailView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private void releaseAndRefreshLock(IPersistentObject object, String commandId){ if (object != null && LocalLockServiceHolder.get().isLockedLocal(object)) { LocalLockServiceHolder.get().releaseLock(object); } ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); commandService.refreshElements(commandId, null); }