Search in sources :

Example 1 with ContextManager

use of org.eclipse.core.commands.contexts.ContextManager in project translationstudio8 by heartsome.

the class KeyController2 method loadModelBackend.

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 {
        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] == bindingService.getActiveScheme()) {
                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", //$NON-NLS-1$
        e));
    }
    bindingManager.setLocale(bindingService.getLocale());
    bindingManager.setPlatform(bindingService.getPlatform());
    bindingManager.setBindings(bindingService.getBindings());
    return bindingManager;
}
Also used : BindingManager(org.eclipse.jface.bindings.BindingManager) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CommandManager(org.eclipse.core.commands.CommandManager) Scheme(org.eclipse.jface.bindings.Scheme) ContextManager(org.eclipse.core.commands.contexts.ContextManager) NotDefinedException(org.eclipse.core.commands.common.NotDefinedException) IBindingService(org.eclipse.ui.keys.IBindingService)

Aggregations

CommandManager (org.eclipse.core.commands.CommandManager)1 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)1 ContextManager (org.eclipse.core.commands.contexts.ContextManager)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 BindingManager (org.eclipse.jface.bindings.BindingManager)1 Scheme (org.eclipse.jface.bindings.Scheme)1 IBindingService (org.eclipse.ui.keys.IBindingService)1