List of usage examples for org.eclipse.jface.bindings BindingManager setActiveScheme
public void setActiveScheme(final Scheme scheme) throws NotDefinedException
Selects one of the schemes as the active scheme.
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 .java2 s. c om*/ */ 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.eclipse.ui.internal.keys.BindingPersistence.java
License:Open Source License
/** * <p>/* www . jav a 2 s . co m*/ * Reads the registry and the preference store, and determines the * identifier for the scheme that should be active. There is a complicated * order of priorities for this. The registry will only be read if there is * no user preference, and the default active scheme id is different than * the default default active scheme id. * </p> * <ol> * <li>A non-default preference.</li> * <li>The legacy preference XML memento.</li> * <li>A default preference value that is different than the default * default active scheme id.</li> * <li>The registry.</li> * <li>The default default active scheme id.</li> * </ol> * * @param configurationElements * The configuration elements from the commands extension point; * must not be <code>null</code>. * @param configurationElementCount * The number of configuration elements that are really in the * array. * @param preferences * The memento wrapping the commands preference key; may be * <code>null</code>. * @param bindingManager * The binding manager that should be updated with the active * scheme. This binding manager must already have its schemes * defined. This value must not be <code>null</code>. */ private static final void readActiveScheme(final IConfigurationElement[] configurationElements, final int configurationElementCount, final IMemento preferences, final BindingManager bindingManager) { // A non-default preference. final IPreferenceStore store = PlatformUI.getPreferenceStore(); final String defaultActiveSchemeId = store .getDefaultString(IWorkbenchPreferenceConstants.KEY_CONFIGURATION_ID); final String preferenceActiveSchemeId = store.getString(IWorkbenchPreferenceConstants.KEY_CONFIGURATION_ID); if ((preferenceActiveSchemeId != null) && (!preferenceActiveSchemeId.equals(defaultActiveSchemeId))) { try { bindingManager.setActiveScheme(bindingManager.getScheme(preferenceActiveSchemeId)); return; } catch (final NotDefinedException e) { // Let's keep looking.... } } // A legacy preference XML memento. if (preferences != null) { final IMemento[] preferenceMementos = preferences.getChildren(TAG_ACTIVE_KEY_CONFIGURATION); int preferenceMementoCount = preferenceMementos.length; for (int i = preferenceMementoCount - 1; i >= 0; i--) { final IMemento memento = preferenceMementos[i]; String id = memento.getString(ATT_KEY_CONFIGURATION_ID); if (id != null) { try { bindingManager.setActiveScheme(bindingManager.getScheme(id)); return; } catch (final NotDefinedException e) { // Let's keep looking.... } } } } // A default preference value that is different than the default. if ((defaultActiveSchemeId != null && defaultActiveSchemeId.length() > 0) && (!defaultActiveSchemeId.equals(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID))) { try { bindingManager.setActiveScheme(bindingManager.getScheme(defaultActiveSchemeId)); return; } catch (final NotDefinedException e) { // Let's keep looking.... } } // The registry. for (int i = configurationElementCount - 1; i >= 0; i--) { final IConfigurationElement configurationElement = configurationElements[i]; String id = configurationElement.getAttribute(ATT_KEY_CONFIGURATION_ID); if (id != null) { try { bindingManager.setActiveScheme(bindingManager.getScheme(id)); return; } catch (final NotDefinedException e) { // Let's keep looking.... } } id = configurationElement.getAttribute(ATT_VALUE); if (id != null) { try { bindingManager.setActiveScheme(bindingManager.getScheme(id)); return; } catch (final NotDefinedException e) { // Let's keep looking.... } } } // The default default active scheme id. try { bindingManager .setActiveScheme(bindingManager.getScheme(IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID)); } catch (final NotDefinedException e) { //this is bad - the default default scheme should always exist throw new Error("The default default active scheme id is not defined."); //$NON-NLS-1$ } }
From source file:org.eclipse.ui.internal.keys.model.KeyController.java
License:Open Source License
private static BindingManager loadModelBackend(IServiceLocator locator) { IBindingService bindingService = (IBindingService) locator.getService(IBindingService.class); BindingManager bindingManager = new BindingManager(new ContextManager(), new CommandManager()); final Scheme[] definedSchemes = bindingService.getDefinedSchemes(); try {/*from w w w .j av a 2 s.com*/ Scheme modelActiveScheme = null; for (int i = 0; i < definedSchemes.length; i++) { final Scheme scheme = definedSchemes[i]; final Scheme copy = bindingManager.getScheme(scheme.getId()); copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId()); if (definedSchemes[i].getId().equals(bindingService.getActiveScheme().getId())) { modelActiveScheme = copy; } } bindingManager.setActiveScheme(modelActiveScheme); } catch (final NotDefinedException e) { StatusManager.getManager().handle(new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH, "Keys page found an undefined scheme", e)); //$NON-NLS-1$ } bindingManager.setLocale(bindingService.getLocale()); bindingManager.setPlatform(bindingService.getPlatform()); bindingManager.setBindings(bindingService.getBindings()); return bindingManager; }
From source file:org.limy.eclipse.qalab.action.KeyBindAction.java
License:Open Source License
/** * L?[oChRs?[???B/* w w w . j a v a2 s. c o m*/ * @param bindingService * @return * @throws NotDefinedException */ private BindingManager createLocalManager(IBindingService bindingService) throws NotDefinedException { BindingManager localChangeManager = new BindingManager(new ContextManager(), new CommandManager()); Scheme[] definedSchemes = bindingService.getDefinedSchemes(); // Make an internal copy of the binding manager, for local changes. for (int i = 0; i < definedSchemes.length; i++) { Scheme scheme = definedSchemes[i]; Scheme copy = localChangeManager.getScheme(scheme.getId()); copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId()); } localChangeManager.setActiveScheme(bindingService.getActiveScheme()); localChangeManager.setLocale(bindingService.getLocale()); localChangeManager.setPlatform(bindingService.getPlatform()); localChangeManager.setBindings(bindingService.getBindings()); return localChangeManager; }
From source file:org.netxms.ui.eclipse.console.ApplicationWorkbenchWindowAdvisor.java
License:Open Source License
@Override public void postWindowCreate() { super.postWindowCreate(); NXCSession session = (NXCSession) ConsoleSharedData.getSession(); // Changes the page title at runtime JavaScriptExecutor executor = RWT.getClient().getService(JavaScriptExecutor.class); if (executor != null) { StringBuilder js = new StringBuilder(); js.append("document.title = "); //$NON-NLS-1$ js.append("\""); js.append(BrandingManager.getInstance().getProductName()); js.append(" - ["); js.append(session.getUserName()); js.append("@"); js.append(session.getServerAddress()); js.append("]"); js.append("\""); executor.execute(js.toString()); }/*from w ww . j a v a 2s . com*/ BindingService service = (BindingService) getWindowConfigurer().getWindow().getWorkbench() .getService(IBindingService.class); BindingManager bindingManager = service.getBindingManager(); try { bindingManager.setActiveScheme(service.getScheme("org.netxms.ui.eclipse.defaultKeyBinding")); //$NON-NLS-1$ } catch (NotDefinedException e) { e.printStackTrace(); } final Shell shell = getWindowConfigurer().getWindow().getShell(); shell.setMaximized(true); for (Control ctrl : shell.getChildren()) { ctrl.setData(RWT.CUSTOM_VARIANT, "gray"); //$NON-NLS-1$ if (ctrl instanceof CBanner) { for (Control cc : ((CBanner) ctrl).getChildren()) cc.setData(RWT.CUSTOM_VARIANT, "gray"); //$NON-NLS-1$ } else if (ctrl.getClass().getName().equals("org.eclipse.swt.widgets.Composite")) //$NON-NLS-1$ { for (Control cc : ((Composite) ctrl).getChildren()) cc.setData(RWT.CUSTOM_VARIANT, "gray"); //$NON-NLS-1$ } } Menu menuBar = shell.getMenuBar(); if (menuBar != null) menuBar.setData(RWT.CUSTOM_VARIANT, "menuBar"); //$NON-NLS-1$ }
From source file:org.netxms.webui.mobile.MobileApplicationWorkbenchWindowAdvisor.java
License:Open Source License
@Override public void postWindowCreate() { super.postWindowCreate(); BindingService service = (BindingService) getWindowConfigurer().getWindow().getWorkbench() .getService(IBindingService.class); BindingManager bindingManager = service.getBindingManager(); try {/*from ww w . j av a2s. c o m*/ bindingManager.setActiveScheme(service.getScheme("org.netxms.ui.eclipse.defaultKeyBinding")); //$NON-NLS-1$ } catch (NotDefinedException e) { e.printStackTrace(); } final Shell shell = getWindowConfigurer().getWindow().getShell(); shell.setMaximized(true); for (Control ctrl : shell.getChildren()) { ctrl.setData(RWT.CUSTOM_VARIANT, "gray"); //$NON-NLS-1$ if (ctrl instanceof CBanner) { for (Control cc : ((CBanner) ctrl).getChildren()) cc.setData(RWT.CUSTOM_VARIANT, "gray"); //$NON-NLS-1$ } else if (ctrl.getClass().getName().equals("org.eclipse.swt.widgets.Composite")) //$NON-NLS-1$ { for (Control cc : ((Composite) ctrl).getChildren()) cc.setData(RWT.CUSTOM_VARIANT, "gray"); //$NON-NLS-1$ } } shell.getMenuBar().setData(RWT.CUSTOM_VARIANT, "menuBar"); //$NON-NLS-1$ }
From source file:org.vimplugin.editors.VimEditorPartListener.java
License:Open Source License
private BindingManager getLocalChangeManager() { BindingManager manager = new BindingManager(new ContextManager(), new CommandManager()); Scheme scheme = bindingService.getActiveScheme(); try {/*from www . ja v a 2 s . c o m*/ try { manager.setActiveScheme(scheme); } catch (NotDefinedException nde) { // KeysPreferencePage ignores this error as well... hmmm } manager.setLocale(bindingService.getLocale()); manager.setPlatform(bindingService.getPlatform()); manager.setBindings(bindingService.getBindings()); } catch (Exception e) { logger.error("Error initializing local binding manager.", e); } return manager; }