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

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

Introduction

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

Prototype

List TRAPPED_KEYS

To view the source code for org.eclipse.jface.bindings.keys KeySequenceText TRAPPED_KEYS.

Click Source Link

Document

The keys trapped by this widget.

Usage

From source file:com.bdaum.zoom.ui.internal.preferences.KeyPreferencePage.java

License:Open Source License

@SuppressWarnings("unused")
private void createDefinitionArea(Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    composite.setLayout(new GridLayout(2, false));
    new Label(composite, SWT.NONE).setText(Messages.getString("KeyPreferencePage.command2")); //$NON-NLS-1$
    nameField = new Text(composite, SWT.SINGLE | SWT.LEAD | SWT.BORDER | SWT.READ_ONLY);
    nameField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    new Label(composite, SWT.NONE).setText(Messages.getString("KeyPreferencePage.description")); //$NON-NLS-1$
    descriptionField = new Text(composite, SWT.MULTI | SWT.LEAD | SWT.BORDER | SWT.READ_ONLY | SWT.WRAP);
    GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
    layoutData.heightHint = 50;//  w  w w .  j a v  a 2  s .  co m
    descriptionField.setLayoutData(layoutData);
    new Label(composite, SWT.NONE).setText(Messages.getString("KeyPreferencePage.key_sequence")); //$NON-NLS-1$
    Composite keyGroup = new Composite(composite, SWT.NONE);
    keyGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true));
    GridLayout layout = new GridLayout(2, false);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    keyGroup.setLayout(layout);
    keyField = new Text(keyGroup, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
    keyField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    keySequenceField = new KeySequenceText(keyField);
    keySequenceField.setKeyStrokeLimit(2);
    keySequenceField.addPropertyChangeListener(new IPropertyChangeListener() {
        public final void propertyChange(final PropertyChangeEvent event) {
            if (!event.getOldValue().equals(event.getNewValue())) {
                final KeySequence keySequence = keySequenceField.getKeySequence();
                if (selectedCommand == null || !keySequence.isComplete())
                    return;
                boolean empty = keySequence.isEmpty();
                Binding newBinding;
                Binding b = commandMap.get(selectedCommand.getId());
                if (b != null) {
                    if (!keySequence.equals(b.getTriggerSequence())) {
                        newBinding = new KeyBinding(keySequence, empty ? null : b.getParameterizedCommand(),
                                activeSchemeId, b.getContextId(), null, null, null, Binding.USER);
                        userMap.remove(b.getTriggerSequence());
                        userMap.put(keySequence, newBinding);
                        if (empty)
                            commandMap.remove(selectedCommand.getId());
                        else
                            commandMap.put(selectedCommand.getId(), newBinding);
                    }
                } else if (!empty) {
                    ParameterizedCommand pc = new ParameterizedCommand(selectedCommand, null);
                    newBinding = new KeyBinding(keySequence, pc, activeSchemeId,
                            "org.eclipse.ui.contexts.window", //$NON-NLS-1$
                            null, null, null, Binding.USER);
                    userMap.put(keySequence, newBinding);
                    commandMap.put(selectedCommand.getId(), newBinding);
                }
                refreshViewer();
                doValidate();
                keyField.setSelection(keyField.getTextLimit());
            }
        }
    });
    final Button helpButton = new Button(keyGroup, SWT.ARROW | SWT.LEFT);
    helpButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    helpButton.setToolTipText(Messages.getString("KeyPreferencePage.add_a_special_key")); //$NON-NLS-1$
    // Arrow buttons aren't normally added to the tab list. Let's fix that.
    final Control[] tabStops = keyGroup.getTabList();
    final ArrayList<Control> newTabStops = new ArrayList<Control>();
    for (int i = 0; i < tabStops.length; i++) {
        Control tabStop = tabStops[i];
        newTabStops.add(tabStop);
        if (keyField.equals(tabStop))
            newTabStops.add(helpButton);
    }
    keyGroup.setTabList(newTabStops.toArray(new Control[newTabStops.size()]));

    // Construct the menu to attach to the above button.
    final Menu addKeyMenu = new Menu(helpButton);
    final Iterator<?> trappedKeyItr = KeySequenceText.TRAPPED_KEYS.iterator();
    while (trappedKeyItr.hasNext()) {
        final KeyStroke trappedKey = (KeyStroke) trappedKeyItr.next();
        final MenuItem menuItem = new MenuItem(addKeyMenu, SWT.PUSH);
        menuItem.setText(trappedKey.format());
        menuItem.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                keySequenceField.insert(trappedKey);
                keyField.setFocus();
                keyField.setSelection(keyField.getTextLimit());
            }
        });
    }
    helpButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent selectionEvent) {
            Point buttonLocation = helpButton.getLocation();
            buttonLocation = composite.toDisplay(buttonLocation.x, buttonLocation.y);
            Point buttonSize = helpButton.getSize();
            addKeyMenu.setLocation(buttonLocation.x, buttonLocation.y + buttonSize.y);
            addKeyMenu.setVisible(true);
        }
    });
    new Label(composite, SWT.NONE);
    userLabel = new Label(composite, SWT.NONE);
    userLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
}

From source file:org.eclipse.ui.internal.keys.KeysPreferencePage.java

License:Open Source License

/**
 * Creates the tab that allows the user to change the keyboard shortcuts.
 * //w w w . j  a v  a 2  s  . c  o  m
 * @param parent
 *            The tab folder in which the tab should be created; must not be
 *            <code>null</code>.
 * @return The composite which represents the contents of the tab; never
 *         <code>null</code>.
 */
private final Composite createModifyTab(final TabFolder parent) {
    final Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout());
    GridData gridData = new GridData(GridData.FILL_BOTH);
    composite.setLayoutData(gridData);
    final Composite compositeKeyConfiguration = new Composite(composite, SWT.NULL);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    compositeKeyConfiguration.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    compositeKeyConfiguration.setLayoutData(gridData);
    final Label labelKeyConfiguration = new Label(compositeKeyConfiguration, SWT.LEFT);
    labelKeyConfiguration.setText(Util.translateString(RESOURCE_BUNDLE, "labelScheme")); //$NON-NLS-1$
    comboScheme = new Combo(compositeKeyConfiguration, SWT.READ_ONLY);
    gridData = new GridData();
    gridData.widthHint = 200;
    comboScheme.setLayoutData(gridData);
    comboScheme.setVisibleItemCount(ITEMS_TO_SHOW);

    comboScheme.addSelectionListener(new SelectionAdapter() {
        public final void widgetSelected(final SelectionEvent e) {
            selectedComboScheme();
        }
    });

    labelSchemeExtends = new Label(compositeKeyConfiguration, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    labelSchemeExtends.setLayoutData(gridData);
    final Control spacer = new Composite(composite, SWT.NULL);
    gridData = new GridData();
    gridData.heightHint = 10;
    gridData.widthHint = 10;
    spacer.setLayoutData(gridData);
    final Group groupCommand = new Group(composite, SWT.SHADOW_NONE);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    groupCommand.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    groupCommand.setLayoutData(gridData);
    groupCommand.setText(Util.translateString(RESOURCE_BUNDLE, "groupCommand")); //$NON-NLS-1$   
    final Label labelCategory = new Label(groupCommand, SWT.LEFT);
    gridData = new GridData();
    labelCategory.setLayoutData(gridData);
    labelCategory.setText(Util.translateString(RESOURCE_BUNDLE, "labelCategory")); //$NON-NLS-1$
    comboCategory = new Combo(groupCommand, SWT.READ_ONLY);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.widthHint = 200;
    comboCategory.setLayoutData(gridData);
    comboCategory.setVisibleItemCount(ITEMS_TO_SHOW);

    comboCategory.addSelectionListener(new SelectionAdapter() {
        public final void widgetSelected(final SelectionEvent e) {
            update();
        }
    });

    final Label labelCommand = new Label(groupCommand, SWT.LEFT);
    gridData = new GridData();
    labelCommand.setLayoutData(gridData);
    labelCommand.setText(Util.translateString(RESOURCE_BUNDLE, "labelCommand")); //$NON-NLS-1$
    comboCommand = new Combo(groupCommand, SWT.READ_ONLY);
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.widthHint = 300;
    comboCommand.setLayoutData(gridData);
    comboCommand.setVisibleItemCount(9);

    comboCommand.addSelectionListener(new SelectionAdapter() {
        public final void widgetSelected(final SelectionEvent e) {
            update();
        }
    });

    labelBindingsForCommand = new Label(groupCommand, SWT.LEFT);
    gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    gridData.verticalAlignment = GridData.FILL_VERTICAL;
    labelBindingsForCommand.setLayoutData(gridData);
    labelBindingsForCommand.setText(Util.translateString(RESOURCE_BUNDLE, "labelAssignmentsForCommand")); //$NON-NLS-1$
    tableBindingsForCommand = new Table(groupCommand,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    tableBindingsForCommand.setHeaderVisible(true);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 60;
    gridData.horizontalSpan = 2;
    boolean isMac = org.eclipse.jface.util.Util.isMac();
    gridData.widthHint = isMac ? 620 : 520;
    tableBindingsForCommand.setLayoutData(gridData);
    TableColumn tableColumnDelta = new TableColumn(tableBindingsForCommand, SWT.NULL, 0);
    tableColumnDelta.setResizable(false);
    tableColumnDelta.setText(Util.ZERO_LENGTH_STRING);
    tableColumnDelta.setWidth(20);
    TableColumn tableColumnContext = new TableColumn(tableBindingsForCommand, SWT.NULL, 1);
    tableColumnContext.setResizable(true);
    tableColumnContext.setText(Util.translateString(RESOURCE_BUNDLE, "tableColumnContext")); //$NON-NLS-1$
    tableColumnContext.pack();
    tableColumnContext.setWidth(200);
    final TableColumn tableColumnKeySequence = new TableColumn(tableBindingsForCommand, SWT.NULL, 2);
    tableColumnKeySequence.setResizable(true);
    tableColumnKeySequence.setText(Util.translateString(RESOURCE_BUNDLE, "tableColumnKeySequence")); //$NON-NLS-1$
    tableColumnKeySequence.pack();
    tableColumnKeySequence.setWidth(300);

    tableBindingsForCommand.addMouseListener(new MouseAdapter() {

        public void mouseDoubleClick(MouseEvent mouseEvent) {
            update();
        }
    });

    tableBindingsForCommand.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent selectionEvent) {
            selectedTableBindingsForCommand();
        }
    });

    final Group groupKeySequence = new Group(composite, SWT.SHADOW_NONE);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 4;
    groupKeySequence.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_BOTH);
    groupKeySequence.setLayoutData(gridData);
    groupKeySequence.setText(Util.translateString(RESOURCE_BUNDLE, "groupKeySequence")); //$NON-NLS-1$   
    final Label labelKeySequence = new Label(groupKeySequence, SWT.LEFT);
    gridData = new GridData();
    labelKeySequence.setLayoutData(gridData);
    labelKeySequence.setText(Util.translateString(RESOURCE_BUNDLE, "labelKeySequence")); //$NON-NLS-1$

    // The text widget into which the key strokes will be entered.
    textTriggerSequence = new Text(groupKeySequence, SWT.BORDER);
    // On MacOS X, this font will be changed by KeySequenceText
    textTriggerSequence.setFont(groupKeySequence.getFont());
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    gridData.widthHint = 300;
    textTriggerSequence.setLayoutData(gridData);
    textTriggerSequence.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            update();
        }
    });
    textTriggerSequence.addFocusListener(new FocusListener() {
        public void focusGained(FocusEvent e) {
            bindingService.setKeyFilterEnabled(false);
        }

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

    // The manager for the key sequence text widget.
    textTriggerSequenceManager = new KeySequenceText(textTriggerSequence);
    textTriggerSequenceManager.setKeyStrokeLimit(4);

    // Button for adding trapped key strokes
    final Button buttonAddKey = new Button(groupKeySequence, SWT.LEFT | SWT.ARROW);
    buttonAddKey.setToolTipText(Util.translateString(RESOURCE_BUNDLE, "buttonAddKey.ToolTipText")); //$NON-NLS-1$
    gridData = new GridData();
    gridData.heightHint = comboCategory.getTextHeight();
    buttonAddKey.setLayoutData(gridData);

    // Arrow buttons aren't normally added to the tab list. Let's fix that.
    final Control[] tabStops = groupKeySequence.getTabList();
    final ArrayList newTabStops = new ArrayList();
    for (int i = 0; i < tabStops.length; i++) {
        Control tabStop = tabStops[i];
        newTabStops.add(tabStop);
        if (textTriggerSequence.equals(tabStop)) {
            newTabStops.add(buttonAddKey);
        }
    }
    final Control[] newTabStopArray = (Control[]) newTabStops.toArray(new Control[newTabStops.size()]);
    groupKeySequence.setTabList(newTabStopArray);

    // Construct the menu to attach to the above button.
    final Menu menuButtonAddKey = new Menu(buttonAddKey);
    final Iterator trappedKeyItr = KeySequenceText.TRAPPED_KEYS.iterator();
    while (trappedKeyItr.hasNext()) {
        final KeyStroke trappedKey = (KeyStroke) trappedKeyItr.next();
        final MenuItem menuItem = new MenuItem(menuButtonAddKey, SWT.PUSH);
        menuItem.setText(trappedKey.format());
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                textTriggerSequenceManager.insert(trappedKey);
                textTriggerSequence.setFocus();
                textTriggerSequence.setSelection(textTriggerSequence.getTextLimit());
            }
        });
    }
    buttonAddKey.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent selectionEvent) {
            Point buttonLocation = buttonAddKey.getLocation();
            buttonLocation = groupKeySequence.toDisplay(buttonLocation.x, buttonLocation.y);
            Point buttonSize = buttonAddKey.getSize();
            menuButtonAddKey.setLocation(buttonLocation.x, buttonLocation.y + buttonSize.y);
            menuButtonAddKey.setVisible(true);
        }
    });

    labelBindingsForTriggerSequence = new Label(groupKeySequence, SWT.LEFT);
    gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    gridData.verticalAlignment = GridData.FILL_VERTICAL;
    labelBindingsForTriggerSequence.setLayoutData(gridData);
    labelBindingsForTriggerSequence
            .setText(Util.translateString(RESOURCE_BUNDLE, "labelAssignmentsForKeySequence")); //$NON-NLS-1$
    tableBindingsForTriggerSequence = new Table(groupKeySequence,
            SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    tableBindingsForTriggerSequence.setHeaderVisible(true);
    gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 60;
    gridData.horizontalSpan = 3;
    gridData.widthHint = isMac ? 620 : 520;
    tableBindingsForTriggerSequence.setLayoutData(gridData);
    tableColumnDelta = new TableColumn(tableBindingsForTriggerSequence, SWT.NULL, 0);
    tableColumnDelta.setResizable(false);
    tableColumnDelta.setText(Util.ZERO_LENGTH_STRING);
    tableColumnDelta.setWidth(20);
    tableColumnContext = new TableColumn(tableBindingsForTriggerSequence, SWT.NULL, 1);
    tableColumnContext.setResizable(true);
    tableColumnContext.setText(Util.translateString(RESOURCE_BUNDLE, "tableColumnContext")); //$NON-NLS-1$
    tableColumnContext.pack();
    tableColumnContext.setWidth(200);
    final TableColumn tableColumnCommand = new TableColumn(tableBindingsForTriggerSequence, SWT.NULL, 2);
    tableColumnCommand.setResizable(true);
    tableColumnCommand.setText(Util.translateString(RESOURCE_BUNDLE, "tableColumnCommand")); //$NON-NLS-1$
    tableColumnCommand.pack();
    tableColumnCommand.setWidth(300);

    tableBindingsForTriggerSequence.addMouseListener(new MouseAdapter() {

        public void mouseDoubleClick(MouseEvent mouseEvent) {
            update();
        }
    });

    tableBindingsForTriggerSequence.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent selectionEvent) {
            selectedTableBindingsForTriggerSequence();
        }
    });

    final Composite compositeContext = new Composite(composite, SWT.NULL);
    gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    compositeContext.setLayout(gridLayout);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    compositeContext.setLayoutData(gridData);
    final Label labelContext = new Label(compositeContext, SWT.LEFT);
    labelContext.setText(Util.translateString(RESOURCE_BUNDLE, "labelContext")); //$NON-NLS-1$
    comboContext = new Combo(compositeContext, SWT.READ_ONLY);
    gridData = new GridData();
    gridData.widthHint = 250;
    comboContext.setLayoutData(gridData);
    comboContext.setVisibleItemCount(ITEMS_TO_SHOW);

    comboContext.addSelectionListener(new SelectionAdapter() {
        public final void widgetSelected(final SelectionEvent e) {
            update();
        }
    });

    labelContextExtends = new Label(compositeContext, SWT.LEFT);
    gridData = new GridData(GridData.FILL_HORIZONTAL);
    labelContextExtends.setLayoutData(gridData);
    final Composite compositeButton = new Composite(composite, SWT.NULL);
    gridLayout = new GridLayout();
    gridLayout.marginHeight = 20;
    gridLayout.marginWidth = 0;
    gridLayout.numColumns = 3;
    compositeButton.setLayout(gridLayout);
    gridData = new GridData();
    compositeButton.setLayoutData(gridData);
    buttonAdd = new Button(compositeButton, SWT.CENTER | SWT.PUSH);
    gridData = new GridData();
    int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    buttonAdd.setText(Util.translateString(RESOURCE_BUNDLE, "buttonAdd")); //$NON-NLS-1$
    gridData.widthHint = Math.max(widthHint, buttonAdd.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x) + 5;
    buttonAdd.setLayoutData(gridData);

    buttonAdd.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent selectionEvent) {
            selectedButtonAdd();
        }
    });

    buttonRemove = new Button(compositeButton, SWT.CENTER | SWT.PUSH);
    gridData = new GridData();
    widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    buttonRemove.setText(Util.translateString(RESOURCE_BUNDLE, "buttonRemove")); //$NON-NLS-1$
    gridData.widthHint = Math.max(widthHint, buttonRemove.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x) + 5;
    buttonRemove.setLayoutData(gridData);

    buttonRemove.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent selectionEvent) {
            selectedButtonRemove();
        }
    });

    buttonRestore = new Button(compositeButton, SWT.CENTER | SWT.PUSH);
    gridData = new GridData();
    widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
    buttonRestore.setText(Util.translateString(RESOURCE_BUNDLE, "buttonRestore")); //$NON-NLS-1$
    gridData.widthHint = Math.max(widthHint, buttonRestore.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x) + 5;
    buttonRestore.setLayoutData(gridData);

    buttonRestore.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent selectionEvent) {
            selectedButtonRestore();
        }
    });

    return composite;
}

From source file:org.eclipse.ui.internal.keys.NewKeysPreferencePage.java

License:Open Source License

private final void createDataControls(final Composite parent) {
    GridLayout layout;//w w  w  . ja va 2 s. c o  m
    GridData gridData;

    // Creates the data area.
    final Composite dataArea = new Composite(parent, SWT.NONE);
    layout = new GridLayout(2, true);
    layout.marginWidth = 0;
    dataArea.setLayout(layout);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = SWT.FILL;
    dataArea.setLayoutData(gridData);

    // LEFT DATA AREA
    // Creates the left data area.
    final Composite leftDataArea = new Composite(dataArea, SWT.NONE);
    layout = new GridLayout(3, false);
    leftDataArea.setLayout(layout);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.verticalAlignment = SWT.TOP;
    gridData.horizontalAlignment = SWT.FILL;
    leftDataArea.setLayoutData(gridData);

    // The command name label.
    final Label commandNameLabel = new Label(leftDataArea, SWT.NONE);
    commandNameLabel.setText(NewKeysPreferenceMessages.CommandNameLabel_Text);

    // The current command name.
    commandNameValueLabel = new Label(leftDataArea, SWT.NONE);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalSpan = 2;
    gridData.horizontalAlignment = SWT.FILL;
    commandNameValueLabel.setLayoutData(gridData);

    final Label commandDescriptionlabel = new Label(leftDataArea, SWT.LEAD);
    commandDescriptionlabel.setText(NewKeysPreferenceMessages.CommandDescriptionLabel_Text);
    gridData = new GridData();
    gridData.verticalAlignment = SWT.BEGINNING;
    commandDescriptionlabel.setLayoutData(gridData);

    fDescriptionText = new Text(leftDataArea, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.READ_ONLY);

    // The binding label.
    final Label bindingLabel = new Label(leftDataArea, SWT.NONE);
    bindingLabel.setText(NewKeysPreferenceMessages.BindingLabel_Text);

    // The key sequence entry widget.
    fBindingText = new Text(leftDataArea, SWT.BORDER);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = SWT.FILL;
    gridData.widthHint = 200;
    fBindingText.setLayoutData(gridData);

    fBindingText.addFocusListener(new FocusListener() {
        public void focusGained(FocusEvent e) {
            fBindingService.setKeyFilterEnabled(false);
        }

        public void focusLost(FocusEvent e) {
            fBindingService.setKeyFilterEnabled(true);
        }
    });
    fBindingText.addDisposeListener(new DisposeListener() {
        public void widgetDisposed(DisposeEvent e) {
            if (!fBindingService.isKeyFilterEnabled()) {
                fBindingService.setKeyFilterEnabled(true);
            }
        }
    });

    fKeySequenceText = new KeySequenceText(fBindingText);
    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;
                }

                BindingElement activeBinding = (BindingElement) keyController.getBindingModel()
                        .getSelectedElement();
                if (activeBinding != null) {
                    activeBinding.setTrigger(keySequence);
                }
                fBindingText.setSelection(fBindingText.getTextLimit());
            }
        }
    });

    // Button for adding trapped key strokes
    final Button addKeyButton = new Button(leftDataArea, SWT.LEFT | SWT.ARROW);
    addKeyButton.setToolTipText(NewKeysPreferenceMessages.AddKeyButton_ToolTipText);
    gridData = new GridData();
    gridData.heightHint = fSchemeCombo.getCombo().getTextHeight();
    addKeyButton.setLayoutData(gridData);

    // Arrow buttons aren't normally added to the tab list. Let's fix that.
    final Control[] tabStops = dataArea.getTabList();
    final ArrayList newTabStops = new ArrayList();
    for (int i = 0; i < tabStops.length; i++) {
        Control tabStop = tabStops[i];
        newTabStops.add(tabStop);
        if (fBindingText.equals(tabStop)) {
            newTabStops.add(addKeyButton);
        }
    }
    final Control[] newTabStopArray = (Control[]) newTabStops.toArray(new Control[newTabStops.size()]);
    dataArea.setTabList(newTabStopArray);

    // Construct the menu to attach to the above button.
    final Menu addKeyMenu = new Menu(addKeyButton);
    final Iterator trappedKeyItr = KeySequenceText.TRAPPED_KEYS.iterator();
    while (trappedKeyItr.hasNext()) {
        final KeyStroke trappedKey = (KeyStroke) trappedKeyItr.next();
        final MenuItem menuItem = new MenuItem(addKeyMenu, SWT.PUSH);
        menuItem.setText(trappedKey.format());
        menuItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                fKeySequenceText.insert(trappedKey);
                fBindingText.setFocus();
                fBindingText.setSelection(fBindingText.getTextLimit());
            }
        });
    }
    addKeyButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent selectionEvent) {
            Point buttonLocation = addKeyButton.getLocation();
            buttonLocation = dataArea.toDisplay(buttonLocation.x, buttonLocation.y);
            Point buttonSize = addKeyButton.getSize();
            addKeyMenu.setLocation(buttonLocation.x, buttonLocation.y + buttonSize.y);
            addKeyMenu.setVisible(true);
        }
    });

    // The when label.
    final Label whenLabel = new Label(leftDataArea, SWT.NONE);
    whenLabel.setText(NewKeysPreferenceMessages.WhenLabel_Text);

    // The when combo.
    fWhenCombo = new ComboViewer(leftDataArea);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = SWT.FILL;
    gridData.horizontalSpan = 2;
    ViewerComparator comparator = new ViewerComparator();
    fWhenCombo.setComparator(comparator);
    fWhenCombo.getCombo().setVisibleItemCount(ITEMS_TO_SHOW);
    fWhenCombo.getCombo().setLayoutData(gridData);
    fWhenCombo.setContentProvider(new ModelContentProvider());
    fWhenCombo.setLabelProvider(new ListLabelProvider());
    fWhenCombo.addSelectionChangedListener(new ISelectionChangedListener() {
        public final void selectionChanged(final SelectionChangedEvent event) {
            ContextElement context = (ContextElement) ((IStructuredSelection) event.getSelection())
                    .getFirstElement();
            if (context != null) {
                keyController.getContextModel().setSelectedElement(context);
            }
        }
    });
    IPropertyChangeListener whenListener = new IPropertyChangeListener() {

        // Sets the combo selection when a new keybinding is selected?
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getSource() == keyController.getContextModel()
                    && CommonModel.PROP_SELECTED_ELEMENT.equals(event.getProperty())) {
                Object newVal = event.getNewValue();
                StructuredSelection structuredSelection = newVal == null ? null
                        : new StructuredSelection(newVal);
                fWhenCombo.setSelection(structuredSelection, true);
            }
        }
    };
    keyController.addPropertyChangeListener(whenListener);

    // RIGHT DATA AREA
    // Creates the right data area.
    final Composite rightDataArea = new Composite(dataArea, SWT.NONE);
    layout = new GridLayout(1, false);
    rightDataArea.setLayout(layout);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    rightDataArea.setLayoutData(gridData);

    new Label(rightDataArea, SWT.NONE); // filler

    // The description label.
    final Label descriptionLabel = new Label(rightDataArea, SWT.NONE);
    descriptionLabel.setText(NewKeysPreferenceMessages.ConflictsLabel_Text);
    gridData = new GridData();
    gridData.grabExcessHorizontalSpace = true;
    gridData.horizontalAlignment = SWT.FILL;
    descriptionLabel.setLayoutData(gridData);

    conflictViewer = new TableViewer(rightDataArea,
            SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    Table table = conflictViewer.getTable();
    table.setHeaderVisible(true);
    TableColumn bindingNameColumn = new TableColumn(table, SWT.LEAD);
    bindingNameColumn.setText(NewKeysPreferenceMessages.CommandNameColumn_Text);
    bindingNameColumn.setWidth(150);
    TableColumn bindingContextNameColumn = new TableColumn(table, SWT.LEAD);
    bindingContextNameColumn.setText(NewKeysPreferenceMessages.WhenColumn_Text);
    bindingContextNameColumn.setWidth(150);
    gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    //gridData.horizontalIndent = 10;
    table.setLayoutData(gridData);
    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnWeightData(60));
    tableLayout.addColumnData(new ColumnWeightData(40));
    table.setLayout(tableLayout);
    conflictViewer.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof Collection) {
                return ((Collection) inputElement).toArray();
            }
            return new Object[0];
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    conflictViewer.setLabelProvider(new BindingElementLabelProvider() {
        public String getColumnText(Object o, int index) {
            BindingElement element = (BindingElement) o;
            if (index == 0) {
                return element.getName();
            }
            return element.getContext().getName();
        }
    });
    conflictViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        // When the conflict viewer's selection changes, update the
        // model's current selection
        public void selectionChanged(SelectionChangedEvent event) {
            ModelElement binding = (ModelElement) ((IStructuredSelection) event.getSelection())
                    .getFirstElement();
            BindingModel bindingModel = keyController.getBindingModel();
            if (binding != null && binding != bindingModel.getSelectedElement()) {
                StructuredSelection selection = new StructuredSelection(binding);

                bindingModel.setSelectedElement(binding);
                conflictViewer.setSelection(selection);

                boolean selectionVisible = false;
                TreeItem[] items = fFilteredTree.getViewer().getTree().getItems();
                for (int i = 0; i < items.length; i++) {
                    if (items[i].getData().equals(binding)) {
                        selectionVisible = true;
                        break;
                    }
                }

                if (!selectionVisible) {
                    fFilteredTree.getFilterControl().setText(""); //$NON-NLS-1$
                    fFilteredTree.getViewer().refresh();
                    bindingModel.setSelectedElement(binding);
                    conflictViewer.setSelection(selection);
                }
            }
        }
    });

    IPropertyChangeListener conflictsListener = new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getSource() == keyController.getConflictModel()
                    && CommonModel.PROP_SELECTED_ELEMENT.equals(event.getProperty())) {
                if (keyController.getConflictModel().getConflicts() != null) {
                    Object newVal = event.getNewValue();
                    StructuredSelection structuredSelection = newVal == null ? null
                            : new StructuredSelection(newVal);
                    conflictViewer.setSelection(structuredSelection, true);
                }
            } else if (ConflictModel.PROP_CONFLICTS.equals(event.getProperty())) {
                conflictViewer.setInput(event.getNewValue());
            } else if (ConflictModel.PROP_CONFLICTS_ADD.equals(event.getProperty())) {
                conflictViewer.add(event.getNewValue());
            } else if (ConflictModel.PROP_CONFLICTS_REMOVE.equals(event.getProperty())) {
                conflictViewer.remove(event.getNewValue());
            }
        }
    };
    keyController.addPropertyChangeListener(conflictsListener);

    IPropertyChangeListener dataUpdateListener = new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            BindingElement bindingElement = null;
            boolean weCare = false;
            if (event.getSource() == keyController.getBindingModel()
                    && CommonModel.PROP_SELECTED_ELEMENT.equals(event.getProperty())) {
                bindingElement = (BindingElement) event.getNewValue();
                weCare = true;
            } else if (event.getSource() == keyController.getBindingModel().getSelectedElement()
                    && ModelElement.PROP_MODEL_OBJECT.equals(event.getProperty())) {
                bindingElement = (BindingElement) event.getSource();
                weCare = true;
            }
            if (bindingElement == null && weCare) {
                commandNameValueLabel.setText(""); //$NON-NLS-1$
                fDescriptionText.setText(""); //$NON-NLS-1$
                fBindingText.setText(""); //$NON-NLS-1$
            } else if (bindingElement != null) {
                commandNameValueLabel.setText(bindingElement.getName());
                String desc = bindingElement.getDescription();
                fDescriptionText.setText(desc == null ? "" : desc); //$NON-NLS-1$
                KeySequence trigger = (KeySequence) bindingElement.getTrigger();
                fKeySequenceText.setKeySequence(trigger);
            }
        }
    };
    keyController.addPropertyChangeListener(dataUpdateListener);

}