Java Code Examples for org.eclipse.jface.bindings.Binding#getParameterizedCommand()
The following examples show how to use
org.eclipse.jface.bindings.Binding#getParameterizedCommand() .
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: 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 2
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 3
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 4
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 5
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 6
Source File: KeyController2.java From translationstudio8 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 7
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 8
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 9
Source File: KeyBindings.java From workspacemechanic with Eclipse Public License 1.0 | 5 votes |
/** * Finds a binding in {@code list} that matches the given * {@code triggerSequence}, {@code scheme} and {@code cid}. If not found, * return {@code null}. */ private static Binding find( Scheme scheme, String platform, KeySequence triggerSequence, String cid, Map<String,String> params, List<Binding> list) { for (Binding binding : list) { if (binding.getSchemeId().equals(scheme.getId()) && (binding.getTriggerSequence().equals(triggerSequence)) && Objects.equal(binding.getPlatform(), platform)) { ParameterizedCommand param = binding.getParameterizedCommand(); if (param == null) { if (cid == null) { return binding; } continue; } Command command = param.getCommand(); if (cid == null) { return command == null ? binding : null; } if (cid.equals(command.getId())) { Map<String,String> temp = commandParamMap(param); if (equalMaps(temp, params)) { return binding; } } } } return null; }
Example 10
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 11
Source File: EmacsHelpHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { EmacsPlusConsole console = EmacsPlusConsole.getInstance(); console.clear(); console.activate(); IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class); String id = (event.getCommand() != null ? event.getCommand().getId() : null); if (id != null) { try { TriggerSequence trigger = bindingService.getBestActiveBindingFor(event.getCommand().getId()); Trigger[] trigs = trigger.getTriggers(); KeyStroke key = (KeyStroke)trigs[0]; Collection<Binding> partials = EmacsPlusUtils.getPartialMatches(bindingService,KeySequence.getInstance(key)).values(); for (Binding bind : partials) { ParameterizedCommand cmd = bind.getParameterizedCommand(); if (cmd.getId().startsWith(EmacsPlusUtils.MULGASOFT)) { console.printBold(bind.getTriggerSequence().toString()); console.print(SWT.TAB + cmd.getCommand().getName()); String desc = cmd.getCommand().getDescription(); if (desc != null) { desc = desc.replaceAll(CR, EMPTY_STR); console.print(" - " + desc + CR); //$NON-NLS-1$ } else { console.print(CR); } } } } catch (Exception e) {} console.setFocus(true); } return null; }
Example 12
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 13
Source File: BindingModel2.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * Removes the <code>bindingElement</code> binding. * @param bindingElement */ public void remove(BindingElement bindingElement) { if (bindingElement == null || !(bindingElement.getModelObject() instanceof Binding)) { return; } KeyBinding keyBinding = (KeyBinding) bindingElement.getModelObject(); if (keyBinding.getType() == Binding.USER) { bindingManager.removeBinding(keyBinding); } else { KeySequence keySequence = keyBinding.getKeySequence(); // Add the delete binding bindingManager.addBinding(new KeyBinding(keySequence, null, keyBinding.getSchemeId(), keyBinding .getContextId(), null, null, null, Binding.USER)); // Unbind any conflicts affected by the delete binding ConflictModel conflictModel = controller.getConflictModel(); conflictModel.updateConflictsFor(bindingElement); Collection conflictsList = conflictModel.getConflicts(); if (conflictsList != null) { Object[] conflicts = conflictsList.toArray(); for (int i = 0; i < conflicts.length; i++) { BindingElement be = (BindingElement) conflicts[i]; if (be == bindingElement) { continue; } Object modelObject = be.getModelObject(); if (modelObject instanceof Binding) { Binding binding = (Binding) modelObject; if (binding.getType() != Binding.SYSTEM) { continue; } ParameterizedCommand pCommand = binding.getParameterizedCommand(); be.fill(pCommand); commandToElement.put(pCommand, be); } } } } ParameterizedCommand parameterizedCommand = keyBinding.getParameterizedCommand(); bindingElement.fill(parameterizedCommand); commandToElement.put(parameterizedCommand, bindingElement); controller.firePropertyChange(this, PROP_CONFLICT_ELEMENT_MAP, null, bindingElement); }
Example 14
Source File: CommandDescribeHandler.java From e4macs with Eclipse Public License 1.0 | 4 votes |
ParameterizedCommand getPCommand(Binding binding) { return binding.getParameterizedCommand(); }
Example 15
Source File: BindingModel2.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
/** * Removes the <code>bindingElement</code> binding. * @param bindingElement */ public void remove(BindingElement bindingElement) { if (bindingElement == null || !(bindingElement.getModelObject() instanceof Binding)) { return; } KeyBinding keyBinding = (KeyBinding) bindingElement.getModelObject(); if (keyBinding.getType() == Binding.USER) { bindingManager.removeBinding(keyBinding); } else { KeySequence keySequence = keyBinding.getKeySequence(); // Add the delete binding bindingManager.addBinding(new KeyBinding(keySequence, null, keyBinding.getSchemeId(), keyBinding .getContextId(), null, null, null, Binding.USER)); // Unbind any conflicts affected by the delete binding ConflictModel conflictModel = controller.getConflictModel(); conflictModel.updateConflictsFor(bindingElement); Collection conflictsList = conflictModel.getConflicts(); if (conflictsList != null) { Object[] conflicts = conflictsList.toArray(); for (int i = 0; i < conflicts.length; i++) { BindingElement be = (BindingElement) conflicts[i]; if (be == bindingElement) { continue; } Object modelObject = be.getModelObject(); if (modelObject instanceof Binding) { Binding binding = (Binding) modelObject; if (binding.getType() != Binding.SYSTEM) { continue; } ParameterizedCommand pCommand = binding.getParameterizedCommand(); be.fill(pCommand); commandToElement.put(pCommand, be); } } } } ParameterizedCommand parameterizedCommand = keyBinding.getParameterizedCommand(); bindingElement.fill(parameterizedCommand); commandToElement.put(parameterizedCommand, bindingElement); controller.firePropertyChange(this, PROP_CONFLICT_ELEMENT_MAP, null, bindingElement); }
Example 16
Source File: BindingModel2.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
/** * Removes the <code>bindingElement</code> binding. * @param bindingElement */ public void remove(BindingElement bindingElement) { if (bindingElement == null || !(bindingElement.getModelObject() instanceof Binding)) { return; } KeyBinding keyBinding = (KeyBinding) bindingElement.getModelObject(); if (keyBinding.getType() == Binding.USER) { bindingManager.removeBinding(keyBinding); } else { KeySequence keySequence = keyBinding.getKeySequence(); // Add the delete binding bindingManager.addBinding(new KeyBinding(keySequence, null, keyBinding.getSchemeId(), keyBinding .getContextId(), null, null, null, Binding.USER)); // Unbind any conflicts affected by the delete binding ConflictModel conflictModel = controller.getConflictModel(); conflictModel.updateConflictsFor(bindingElement); Collection conflictsList = conflictModel.getConflicts(); if (conflictsList != null) { Object[] conflicts = conflictsList.toArray(); for (int i = 0; i < conflicts.length; i++) { BindingElement be = (BindingElement) conflicts[i]; if (be == bindingElement) { continue; } Object modelObject = be.getModelObject(); if (modelObject instanceof Binding) { Binding binding = (Binding) modelObject; if (binding.getType() != Binding.SYSTEM) { continue; } ParameterizedCommand pCommand = binding.getParameterizedCommand(); be.fill(pCommand); commandToElement.put(pCommand, be); } } } } ParameterizedCommand parameterizedCommand = keyBinding.getParameterizedCommand(); bindingElement.fill(parameterizedCommand); commandToElement.put(parameterizedCommand, bindingElement); controller.firePropertyChange(this, PROP_CONFLICT_ELEMENT_MAP, null, bindingElement); }
Example 17
Source File: FindBarActions.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * @return a map with the commands -> bindings available. */ public HashMap<String, List<TriggerSequence>> getCommandToBindings() { HashMap<String, List<TriggerSequence>> commandToBinding = new HashMap<String, List<TriggerSequence>>(); IWorkbenchPartSite site = textEditor.getSite(); IBindingService service = (IBindingService) site.getService(IBindingService.class); Binding[] bindings = service.getBindings(); for (int i = 0; i < bindings.length; i++) { Binding binding = bindings[i]; ParameterizedCommand command = binding.getParameterizedCommand(); if (command != null) { String id = command.getId(); // Filter only the actions we decided would be active. // // Note: we don't just make all actions active because they conflict with the find bar // expected accelerators, so, things as Alt+W don't work -- even a second Ctrl+F isn't properly // treated as specified in the options. // A different option could be filtering those out and let everything else enabled, // but this would need to be throughly tested to know if corner-cases work. if (fCommandToHandler.containsKey(id)) { List<TriggerSequence> list = commandToBinding.get(id); if (list == null) { list = new ArrayList<TriggerSequence>(); commandToBinding.put(id, list); } list.add(binding.getTriggerSequence()); } // Uncomment to know which actions will be disabled // else // { // try // { // System.out.println("Command disabled: " + id + ": " + command.getName()); // } // catch (NotDefinedException e) // { // // } // } } } return commandToBinding; }
Example 18
Source File: EclBinding.java From workspacemechanic with Eclipse Public License 1.0 | 4 votes |
private static String calculateCid(Binding b) { ParameterizedCommand parameterizedCommand = b.getParameterizedCommand(); return parameterizedCommand == null ? null : parameterizedCommand.getId(); }