List of usage examples for org.eclipse.jface.bindings BindingManager getBindings
public Binding[] getBindings()
Returns the set of all bindings managed by this class.
From source file:org.csstudio.iter.css.product.util.WorkbenchUtil.java
License:Open Source License
/** * Unbind F11 KeyBinding of org.eclipse.debug.ui to avoid conflict with * org.csstudio.opibuilder plugin// w w w . j a v a 2 s . c o m */ public static void unbindDebugLast() { IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench() .getAdapter(IBindingService.class); BindingManager localChangeManager = new BindingManager(new ContextManager(), new CommandManager()); final Scheme[] definedSchemes = bindingService.getDefinedSchemes(); try { for (int i = 0; i < definedSchemes.length; i++) { final Scheme scheme = definedSchemes[i]; final Scheme copy = localChangeManager.getScheme(scheme.getId()); copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId()); } localChangeManager.setActiveScheme(bindingService.getActiveScheme()); } catch (final NotDefinedException e) { e.printStackTrace(); } localChangeManager.setLocale(bindingService.getLocale()); localChangeManager.setPlatform(bindingService.getPlatform()); localChangeManager.setBindings(bindingService.getBindings()); KeyBinding opiFullScreenBinding = null; int nbBinding = 0; Binding[] bArray = bindingService.getBindings(); if (bArray != null) { for (Binding binding : bArray) { if (binding instanceof KeyBinding) { KeyBinding kBind = (KeyBinding) binding; if (kBind.getParameterizedCommand() != null && kBind.getParameterizedCommand().getCommand() != null) { if ("org.eclipse.debug.ui.commands.DebugLast" .equals(kBind.getParameterizedCommand().getCommand().getId())) { KeySequence triggerSequence = kBind.getKeySequence(); String contextId = kBind.getContextId(); String schemeId = kBind.getSchemeId(); KeyBinding deleteBinding = new KeyBinding(triggerSequence, null, schemeId, contextId, null, null, null, Binding.USER); localChangeManager.addBinding(deleteBinding); try { bindingService.savePreferences(localChangeManager.getActiveScheme(), localChangeManager.getBindings()); } catch (IOException e) { e.printStackTrace(); } } else if ("org.csstudio.opibuilder.actions.fullscreen" .equals(kBind.getParameterizedCommand().getCommand().getId())) { if (opiFullScreenBinding == null) opiFullScreenBinding = kBind; nbBinding++; } } } } } // Rebind OPI runner full screen command if it exists only one time if (nbBinding == 1) { KeySequence triggerSequence = opiFullScreenBinding.getKeySequence(); String contextId = opiFullScreenBinding.getContextId(); String schemeId = opiFullScreenBinding.getSchemeId(); KeyBinding updateBinding = new KeyBinding(triggerSequence, opiFullScreenBinding.getParameterizedCommand(), schemeId, contextId, null, null, null, Binding.USER); localChangeManager.addBinding(updateBinding); try { bindingService.savePreferences(localChangeManager.getActiveScheme(), localChangeManager.getBindings()); } catch (IOException e) { e.printStackTrace(); } } }
From source file:org.limy.eclipse.qalab.action.KeyBindAction.java
License:Open Source License
@Override public void doRun(ISelection selection, IProgressMonitor monitor) throws CoreException { IBindingService bindingService = (IBindingService) getWindow().getWorkbench() .getService(IBindingService.class); KeybindWindow keyWindow = new KeybindWindow(getWindow().getShell(), bindingService); keyWindow.setBlockOnOpen(true);//from w w w .j a va 2s .c o m keyWindow.open(); Map<Binding, KeySequence> results = keyWindow.getResults(); if (results != null) { BindingManager localChangeManager; try { localChangeManager = createLocalManager(bindingService); } catch (NotDefinedException e) { throw new WorkbenchException(e.getMessage(), e); } Binding[] bindings = bindingService.getBindings(); for (Entry<Binding, KeySequence> entry : results.entrySet()) { Binding systemBinding = entry.getKey(); String contextId = systemBinding.getContextId(); String schemeId = systemBinding.getSchemeId(); String commandId = systemBinding.getParameterizedCommand().getId(); // L?[oCh?? for (Binding binding : bindings) { ParameterizedCommand command = binding.getParameterizedCommand(); if (command != null && commandId.equals(command.getId()) && binding.getType() == Binding.USER) { localChangeManager.removeBindings(binding.getTriggerSequence(), schemeId, contextId, null, null, null, Binding.USER); } } // L?[oCho^ final ParameterizedCommand command = systemBinding.getParameterizedCommand(); localChangeManager.addBinding(new KeyBinding(entry.getValue(), command, schemeId, contextId, null, null, null, Binding.USER)); } try { bindingService.savePreferences(localChangeManager.getActiveScheme(), localChangeManager.getBindings()); } catch (IOException e) { LimyEclipsePluginUtils.log(e); } } }
From source file:org.vimplugin.editors.VimEditorPartListener.java
License:Open Source License
private void saveKeyChanges(BindingManager localChangeManager) { try {//from w w w . j a v a 2 s. co m bindingService.savePreferences(localChangeManager.getActiveScheme(), localChangeManager.getBindings()); } catch (Exception e) { logger.error("Error persisting key bindings.", e); } }