Search in sources :

Example 1 with KeySequenceText

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

the class PluginConfigManageDialog method createShortcutKeyGoup.

/**
	 * 创建快捷键面板
	 * @param tparent
	 *            ;
	 */
private void createShortcutKeyGoup(Composite tparent) {
    Group group = new Group(tparent, SWT.None);
    group.setText(Messages.getString("dialog.PluginConfigManageDialog.group"));
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(group);
    GridLayoutFactory.swtDefaults().numColumns(2).applyTo(group);
    Label keyLbl = new Label(group, SWT.NONE);
    keyLbl.setText(Messages.getString("dialog.PluginConfigManageDialog.keyLbl"));
    keyTxt = new Text(group, SWT.BORDER);
    GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(keyTxt);
    fKeySequenceText = new KeySequenceText(keyTxt);
    fKeySequenceText.setKeyStrokeLimit(4);
    fKeySequenceText.addPropertyChangeListener(new IPropertyChangeListener() {

        public final void propertyChange(final PropertyChangeEvent event) {
            if (!event.getOldValue().equals(event.getNewValue())) {
                final KeySequence keySequence = fKeySequenceText.getKeySequence();
                if (!keySequence.isComplete()) {
                    return;
                }
                keyTxt.setSelection(keyTxt.getTextLimit());
            }
        }
    });
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) Group(org.eclipse.swt.widgets.Group) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Label(org.eclipse.swt.widgets.Label) KeySequenceText(org.eclipse.jface.bindings.keys.KeySequenceText) Text(org.eclipse.swt.widgets.Text) KeySequenceText(org.eclipse.jface.bindings.keys.KeySequenceText) KeySequence(org.eclipse.jface.bindings.keys.KeySequence)

Aggregations

KeySequence (org.eclipse.jface.bindings.keys.KeySequence)1 KeySequenceText (org.eclipse.jface.bindings.keys.KeySequenceText)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1 Group (org.eclipse.swt.widgets.Group)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1