Example usage for org.eclipse.jface.bindings.keys KeyStroke KEY_DELIMITER

List of usage examples for org.eclipse.jface.bindings.keys KeyStroke KEY_DELIMITER

Introduction

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

Prototype

String KEY_DELIMITER

To view the source code for org.eclipse.jface.bindings.keys KeyStroke KEY_DELIMITER.

Click Source Link

Document

The delimiter between multiple keys in a single key strokes -- expressed in the formal key stroke grammar.

Usage

From source file:org.eclipse.mylyn.internal.web.tasks.WebContentProposalProvider.java

License:Open Source License

@SuppressWarnings("deprecation")
public static ControlDecoration createDecoration(final Text text, //
        ParametersEditor parametersEditor, boolean includeTemplates) {
    FieldDecorationRegistry registry = FieldDecorationRegistry.getDefault();
    FieldDecoration fieldDecoration = registry.getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);

    ControlDecoration decoration = new ControlDecoration(text, SWT.LEFT | SWT.TOP);
    decoration.setImage(fieldDecoration.getImage());
    decoration.setDescriptionText(fieldDecoration.getDescription());
    decoration.setShowOnlyOnFocus(true);

    KeyStroke keystroke = null;//from  w  ww . j av a 2  s .  c  om
    try {
        keystroke = KeyStroke.getInstance("Ctrl" + KeyStroke.KEY_DELIMITER + "Space"); //$NON-NLS-1$ //$NON-NLS-2$
    } catch (ParseException e) {
    }

    ContentProposalAdapter adapter = new ContentProposalAdapter(text, new TextContentAdapter(), //
            new WebContentProposalProvider(parametersEditor, includeTemplates), keystroke, null);
    adapter.setPopupSize(new Point(200, 150));
    adapter.setPropagateKeys(true);
    adapter.setFilterStyle(ContentProposalAdapter.FILTER_CUMULATIVE);

    // workaround for bug 196565
    WebContentProposalListener listener = new WebContentProposalListener(adapter);
    adapter.addContentProposalListener((IContentProposalListener) listener);
    adapter.addContentProposalListener((IContentProposalListener2) listener);
    adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_IGNORE);

    return decoration;
}

From source file:org.eclipse.rcptt.tesla.ui.Q7KeyFormatter.java

License:Open Source License

@Override
protected String getKeyDelimiter() {
    return KeyStroke.KEY_DELIMITER;
}

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

License:Open Source License

/**
 * Parses a single 2.1.x key stroke string, as provided by
 * <code>parse2_1Sequence</code>.
 * /*from  w  ww .  j  av  a  2 s.c om*/
 * @param string
 *            The string to parse; must not be <code>null</code>.
 * @return An single integer value representing this key stroke.
 */
private static final int parse2_1Stroke(final String string) {
    final StringTokenizer stringTokenizer = new StringTokenizer(string, KeyStroke.KEY_DELIMITER, true);

    // Copy out the tokens so we have random access.
    final int size = stringTokenizer.countTokens();
    final String[] tokens = new String[size];
    for (int i = 0; stringTokenizer.hasMoreTokens(); i++) {
        tokens[i] = stringTokenizer.nextToken();
    }

    int value = 0;
    if (size % 2 == 1) {
        String token = tokens[size - 1];
        final Integer integer = (Integer) r2_1KeysByName.get(token.toUpperCase());

        if (integer != null) {
            value = integer.intValue();
        } else if (token.length() == 1) {
            value = token.toUpperCase().charAt(0);
        }

        if (value != 0) {
            for (int i = 0; i < size - 1; i++) {
                token = tokens[i];

                if (i % 2 == 0) {
                    if (token.equalsIgnoreCase(IKeyLookup.CTRL_NAME)) {
                        if ((value & SWT.CTRL) != 0) {
                            return 0;
                        }

                        value |= SWT.CTRL;

                    } else if (token.equalsIgnoreCase(IKeyLookup.ALT_NAME)) {
                        if ((value & SWT.ALT) != 0) {
                            return 0;
                        }

                        value |= SWT.ALT;

                    } else if (token.equalsIgnoreCase(IKeyLookup.SHIFT_NAME)) {
                        if ((value & SWT.SHIFT) != 0) {
                            return 0;
                        }

                        value |= SWT.SHIFT;

                    } else if (token.equalsIgnoreCase(IKeyLookup.COMMAND_NAME)) {
                        if ((value & SWT.COMMAND) != 0) {
                            return 0;
                        }

                        value |= SWT.COMMAND;

                    } else {
                        return 0;

                    }

                } else if (!KeyStroke.KEY_DELIMITER.equals(token)) {
                    return 0;
                }
            }
        }
    }

    return value;
}

From source file:org.org.eclipse.core.utils.platform.fields.StringDialogField.java

License:Open Source License

protected KeyStroke getContentProposalKeyStroke() {
    KeyStroke result = null;//www  . j  av  a2s.  c  om
    try {
        result = KeyStroke.getInstance("Ctrl" + KeyStroke.KEY_DELIMITER + "Space");
    } catch (ParseException e) {
        // fail silently
    }
    return result;
}