Example usage for org.eclipse.jface.bindings BindingManager removeBindings

List of usage examples for org.eclipse.jface.bindings BindingManager removeBindings

Introduction

In this page you can find the example usage for org.eclipse.jface.bindings BindingManager removeBindings.

Prototype

public void removeBindings(final TriggerSequence sequence, final String schemeId, final String contextId,
        final String locale, final String platform, final String windowManager, final int type) 

Source Link

Document

Removes any binding that matches the given values -- regardless of command identifier.

Usage

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  av a  2s. co 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 disableKeys() {
    if (!keysDisabled) {
        logger.debug("Disabling conflicting keybindings while vim editor is focused: " + Arrays.toString(keys));
        BindingManager localChangeManager = getLocalChangeManager();
        String schemeId = localChangeManager.getActiveScheme().getId();
        for (KeySequence keySequence : keySequences) {
            for (String contextId : CONTEXT_IDS) {
                localChangeManager.removeBindings(keySequence, schemeId, contextId, null, null, null,
                        Binding.USER);
                localChangeManager.addBinding(
                        new KeyBinding(keySequence, null, schemeId, contextId, null, null, null, Binding.USER));
            }/*from  ww w.j  av a2 s .co m*/
        }
        keysDisabled = true;
        saveKeyChanges(localChangeManager);
    }
}

From source file:org.vimplugin.editors.VimEditorPartListener.java

License:Open Source License

private void enableKeys() {
    if (keysDisabled) {
        logger.debug("Re-enabling conflicting keybindings.");
        BindingManager localChangeManager = getLocalChangeManager();
        String schemeId = localChangeManager.getActiveScheme().getId();
        for (KeySequence keySequence : keySequences) {
            for (String contextId : CONTEXT_IDS) {
                localChangeManager.removeBindings(keySequence, schemeId, contextId, null, null, null,
                        Binding.USER);
            }/*from w  w w.  j a  v a 2s  .c o m*/
        }
        keysDisabled = false;
        saveKeyChanges(localChangeManager);
    }
}