org.eclipse.ui.internal.keys.BindingService Java Examples
The following examples show how to use
org.eclipse.ui.internal.keys.BindingService.
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: KeyBindingHelper.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
public static void handleEvent(Event e) { IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); Listener keyDownFilter = ((BindingService) bindingService).getKeyboard().getKeyDownFilter(); boolean enabled = bindingService.isKeyFilterEnabled(); Control focusControl = e.display.getFocusControl(); try { bindingService.setKeyFilterEnabled(true); keyDownFilter.handleEvent(e); } finally { if (focusControl == e.display.getFocusControl()) // $codepro.audit.disable useEquals { bindingService.setKeyFilterEnabled(enabled); } } }
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: 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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
Source File: KbdMacroLoadHandler.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Check for binding conflicts independent of the current Eclipse context * If the load is called from a non-editing context, any potential binding conflict will * not be detected; so look for conflicts in a context independent set of bindings. * * @param service * @param sequence * @param binding */ private void checkConflicts(BindingService service, KeySequence sequence, Binding binding) { Collection<Binding> conflicts = getTotalBindings().get(sequence); if (conflicts != null) { for (Binding conflict : conflicts) { if (conflict != binding && binding.getContextId().equals(conflict.getContextId()) && binding.getSchemeId().equals(conflict.getSchemeId())) { service.removeBinding(conflict); } } } }
Example #10
Source File: EmacsPlusUtils.java From e4macs with Eclipse Public License 1.0 | 5 votes |
/** * Return the context free set of key bindings * * @return A map of trigger (<code>TriggerSequence</code>) to bindings ( * <code>Collection</code> containing <code>Binding</code>). * or an empty map */ public static Map<TriggerSequence,Collection<Binding>> getTotalBindings() { Map<TriggerSequence,Collection<Binding>> result = Collections.emptyMap(); BindingService bs = getBindingService(); if (bs != null) { @SuppressWarnings("unchecked") // @see org.eclipse.jface.bindings.BindingManager#getActiveBindingsDisregardingContext() Map<TriggerSequence,Collection<Binding>> bindings = getBindingManager(bs).getActiveBindingsDisregardingContext(); result = bindings; } return result; }
Example #11
Source File: KeybindingsManager.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private void initBindings() { WorkbenchJob workbenchJob = new WorkbenchJob("Installing KeybindingsManager") //$NON-NLS-1$ { @Override public IStatus runInUIThread(IProgressMonitor monitor) { loadbindings(); // Insert our key listener before the Eclipse's key listeners IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class); if (bindingService instanceof BindingService) { final BindingService theBindingService = (BindingService) bindingService; Display display = PlatformUI.getWorkbench().getDisplay(); final WorkbenchKeyboard keyboard = theBindingService.getKeyboard(); Listener keyDownFilter = keyboard.getKeyDownFilter(); try { if (keyDownFilter != null) { display.removeFilter(SWT.KeyDown, keyDownFilter); display.removeFilter(SWT.Traverse, keyDownFilter); } display.addFilter(SWT.KeyDown, listener); display.addFilter(SWT.Traverse, listener); } finally { if (keyDownFilter != null) { display.addFilter(SWT.KeyDown, keyDownFilter); display.addFilter(SWT.Traverse, keyDownFilter); } } } // Set the initial enabled state of KeybindingsManager IContextService contextService = (IContextService) workbench.getService(IContextService.class); contextService.addContextManagerListener(contextManagerListener); setEnabled(contextService.getActiveContextIds().contains(ScriptingUIPlugin.SCRIPTING_CONTEXT_ID)); return Status.OK_STATUS; } }; workbenchJob.setRule(MUTEX_RULE); EclipseUtil.setSystemForJob(workbenchJob); workbenchJob.setPriority(Job.LONG); workbenchJob.schedule(); }