Example usage for org.eclipse.jface.bindings.keys KeySequenceText getKeySequence

List of usage examples for org.eclipse.jface.bindings.keys KeySequenceText getKeySequence

Introduction

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

Prototype

public KeySequence getKeySequence() 

Source Link

Document

An accessor for the KeySequence that corresponds to the current state of the text field.

Usage

From source file:net.sourceforge.vrapper.plugin.bindingkeeper.preferences.KeySequenceInput.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {

    Composite composite = (Composite) super.createDialogArea(parent);

    getText().addFocusListener(new FocusListener() {
        @Override//from   w w w.j a v a  2  s . c o  m
        public void focusGained(FocusEvent e) {
            bindingService.setKeyFilterEnabled(false);
        }

        @Override
        public void focusLost(FocusEvent e) {
            bindingService.setKeyFilterEnabled(true);
        }
    });
    getText().addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(DisposeEvent e) {
            if (!bindingService.isKeyFilterEnabled()) {
                bindingService.setKeyFilterEnabled(true);
            }
        }
    });

    final KeySequenceText keySequenceText = new KeySequenceText(getText());
    keySequenceText.setKeyStrokeLimit(1);
    keySequenceText.addPropertyChangeListener(new IPropertyChangeListener() {
        @Override
        public final void propertyChange(final PropertyChangeEvent event) {
            if (!event.getOldValue().equals(event.getNewValue())) {
                final KeySequence keySequence = keySequenceText.getKeySequence();
                if (!keySequence.isComplete()) {
                    return;
                }

                getText().setSelection(getText().getTextLimit());
            }
        }
    });

    applyDialogFont(composite);
    return composite;

}