org.eclipse.core.commands.ParameterizedCommand Java Examples
The following examples show how to use
org.eclipse.core.commands.ParameterizedCommand.
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: ConfigurationHelper.java From neoscada with Eclipse Public License 1.0 | 6 votes |
private static AlarmNotifierConfiguration convertAlarmNotifier ( final IConfigurationElement ele ) { try { final String connectionId = ele.getAttribute ( "connectionId" ); //$NON-NLS-1$ final String prefix = ele.getAttribute ( "prefix" ) == null ? "ae.server.info" : ele.getAttribute ( "prefix" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ $NON-NLS-2$ final URL soundFile = Platform.getBundle ( ele.getContributor ().getName () ).getEntry ( ele.getAttribute ( "soundFile" ) ); //$NON-NLS-1$ final ParameterizedCommand ackAlarmsAvailableCommand = convertCommand ( ele.getChildren ( "ackAlarmsAvailableCommand" )[0] ); //$NON-NLS-1$ final ParameterizedCommand alarmsAvailableCommand = convertCommand ( ele.getChildren ( "alarmsAvailableCommand" )[0] ); //$NON-NLS-1$ return new AlarmNotifierConfiguration ( connectionId, prefix, soundFile, ackAlarmsAvailableCommand, alarmsAvailableCommand ); } catch ( final Exception e ) { logger.warn ( "Failed to convert alarm notifier configuration: {}", ele ); //$NON-NLS-1$ return null; } }
Example #2
Source File: ExportDiagramHandler.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { fileStoreFinder .findSelectedFileStore(RepositoryManager.getInstance().getCurrentRepository()) .ifPresent(fileStore -> { Map<String, Object> parameters = new HashMap<>(); parameters.put(EXPORT_PARAMETER, fileStore.getName()); ParameterizedCommand parameterizedCommand = eCommandService.createCommand(EXPORT_COMMAND, parameters); if (eHandlerService.canExecute(parameterizedCommand)) { eHandlerService.executeHandler(parameterizedCommand); } else { throw new RuntimeException(String.format("Can't execute command %s", parameterizedCommand.getId())); } }); return null; }
Example #3
Source File: AbstractMenuContributionItem.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("restriction") protected MenuItem createMenu(Menu parent, String command, Optional<Image> image) { MenuItem item = new MenuItem(parent, SWT.NONE); ParameterizedCommand parameterizedCommand = createParametrizedCommand(command); try { item.setText(parameterizedCommand.getName()); } catch (NotDefinedException e) { BonitaStudioLog.error( String.format("The command '%s' doesn't have any name defined.", parameterizedCommand.getId()), e); item.setText(parameterizedCommand.getId()); } item.addListener(SWT.Selection, e -> { if (eHandlerService.canExecute(parameterizedCommand)) { eHandlerService.executeHandler(parameterizedCommand); } else { throw new RuntimeException(String.format("Can't execute command %s", parameterizedCommand.getId())); } }); item.setEnabled(true); appendShortcut(parameterizedCommand, item); image.ifPresent(item::setImage); return item; }
Example #4
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 #5
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 #6
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 #7
Source File: Handler.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private static Object execute(IViewSite origin, String commandID, Map<String, Object> params){ if (origin == null) { log.error("origin is null"); return null; } IHandlerService handlerService = (IHandlerService) origin.getService(IHandlerService.class); ICommandService cmdService = (ICommandService) origin.getService(ICommandService.class); try { Command command = cmdService.getCommand(commandID); String name = StringTool.unique("CommandHandler"); //$NON-NLS-1$ paramMap.put(name, params); Parameterization px = new Parameterization(new DefaultParameter(), name); 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 #8
Source File: EditLabItemUi.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(COMMANDID); // create the parameter HashMap<String, Object> param = new HashMap<String, Object>(); param.put(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(COMMANDID, ex); } }
Example #9
Source File: ImportBarCoolbarItem.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void fill(final ToolBar toolbar, final int index, final int iconSize) { final ToolItem item = new ToolItem(toolbar, SWT.PUSH); item.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_IMPORT_TOOLITEM); item.setToolTipText(Messages.ImportProcessButtonLabel); if (iconSize < 0) { item.setImage(Pics.getImage(PicsConstants.coolbar_import_48)); item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_import_disabled_48)); } else { item.setImage(Pics.getImage(PicsConstants.coolbar_import_16)); item.setDisabledImage(Pics.getImage(PicsConstants.coolbar_import_disabled_16)); } item.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { ECommandService eCommandService = PlatformUI.getWorkbench().getService(ECommandService.class); EHandlerService eHandlerService = PlatformUI.getWorkbench().getService(EHandlerService.class); ParameterizedCommand importCommand = ParameterizedCommand.generateCommand( eCommandService.getCommand("org.bonitasoft.studio.importer.bos.command"), null); eHandlerService.executeHandler(importCommand); } }); }
Example #10
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 #11
Source File: CodeAssistAdvancedConfigurationBlock.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static String getKeyboardShortcut(ParameterizedCommand command) { IBindingService bindingService= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); fgLocalBindingManager.setBindings(bindingService.getBindings()); try { Scheme activeScheme= bindingService.getActiveScheme(); if (activeScheme != null) fgLocalBindingManager.setActiveScheme(activeScheme); } catch (NotDefinedException e) { JavaPlugin.log(e); } TriggerSequence[] bindings= fgLocalBindingManager.getActiveBindingsDisregardingContextFor(command); if (bindings.length > 0) return bindings[0].format(); return null; }
Example #12
Source File: CommandHelp.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Get the displayable key-binding information for the command * * @param com - the command * @param activep - if true, return only active bindings * * @return a String array of binding sequence binding context information */ public static String[] getKeyBindingStrings(Command com, boolean activep) { String id = com.getId(); TriggerSequence trigger; // Get platform bindings for Command Binding[] bindings = getBindings(com,activep); List<String> bindingInfo = new ArrayList<String>(); ParameterizedCommand c; for (Binding bind : bindings) { c = bind.getParameterizedCommand(); if (c != null && c.getId().equals(id)) { trigger = bind.getTriggerSequence(); bindingInfo.add(trigger.toString()); bindingInfo.add(bind.getContextId()); } } return bindingInfo.toArray(new String[0]); }
Example #13
Source File: EmacsPlusUtils.java From e4macs with Eclipse Public License 1.0 | 6 votes |
private static Object executeCommand(String commandId, Map<String,?> parameters, Event event, ICommandService ics, IHandlerService ihs) throws ExecutionException, NotDefinedException, NotEnabledException, NotHandledException, CommandException { Object result = null; if (ics != null && ihs != null) { Command command = ics.getCommand(commandId); if (command != null) { try { MarkUtils.setIgnoreDispatchId(true); ParameterizedCommand pcommand = ParameterizedCommand.generateCommand(command, parameters); if (pcommand != null) { result = ihs.executeCommand(pcommand, event); } } finally { MarkUtils.setIgnoreDispatchId(false); } } } return result; }
Example #14
Source File: CommandDescribeHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Print the details about a parameterized command on the Emacs+ console * * @param cmd * @param console */ void printCmdDetails(ParameterizedCommand cmd, EmacsPlusConsole console) { String[] bindings = CommandHelp.getKeyBindingStrings(cmd, false); String[] abindings = CommandHelp.getKeyBindingStrings(cmd, true); console.print(SWT.TAB + DESC_ID); console.printContext(cmd.getId() + CR); @SuppressWarnings("unchecked") Map<String,?> parameterMap = cmd.getParameterMap(); if (!parameterMap.isEmpty()) { console.printBold(' ' + CMD_PARAM_HEADING + CR); try { Set<String> keySet = parameterMap.keySet(); for (String key : keySet) { console.print(SWT.TAB + key + '=' + parameterMap.get(key) + CR); } } catch (Exception e) {} } console.printBold(' ' + CMD_KEY_HEADING + CR); printDetails(cmd.getCommand(), bindings, abindings, console); }
Example #15
Source File: KeyController2.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * Sets the bindings to default. * @param bindingService * @throws NotDefinedException */ public void setDefaultBindings(IBindingService bindingService, List<String> lstRemove) throws NotDefinedException { // Fix the scheme in the local changes. final String defaultSchemeId = bindingService.getDefaultSchemeId(); final Scheme defaultScheme = fBindingManager.getScheme(defaultSchemeId); try { fBindingManager.setActiveScheme(defaultScheme); } catch (final NotDefinedException e) { // At least we tried.... } // Restore any User defined bindings Binding[] bindings = fBindingManager.getBindings(); for (int i = 0; i < bindings.length; i++) { ParameterizedCommand pCommand = bindings[i].getParameterizedCommand(); String commandId = null; if (pCommand != null) { commandId = pCommand.getCommand().getId(); } if (bindings[i].getType() == Binding.USER || (commandId != null && lstRemove.contains(commandId))) { fBindingManager.removeBinding(bindings[i]); } } bindingModel.refresh(contextModel, lstRemove); saveBindings(bindingService); }
Example #16
Source File: KbdMacroLoadHandler.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Bind the loaded macro to its previous key binding, removing any conflicts * * @param editor * @param command - the new kbd macro command * @param sequence - key sequence for binding * @param previous - conflicting binding */ private void bindMacro(ITextEditor editor, Command command, KeySequence sequence, Binding previous) { if (command != null && sequence != null) { IBindingService service = (editor != null) ? (IBindingService) editor.getSite().getService(IBindingService.class) : (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class); if (service instanceof BindingService) { BindingService bindingMgr = (BindingService) service; if (previous != null) { bindingMgr.removeBinding(previous); } ParameterizedCommand p = new ParameterizedCommand(command, null); Binding binding = new KeyBinding(sequence, p, KBD_SCHEMEID, KBD_CONTEXTID, null, null, null, Binding.USER); bindingMgr.addBinding(binding); // check for conflicts independent of the current Eclipse context checkConflicts(bindingMgr,sequence,binding); } } }
Example #17
Source File: KeyController2.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * Sets the bindings to default. * @param bindingService * @throws NotDefinedException */ public void setDefaultBindings(IBindingService bindingService, List<String> lstRemove) throws NotDefinedException { // Fix the scheme in the local changes. final String defaultSchemeId = bindingService.getDefaultSchemeId(); final Scheme defaultScheme = fBindingManager.getScheme(defaultSchemeId); try { fBindingManager.setActiveScheme(defaultScheme); } catch (final NotDefinedException e) { // At least we tried.... } // Restore any User defined bindings Binding[] bindings = fBindingManager.getBindings(); for (int i = 0; i < bindings.length; i++) { ParameterizedCommand pCommand = bindings[i].getParameterizedCommand(); String commandId = null; if (pCommand != null) { commandId = pCommand.getCommand().getId(); } if (bindings[i].getType() == Binding.USER || (commandId != null && lstRemove.contains(commandId))) { fBindingManager.removeBinding(bindings[i]); } } bindingModel.refresh(contextModel, lstRemove); saveBindings(bindingService); }
Example #18
Source File: KeyController2.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
/** * Sets the bindings to default. * @param bindingService * @throws NotDefinedException */ public void setDefaultBindings(IBindingService bindingService, List<String> lstRemove) throws NotDefinedException { // Fix the scheme in the local changes. final String defaultSchemeId = bindingService.getDefaultSchemeId(); final Scheme defaultScheme = fBindingManager.getScheme(defaultSchemeId); try { fBindingManager.setActiveScheme(defaultScheme); } catch (final NotDefinedException e) { // At least we tried.... } // Restore any User defined bindings Binding[] bindings = fBindingManager.getBindings(); for (int i = 0; i < bindings.length; i++) { ParameterizedCommand pCommand = bindings[i].getParameterizedCommand(); String commandId = null; if (pCommand != null) { commandId = pCommand.getCommand().getId(); } if (bindings[i].getType() == Binding.USER || (commandId != null && lstRemove.contains(commandId))) { fBindingManager.removeBinding(bindings[i]); } } bindingModel.refresh(contextModel, lstRemove); saveBindings(bindingService); }
Example #19
Source File: KeyAssistHandler.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { final IWorkbench workbench = PlatformUI.getWorkbench(); IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class); BindingService service = (BindingService) bindingService; ArrayList<Binding> lstBinding = new ArrayList<Binding>(Arrays.asList(bindingService.getBindings())); List<String> lstRemove = Constants.lstRemove; Iterator<Binding> it = lstBinding.iterator(); while (it.hasNext()) { Binding binding = it.next(); ParameterizedCommand pCommand = binding.getParameterizedCommand(); if (pCommand == null || lstRemove.contains(pCommand.getCommand().getId())) { it.remove(); } } service.getKeyboard().openKeyAssistShell(lstBinding); return null; }
Example #20
Source File: KeyAssistHandler.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { final IWorkbench workbench = PlatformUI.getWorkbench(); IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class); BindingService service = (BindingService) bindingService; ArrayList<Binding> lstBinding = new ArrayList<Binding>(Arrays.asList(bindingService.getBindings())); List<String> lstRemove = Constants.lstRemove; Iterator<Binding> it = lstBinding.iterator(); while (it.hasNext()) { Binding binding = it.next(); ParameterizedCommand pCommand = binding.getParameterizedCommand(); if (pCommand == null || lstRemove.contains(pCommand.getCommand().getId())) { it.remove(); } } service.getKeyboard().openKeyAssistShell(lstBinding); return null; }
Example #21
Source File: CommandHelp.java From e4macs with Eclipse Public License 1.0 | 6 votes |
/** * Get the displayable key-binding information for the parameterized command * * @param com the command * @param activep - if true, return only active bindings * * @return a String array of binding sequence binding context information */ public static String[] getKeyBindingStrings(ParameterizedCommand com, boolean activep) { TriggerSequence trigger; // Get platform bindings for the ParameterizedCommand's Command Binding[] bindings = getBindings(com.getCommand(),activep); List<String> bindingInfo = new ArrayList<String>(); ParameterizedCommand c; for (Binding bind : bindings) { c = bind.getParameterizedCommand(); if (c != null && c.equals(com)) { trigger = bind.getTriggerSequence(); bindingInfo.add(trigger.toString()); bindingInfo.add(bind.getContextId()); } } return bindingInfo.toArray(new String[0]); }
Example #22
Source File: CommandDescribeHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
Command getCommand(Binding binding) { Command result = null; ParameterizedCommand pc = binding.getParameterizedCommand(); if (pc != null) { result = pc.getCommand(); } return result; }
Example #23
Source File: WithMinibuffer.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * @param editor * @param binding * @throws ExecutionException * @throws NotDefinedException * @throws NotEnabledException * @throws NotHandledException */ private void callBinding(final ITextEditor editor, final Binding binding) { try { IHandlerService service = (IHandlerService) editor.getSite().getService(IHandlerService.class); ParameterizedCommand pcommand = binding.getParameterizedCommand(); service.executeCommand(pcommand, null); } catch (Exception e) { // Shouldn't happen, but fail quietly } }
Example #24
Source File: CommandUtils.java From birt with Eclipse Public License 1.0 | 5 votes |
public static Object executeCommand( String commandId, Map paramMap ) throws NotDefinedException, ExecutionException, ParameterValueConversionException, NotEnabledException, NotHandledException { Command cmd = CommandUtils.getCommand( commandId ); List paramList = new ArrayList( ); if ( paramMap != null ) { for ( Iterator iter = paramMap.entrySet( ).iterator( ); iter.hasNext( ); ) { Map.Entry entry = (Entry) iter.next( ); String paramId = entry.getKey( ).toString( ); Object value = entry.getValue( ); if ( value != null ) { paramList.add( createParameter( cmd, paramId, value ) ); } } } if ( paramList.size( ) > 0 ) { ParameterizedCommand paramCommand = new ParameterizedCommand( cmd, (Parameterization[]) paramList.toArray( new Parameterization[paramList.size( )] ) ); return getHandlerService( ).executeCommand( paramCommand, null ); } else { return getHandlerService( ).executeCommand( commandId, null ); } }
Example #25
Source File: BindKeysHelper.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * @param force if true, we'll create the user binding regardless of having some existing binding. Otherwise, * we'll not allow the creation if a binding already exists for it. * * Note: conflicting bindings should be removed before (through removeUserBindingsWithFilter). If they're * not removed, a conflict will be created in the bindings. */ public void addUserBindings(KeySequence keySequence, ParameterizedCommand command) throws Exception { Scheme activeScheme = bindingService.getActiveScheme(); String schemeId = activeScheme.getId(); localChangeManager.addBinding(new KeyBinding(keySequence, command, schemeId, contextId, null, null, null, Binding.USER)); }
Example #26
Source File: AbstractMenuContributionItem.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void appendShortcut(ParameterizedCommand parameterizedCommand, MenuItem item) { TriggerSequence triggerSequence = eBindingService.getBestSequenceFor(parameterizedCommand); if (triggerSequence != null && triggerSequence instanceof KeySequence) { KeySequence keySequence = (KeySequence) triggerSequence; String rawLabel = item.getText(); item.setText(String.format("%s %s%s", rawLabel, '\t', keySequence.format())); } }
Example #27
Source File: SendBriefAsMailHandler.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException{ Brief brief = (Brief) ElexisEventDispatcher.getSelected(Brief.class); if (brief != null) { List<File> attachments = new ArrayList<File>(); Optional<File> tmpFile = getTempFile(brief); if (tmpFile.isPresent()) { attachments.add(tmpFile.get()); ICommandService commandService = (ICommandService) HandlerUtil .getActiveWorkbenchWindow(event).getService(ICommandService.class); try { String attachmentsString = getAttachmentsString(attachments); Command sendMailCommand = commandService.getCommand("ch.elexis.core.mail.ui.sendMail"); HashMap<String, String> params = new HashMap<String, String>(); params.put("ch.elexis.core.mail.ui.sendMail.attachments", attachmentsString); Patient patient = ElexisEventDispatcher.getSelectedPatient(); if (patient != null) { params.put("ch.elexis.core.mail.ui.sendMail.subject", "Patient: " + patient.getLabel()); } ParameterizedCommand parametrizedCommmand = ParameterizedCommand.generateCommand(sendMailCommand, params); PlatformUI.getWorkbench().getService(IHandlerService.class) .executeCommand(parametrizedCommmand, null); } catch (Exception ex) { throw new RuntimeException("ch.elexis.core.mail.ui.sendMail not found", ex); } } removeTempAttachments(attachments); } return null; }
Example #28
Source File: KeyController2.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("restriction") public void filterDupliteBind(){ IWorkbench workbench = PlatformUI.getWorkbench(); IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class); BindingService service =(BindingService)bindingService; BindingManager bindingManager = service.getBindingManager(); //service.getBindingManager(). Binding[] bindings = bindingManager.getBindings(); List<Binding> bindTemp = new ArrayList<Binding>(); List<String> ids = new ArrayList<String>(); for(Binding bind : bindings){ if(null ==bind){ continue; } ParameterizedCommand command = bind.getParameterizedCommand(); if(null == command){ continue; } String id = command.getId(); if(!ids.contains(id)){ ids.add(id); bindTemp.add(bind); } } bindingManager.setBindings(bindTemp.toArray(new Binding[ids.size()])); }
Example #29
Source File: KeyBindingHelper.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * @param commandId the command we want to know about * @return the 'best' key sequence that will activate the given command */ public static KeySequence getCommandKeyBinding(String commandId) { Assert.isNotNull(commandId); IBindingService bindingSvc; try { bindingSvc = PlatformUI.getWorkbench() .getAdapter(IBindingService.class); } catch (IllegalStateException e) { return null; } TriggerSequence keyBinding = bindingSvc.getBestActiveBindingFor(commandId); if (keyBinding instanceof KeySequence) { return (KeySequence) keyBinding; } List<Tuple<Binding, ParameterizedCommand>> matches = new ArrayList<Tuple<Binding, ParameterizedCommand>>(); //Ok, it may be that the binding we're looking for is not active, so, let's give a spin on all //the bindings Binding[] bindings = bindingSvc.getBindings(); for (Binding binding : bindings) { ParameterizedCommand command = binding.getParameterizedCommand(); if (command != null) { if (commandId.equals(command.getId())) { matches.add(new Tuple<Binding, ParameterizedCommand>(binding, command)); } } } for (Tuple<Binding, ParameterizedCommand> tuple : matches) { if (tuple.o1.getTriggerSequence() instanceof KeySequence) { KeySequence keySequence = (KeySequence) tuple.o1.getTriggerSequence(); return keySequence; } } return null; }
Example #30
Source File: CategoryPatternFilter.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
private ParameterizedCommand getCommand(Object element) { if (element instanceof BindingElement) { Object modelObject = ((BindingElement) element).getModelObject(); if (modelObject instanceof Binding) { return ((Binding) modelObject).getParameterizedCommand(); } else if (modelObject instanceof ParameterizedCommand) { return (ParameterizedCommand) modelObject; } } return null; }