Example usage for org.eclipse.jface.bindings.keys KeySequence getPrefixes

List of usage examples for org.eclipse.jface.bindings.keys KeySequence getPrefixes

Introduction

In this page you can find the example usage for org.eclipse.jface.bindings.keys KeySequence getPrefixes.

Prototype

@Override
    public final TriggerSequence[] getPrefixes() 

Source Link

Usage

From source file:com.aptana.scripting.keybindings.internal.KeybindingsManager.java

License:Open Source License

private void loadbindings() {
    resetState();/*from   w ww. j  a  v  a2s. com*/

    // Collect unique key sequences
    uniqueKeySequences.clear();
    uniqueKeySequencesPrefixes.clear();

    // Filter to commands with bindings
    IModelFilter filter = new IModelFilter() {

        public boolean include(AbstractElement element) {
            boolean result = false;

            if (element instanceof CommandElement) {
                CommandElement node = (CommandElement) element;
                String[] bindings = node.getKeyBindings();
                result = (bindings != null && bindings.length > 0);
            }

            return result;
        }
    };

    // Get all commands with bindings
    List<CommandElement> commands = bundleManager.getExecutableCommands(filter);
    for (CommandElement commandElement : commands) {
        // Get key sequences
        KeySequence[] keySequences = commandElement.getKeySequences();
        if (keySequences != null && keySequences.length > 0) {
            // Add to the set
            for (KeySequence keySequence : keySequences) {
                boolean added = uniqueKeySequences.add(keySequence);
                if (added && keySequence.getKeyStrokes().length > 1) {
                    // Collect prefixes - used to determine prefix matching of key sequences
                    TriggerSequence[] prefixes = keySequence.getPrefixes();
                    for (TriggerSequence triggerSequence : prefixes) {
                        KeySequence prefixKeySequence = (KeySequence) triggerSequence;
                        if (prefixKeySequence.getKeyStrokes().length > 0) {
                            uniqueKeySequencesPrefixes.add(prefixKeySequence);
                        }
                    }
                }
            }
        }
    }
}

From source file:com.aptana.scripting.ui.internal.KeybindingsManager.java

License:Open Source License

private void loadbindings() {
    resetState();// w ww  .  java  2s  . c  o m

    // Collect unique key sequences
    uniqueKeySequences.clear();
    uniqueKeySequencesPrefixes.clear();

    // Filter to commands with bindings
    IModelFilter filter = new IModelFilter() {

        public boolean include(AbstractElement element) {
            boolean result = false;

            if (element instanceof CommandElement) {
                CommandElement node = (CommandElement) element;
                String[] bindings = node.getKeyBindings();
                result = (bindings != null && bindings.length > 0);
            }

            return result;
        }
    };

    // Get all commands with bindings
    List<CommandElement> commands = bundleManager.getExecutableCommands(filter);
    for (CommandElement commandElement : commands) {
        // Get key sequences
        KeySequence[] keySequences = KeyBindingUtil.getKeySequences(commandElement);
        if (keySequences != null && keySequences.length > 0) {
            // Add to the set
            for (KeySequence keySequence : keySequences) {
                boolean added = uniqueKeySequences.add(keySequence);
                if (added && keySequence.getKeyStrokes().length > 1) {
                    // Collect prefixes - used to determine prefix matching of key sequences
                    TriggerSequence[] prefixes = keySequence.getPrefixes();
                    for (TriggerSequence triggerSequence : prefixes) {
                        KeySequence prefixKeySequence = (KeySequence) triggerSequence;
                        if (prefixKeySequence.getKeyStrokes().length > 0) {
                            uniqueKeySequencesPrefixes.add(prefixKeySequence);
                        }
                    }
                }
            }
        }
    }
}