Example usage for org.eclipse.jface.bindings TriggerSequence isEmpty

List of usage examples for org.eclipse.jface.bindings TriggerSequence isEmpty

Introduction

In this page you can find the example usage for org.eclipse.jface.bindings TriggerSequence isEmpty.

Prototype

public final boolean isEmpty() 

Source Link

Document

Returns whether or not this trigger sequence is empty.

Usage

From source file:de.walware.ecommons.ui.actions.HandlerContributionItem.java

License:Open Source License

private String getToolTipText(final String text) {
    String tooltipText = tooltip;
    if (tooltip == null) {
        if (text != null) {
            tooltipText = text;/*from w w w . j  a  va 2  s  . co  m*/
        } else {
            tooltipText = ""; //$NON-NLS-1$
        }
    }

    if (command != null) {
        final TriggerSequence activeBinding = bindingService.getBestActiveBindingFor(command);
        if (activeBinding != null && !activeBinding.isEmpty()) {
            final String acceleratorText = activeBinding.format();
            if (acceleratorText != null && acceleratorText.length() != 0) {
                tooltipText = NLS.bind("{0} ({1})", tooltipText, acceleratorText); //$NON-NLS-1$
            }
        }
    }

    return tooltipText;
}

From source file:org.eclipse.e4.ui.bindings.internal.BindingServiceImpl.java

License:Open Source License

public Binding createBinding(TriggerSequence sequence, ParameterizedCommand command, String contextId,
        Map<String, String> attributes) {

    String schemeId = DEFAULT_SCHEME_ID;
    String locale = null;/*from ww  w .  java 2  s . co  m*/
    String platform = null;
    int bindingType = Binding.SYSTEM;

    if (sequence != null && !sequence.isEmpty() && contextId != null) {
        if (attributes != null) {
            String tmp = attributes.get(SCHEME_ID_ATTR_TAG);
            if (tmp != null && tmp.length() > 0) {
                schemeId = tmp;
            }
            locale = attributes.get(LOCALE_ATTR_TAG);
            platform = attributes.get(PLATFORM_ATTR_TAG);
            if (USER_TYPE.equals(attributes.get(TYPE_ATTR_TAG))) {
                bindingType = Binding.USER;
            }
        }
        return new KeyBinding((KeySequence) sequence, command, schemeId, contextId, locale, platform, null,
                bindingType);
    }
    return null;
}

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

License:Open Source License

/**
 * Updates the enabled state of the various widgets on this page. The
 * decision is based on the current trigger sequence and the currently
 * selected command.//from ww w . j  a  va  2s.  co  m
 * 
 * @param triggerSequence
 *            The current trigger sequence; may be empty, but never
 *            <code>null</code>.
 * @param command
 *            The currently selected command, if any; <code>null</code>
 *            otherwise.
 */
private final void updateEnabled(final TriggerSequence triggerSequence, final ParameterizedCommand command) {
    final boolean commandSelected = command != null;
    labelBindingsForCommand.setEnabled(commandSelected);
    tableBindingsForCommand.setEnabled(commandSelected);

    final boolean triggerSequenceSelected = !triggerSequence.isEmpty();
    labelBindingsForTriggerSequence.setEnabled(triggerSequenceSelected);
    tableBindingsForTriggerSequence.setEnabled(triggerSequenceSelected);

    /*
     * TODO Do some better button enablement.
     */
    final boolean buttonsEnabled = commandSelected && triggerSequenceSelected;
    buttonAdd.setEnabled(buttonsEnabled);
    buttonRemove.setEnabled(buttonsEnabled);
    buttonRestore.setEnabled(buttonsEnabled);
}

From source file:org.eclipse.ui.menus.CommandContributionItem.java

License:Open Source License

private String getToolTipText(String text) {
    String tooltipText = tooltip;
    if (tooltip == null)
        if (text != null)
            tooltipText = text;//from  ww  w.  jav a2s .  co m
        else
            tooltipText = ""; //$NON-NLS-1$

    TriggerSequence activeBinding = bindingService.getBestActiveBindingFor(command);
    if (activeBinding != null && !activeBinding.isEmpty()) {
        String acceleratorText = activeBinding.format();
        if (acceleratorText != null && acceleratorText.length() != 0) {
            tooltipText = NLS.bind(CommandMessages.Tooltip_Accelerator, tooltipText, acceleratorText);
        }
    }

    return tooltipText;
}