Search in sources :

Example 1 with BindingManager

use of org.eclipse.jface.bindings.BindingManager in project translationstudio8 by heartsome.

the class KeyController2 method filterDupliteBind.

@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()]));
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) BindingManager(org.eclipse.jface.bindings.BindingManager) KeyBinding(org.eclipse.jface.bindings.keys.KeyBinding) Binding(org.eclipse.jface.bindings.Binding) IBindingService(org.eclipse.ui.keys.IBindingService) BindingService(org.eclipse.ui.internal.keys.BindingService) ArrayList(java.util.ArrayList) IBindingService(org.eclipse.ui.keys.IBindingService) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand)

Example 2 with BindingManager

use of org.eclipse.jface.bindings.BindingManager 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

BindingManager (org.eclipse.jface.bindings.BindingManager)2 IBindingService (org.eclipse.ui.keys.IBindingService)2 ArrayList (java.util.ArrayList)1 CommandManager (org.eclipse.core.commands.CommandManager)1 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)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 Binding (org.eclipse.jface.bindings.Binding)1 Scheme (org.eclipse.jface.bindings.Scheme)1 KeyBinding (org.eclipse.jface.bindings.keys.KeyBinding)1 IWorkbench (org.eclipse.ui.IWorkbench)1 BindingService (org.eclipse.ui.internal.keys.BindingService)1