Java 类org.eclipse.core.commands.contexts.ContextManager 实例源码

项目:translationstudio8    文件:KeyController2.java   
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", e)); //$NON-NLS-1$
    }
    bindingManager.setLocale(bindingService.getLocale());
    bindingManager.setPlatform(bindingService.getPlatform());
    bindingManager.setBindings(bindingService.getBindings());
    return bindingManager;
}
项目:gef-gwt    文件:BindingManager.java   
/**
 * <p>
 * Constructs a new instance of <code>BindingManager</code>.
 * </p>
 * <p>
 * This method completes in amortized constant time (O(1)).
 * </p>
 * 
 * @param contextManager
 *            The context manager that will support this binding manager.
 *            This value must not be <code>null</code>.
 * @param commandManager
 *            The command manager that will support this binding manager.
 *            This value must not be <code>null</code>.
 */
public BindingManager(final ContextManager contextManager,
        final CommandManager commandManager) {
    if (contextManager == null) {
        throw new NullPointerException(
                "A binding manager requires a context manager"); //$NON-NLS-1$
    }

    if (commandManager == null) {
        throw new NullPointerException(
                "A binding manager requires a command manager"); //$NON-NLS-1$
    }

    this.contextManager = contextManager;
    contextManager.addContextManagerListener(this);
    this.commandManager = commandManager;
}
项目:tmxeditor8    文件:KeyController2.java   
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", e)); //$NON-NLS-1$
    }
    bindingManager.setLocale(bindingService.getLocale());
    bindingManager.setPlatform(bindingService.getPlatform());
    bindingManager.setBindings(bindingService.getBindings());
    return bindingManager;
}
项目:tmxeditor8    文件:KeyController2.java   
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", e)); //$NON-NLS-1$
    }
    bindingManager.setLocale(bindingService.getLocale());
    bindingManager.setPlatform(bindingService.getPlatform());
    bindingManager.setBindings(bindingService.getBindings());
    return bindingManager;
}
项目:relations    文件:BindingModelTest.java   
/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    contextManager = new ContextManager();
    commandManager = new CommandManager();
    bindings = new ArrayList<Binding>();

    command1 = commandManager.getCommand(COMMAND_IDS[0]);
    command2 = commandManager.getCommand(COMMAND_IDS[1]);
    command3 = commandManager.getCommand(COMMAND_IDS[2]);
    bindings.add(createBinding(command1, "a", KeySequence.getInstance("M1+A")));
    bindings.add(createBinding(command2, "b", KeySequence.getInstance("M1+B")));
    bindings.add(createBinding(command3, "c", KeySequence.getInstance("M1+C")));

    bindingManager = new BindingManager(contextManager, commandManager);
    bindingManager.addBinding(bindings.get(0));
    bindingManager.addBinding(bindings.get(1));
    bindingManager.addBinding(bindings.get(2));
    final Scheme scheme = bindingManager.getScheme("default");
    scheme.define("myScheme1", "My scheme for testing", null);
    bindingManager.setActiveScheme(scheme);
}
项目:relations    文件:KeyControllerTest.java   
@Before
public void setUp() throws Exception {
    contextManager = new ContextManager();
    commandManager = new CommandManager();
    bindingManager = new BindingManager(contextManager, commandManager);
    MockitoAnnotations.initMocks(this);

    final Scheme scheme = bindingManager.getScheme(SCHEME_ID);
    scheme.define("scheme:name", "scheme:description", null);
    bindingManager.setActiveScheme(scheme);
    bindingManager.schemeChanged(new SchemeEvent(scheme, true, false, false, false));
    inject(keyController, "commandManager", commandManager);
    inject(keyController, "bindingManagerApp", bindingManager);
}
项目:relations    文件:KeyController.java   
private BindingManager loadModelBackend() {
    final BindingManager outManager = new BindingManager(
            new ContextManager(), new CommandManager());
    final Scheme[] definedSchemes = bindingManagerApp.getDefinedSchemes();
    try {
        Scheme modelActiveScheme = null;
        for (int i = 0; i < definedSchemes.length; i++) {
            final Scheme scheme = definedSchemes[i];
            final Scheme copy = outManager.getScheme(scheme.getId());
            copy.define(scheme.getName(), scheme.getDescription(),
                    scheme.getParentId());
            if (definedSchemes[i].getId()
                    .equals(bindingManagerApp.getActiveScheme().getId())) {
                modelActiveScheme = copy;
            }
        }
        outManager.setActiveScheme(modelActiveScheme);
    }
    catch (final NotDefinedException exc) {
        log.error(exc, exc.getMessage());
    }
    outManager.setLocale(bindingManagerApp.getLocale());
    outManager.setPlatform(bindingManagerApp.getPlatform());
    // fill bindings from bindingService to bindingManager instance
    outManager.setBindings(getBindingsFromSrc());
    return outManager;
}