Package org.eclipse.jface.bindings

Examples of org.eclipse.jface.bindings.TriggerSequence


  private String getLabelWithBinding(String id, String label) {
    return getLabelWithBinding(id, label, false);
  }

  private String getLabelWithBinding(String id, String label, boolean forToolTip) {
    TriggerSequence binding = fBindingService.getBestActiveBindingFor(id);
    if (binding != null)
      return forToolTip ? (NLS.bind(Messages.CoolBarAdvisor_LABEL_KEY, label, binding.format())) : (NLS.bind(Messages.CoolBarAdvisor_LABEL_TAB_KEY, label, binding.format()));

    return label;
  }
View Full Code Here


   * @see org.eclipse.jface.action.Action#getText()
   */
  @Override
  public String getText() {
    IBindingService bs = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
    TriggerSequence binding = bs.getBestActiveBindingFor(ID);

    return binding != null ? NLS.bind(Messages.MakeNewsStickyAction_NEWS_STICKY_BINDING, binding.format()) : Messages.MakeNewsStickyAction_NEWS_STICKY;
  }
View Full Code Here

  public Menu getMenu(Menu parent) {
    return null;
  }

  private String getLabelWithBinding(String id, String label) {
    TriggerSequence binding = fBindingService.getBestActiveBindingFor(id);
    if (binding != null)
      return NLS.bind(Messages.NewTypeDropdownAction_LABEL_BINDING, label, binding.format());

    return label;
  }
View Full Code Here

   * @see org.eclipse.jface.action.Action#getText()
   */
  @Override
  public String getText() {
    IBindingService bs = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
    TriggerSequence binding = bs.getBestActiveBindingFor(ID);

    return binding != null ? NLS.bind(Messages.ToggleReadStateAction_NEWS_READ_BINDING, binding.format()) : Messages.ToggleReadStateAction_NEWS_READ;
  }
View Full Code Here

   */
  public static String getShortcut(String commandId) {
    final IBindingService keys = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
   
    if (commandId != null && keys != null) {
      TriggerSequence trigger = keys.getBestActiveBindingFor(commandId);
      if (trigger != null && trigger.getTriggers().length > 0) {
        return trigger.format();
      }
    }
   
    return "";
  }
View Full Code Here

     * @return the 'best' key sequence that will activate the given command
     */
    public static KeySequence getCommandKeyBinding(final String commandId) {
        final IBindingService bindingSvc = (IBindingService) PlatformUI.getWorkbench()
                .getAdapter(IBindingService.class);
        final TriggerSequence binding = bindingSvc.getBestActiveBindingFor(commandId);
        if (binding instanceof KeySequence) {
            return (KeySequence) binding;
        }

        return null;
View Full Code Here

            final IBindingManagerCallback bindingManagerCallback = (IBindingManagerCallback) callback;
            final IKeyLookup lookup = KeyLookupFactory.getDefault();
            final TriggerSequence[] triggerSequences = bindingManagerCallback
                .getActiveBindingsFor(commandId);
            for (int i = 0; i < triggerSequences.length; i++) {
              final TriggerSequence triggerSequence = triggerSequences[i];
              final Trigger[] triggers = triggerSequence
                  .getTriggers();
              if (triggers.length == 1) {
                final Trigger trigger = triggers[0];
                if (trigger instanceof KeyStroke) {
                  final KeyStroke currentKeyStroke = (KeyStroke) trigger;
                  final int currentNaturalKey = currentKeyStroke
                      .getNaturalKey();
                  if ((currentKeyStroke.getModifierKeys() == (lookup
                      .getCtrl() | lookup.getShift()))
                      && ((currentNaturalKey >= '0' && currentNaturalKey <= '9')
                          || (currentNaturalKey >= 'A' && currentNaturalKey <= 'F') || (currentNaturalKey == 'U'))) {
                    accelerator = currentKeyStroke
                        .getModifierKeys()
                        | currentNaturalKey;
                    acceleratorText = triggerSequence
                        .format();
                    break;
                  }
                }
              }
View Full Code Here

    /**
     * @see org.eclipse.jface.action.ExternalActionManager.ICallback#getAccelerator(String)
     */
    public final Integer getAccelerator(final String commandId) {
      final TriggerSequence triggerSequence = bindingManager
          .getBestActiveBindingFor(commandId);
      if (triggerSequence != null) {
        final Trigger[] triggers = triggerSequence.getTriggers();
        if (triggers.length == 1) {
          final Trigger trigger = triggers[0];
          if (trigger instanceof KeyStroke) {
            final KeyStroke keyStroke = (KeyStroke) trigger;
            final int accelerator = SWTKeySupport
View Full Code Here

    /**
     * @see org.eclipse.jface.action.ExternalActionManager.ICallback#getAcceleratorText(String)
     */
    public final String getAcceleratorText(final String commandId) {
      final TriggerSequence triggerSequence = bindingManager
          .getBestActiveBindingFor(commandId);
      if (triggerSequence == null) {
        return null;
      }

      return triggerSequence.format();
    }
View Full Code Here

        if (commandForward != null) {
          if (forwardTriggerSequences != null) {
            final int forwardCount = forwardTriggerSequences.length;
            for (int i = 0; i < forwardCount; i++) {
              final TriggerSequence triggerSequence = forwardTriggerSequences[i];

              // Compare the last key stroke of the binding.
              final Trigger[] triggers = triggerSequence
                  .getTriggers();
              final int triggersLength = triggers.length;
              if ((triggersLength > 0)
                  && (triggers[triggersLength - 1]
                      .equals(keyStroke))) {
                acceleratorForward = true;
                break;
              }
            }
          }
        }

        if (commandBackward != null) {
          if (backwardTriggerSequences != null) {
            final int backwardCount = backwardTriggerSequences.length;
            for (int i = 0; i < backwardCount; i++) {
              final TriggerSequence triggerSequence = backwardTriggerSequences[i];

              // Compare the last key stroke of the binding.
              final Trigger[] triggers = triggerSequence
                  .getTriggers();
              final int triggersLength = triggers.length;
              if ((triggersLength > 0)
                  && (triggers[triggersLength - 1]
                      .equals(keyStroke))) {
View Full Code Here

TOP

Related Classes of org.eclipse.jface.bindings.TriggerSequence

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.