/** * Checks if for the current action a keyboard shortcut can be configured. * * @param actionDesc * ActionDesc for the current action. Not null. * @return true, if the current action has at least one ParameterizedCommand * (only those are listed in the keys preference page), false else. */ @SuppressWarnings({ "rawtypes", "unchecked" }) protected boolean isConfigurableAction(final AbstractActionDesc actionDesc) { final String actionId = actionDesc.getId(); final Command command = commandService.getCommand(actionId); if (command != null) { final HashSet allParameterizedCommands = new HashSet(); try { allParameterizedCommands.addAll(ParameterizedCommand .generateCombinations(command)); } catch (final NotDefinedException e) { // It is safe to just ignore undefined commands. } return !allParameterizedCommands.isEmpty(); } return false; }
/** * Handle link activation. */ @SuppressWarnings({ "rawtypes", "unchecked" }) final void doLinkActivated() { Object data = null; final IWorkbench workbench = Activator.getDefault().getWorkbench(); final ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class); final Command command = commandService.getCommand(actionId); if (command != null) { final HashSet allParameterizedCommands = new HashSet(); try { allParameterizedCommands.addAll(ParameterizedCommand .generateCombinations(command)); } catch (final NotDefinedException e) { // It is safe to just ignore undefined commands. } if (!allParameterizedCommands.isEmpty()) { data = allParameterizedCommands.iterator().next(); // only commands can be bound to keyboard shortcuts openWorkspacePreferences(data); } } }
private void retrieveCommand(final String currentCommandId) { boolean commandRetrieved = idToCommand.containsKey(currentCommandId); if (!commandRetrieved) { ICommandService commandService = getCommandService(); EHandlerService ehandlerService = getEHandlerService(); final Command command = commandService.getCommand(currentCommandId); ParameterizedCommand pcmd = new ParameterizedCommand(command, null); if (command != null && ehandlerService.canExecute(pcmd)) { try { Collection<?> combinations = ParameterizedCommand.generateCombinations(command); for (Iterator<?> it = combinations.iterator(); it.hasNext();) { ParameterizedCommand pc = (ParameterizedCommand) it.next(); String id = pc.serialize(); synchronized (idToCommand) { idToCommand.put(id, new CommandElement(pc, id, this)); } } } catch (final NotDefinedException e) { // It is safe to just ignore undefined commands. } } } }
try { allParameterizedCommands.addAll(ParameterizedCommand .generateCombinations(currentCommand)); } catch (final NotDefinedException e) {
try { commands.addAll(ParameterizedCommand .generateCombinations(currentCommand)); } catch (final NotDefinedException e) {