Java 类com.intellij.openapi.actionSystem.ShortcutSet 实例源码

项目:intellij-ce-playground    文件:XValueHint.java   
@Override
protected boolean showHint(final JComponent component) {
  boolean result = super.showHint(component);
  if (result && getType() == ValueHintType.MOUSE_OVER_HINT) {
    myDisposable = Disposer.newDisposable();
    ShortcutSet shortcut = ActionManager.getInstance().getAction("ShowErrorDescription").getShortcutSet();
    new DumbAwareAction() {
      @Override
      public void actionPerformed(@NotNull AnActionEvent e) {
        hideHint();
        final Point point = new Point(myPoint.x, myPoint.y + getEditor().getLineHeight());
        new XValueHint(getProject(), getEditor(), point, ValueHintType.MOUSE_CLICK_HINT, myExpressionInfo, myEvaluator, myDebugSession).invokeHint();
      }
    }.registerCustomShortcutSet(shortcut, getEditor().getContentComponent(), myDisposable);
  }
  if (result) {
    XValueHint prev = getEditor().getUserData(HINT_KEY);
    if (prev != null) {
      prev.hideHint();
    }
    getEditor().putUserData(HINT_KEY, this);
  }
  return result;
}
项目:consulo    文件:XValueHint.java   
@Override
protected boolean showHint(final JComponent component) {
  boolean result = super.showHint(component);
  if (result && getType() == ValueHintType.MOUSE_OVER_HINT) {
    myDisposable = Disposer.newDisposable();
    ShortcutSet shortcut = ActionManager.getInstance().getAction("ShowErrorDescription").getShortcutSet();
    new DumbAwareAction() {
      @Override
      public void actionPerformed(@Nonnull AnActionEvent e) {
        hideHint();
        final Point point = new Point(myPoint.x, myPoint.y + getEditor().getLineHeight());
        new XValueHint(getProject(), getEditor(), point, ValueHintType.MOUSE_CLICK_HINT, myExpressionInfo, myEvaluator, myDebugSession).invokeHint();
      }
    }.registerCustomShortcutSet(shortcut, getEditor().getContentComponent(), myDisposable);
  }
  if (result) {
    XValueHint prev = getEditor().getUserData(HINT_KEY);
    if (prev != null) {
      prev.hideHint();
    }
    getEditor().putUserData(HINT_KEY, this);
  }
  return result;
}
项目:intellij-ce-playground    文件:UpdatableDebuggerView.java   
protected void overrideShortcut(final JComponent forComponent, final String actionId, final ShortcutSet shortcutSet) {
  final AnAction action = ActionManager.getInstance().getAction(actionId);
  action.registerCustomShortcutSet(shortcutSet, forComponent);
  registerDisposable(new Disposable() {
    public void dispose() {
      action.unregisterCustomShortcutSet(forComponent);
    }
  });
}
项目:intellij-ce-playground    文件:NavigateAction.java   
public NavigateAction(@NotNull String text,
                      @NotNull LineMarkerInfo<T> info,
                      @Nullable String originalActionId) {
  super(text);
  myInfo = info;
  if (originalActionId != null) {
    ShortcutSet set = ActionManager.getInstance().getAction(originalActionId).getShortcutSet();
    setShortcutSet(set);
  }
}
项目:tools-idea    文件:UpdatableDebuggerView.java   
protected void overrideShortcut(final JComponent forComponent, final String actionId, final ShortcutSet shortcutSet) {
  final AnAction action = ActionManager.getInstance().getAction(actionId);
  action.registerCustomShortcutSet(shortcutSet, forComponent);
  registerDisposable(new Disposable() {
    public void dispose() {
      action.unregisterCustomShortcutSet(forComponent);
    }
  });
}
项目:consulo    文件:NavigateAction.java   
public NavigateAction(@Nonnull String text,
                      @Nonnull LineMarkerInfo<T> info,
                      @Nullable String originalActionId) {
  super(text);
  myInfo = info;
  if (originalActionId != null) {
    ShortcutSet set = ActionManager.getInstance().getAction(originalActionId).getShortcutSet();
    setShortcutSet(set);
  }
}
项目:ddescriber    文件:DescriberDialog.java   
private void registerForEveryKeyboardShortcut(ActionListener action,
    @NotNull ShortcutSet shortcuts) {
  for (Shortcut shortcut : shortcuts.getShortcuts()) {
    if (shortcut instanceof KeyboardShortcut) {
      KeyboardShortcut ks = (KeyboardShortcut) shortcut;
      KeyStroke first = ks.getFirstKeyStroke();
      KeyStroke second = ks.getSecondKeyStroke();
      if (second == null) {
        getRootPane().registerKeyboardAction(action, first, JComponent.WHEN_IN_FOCUSED_WINDOW);
      }
    }
  }
}
项目:consulo-java    文件:UpdatableDebuggerView.java   
protected void overrideShortcut(final JComponent forComponent, final String actionId, final ShortcutSet shortcutSet)
{
    final AnAction action = ActionManager.getInstance().getAction(actionId);
    action.registerCustomShortcutSet(shortcutSet, forComponent);
    registerDisposable(new Disposable()
    {
        @Override
        public void dispose()
        {
            action.unregisterCustomShortcutSet(forComponent);
        }
    });
}
项目:intellij-ce-playground    文件:RefreshDirDiffAction.java   
@Override
public ShortcutSet getShortcut() {
  return REFRESH_SHORTCUT;
}
项目:intellij-ce-playground    文件:SynchronizeDiff.java   
@Override
public ShortcutSet getShortcut() {
  return CustomShortcutSet.fromString(mySelectedOnly ? "ENTER" : SystemInfo.isMac ? "meta ENTER" : "control ENTER");
}
项目:intellij-ce-playground    文件:DirDiffAction.java   
@Nullable
@Override
public ShortcutSet getShortcut() {
  return getShortcutSet();
}
项目:intellij-ce-playground    文件:ComponentWithBrowseButton.java   
public void registerShortcut(JComponent textField) {
  ShortcutSet shiftEnter = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK));
  registerCustomShortcutSet(shiftEnter, textField);
  myBrowseButton.setToolTipText(KeymapUtil.getShortcutsText(shiftEnter.getShortcuts()));
}
项目:intellij-ce-playground    文件:ScrollingUtil.java   
protected ListScrollAction(final ShortcutSet shortcutSet, final JComponent component) {
  registerCustomShortcutSet(shortcutSet, component);
}
项目:intellij-ce-playground    文件:PopupListElementRenderer.java   
@Override
protected void customizeComponent(JList list, Object value, boolean isSelected) {
  ListPopupStep<Object> step = myPopup.getListStep();
  boolean isSelectable = step.isSelectable(value);
  myTextLabel.setEnabled(isSelectable);
  if (!isSelected && step instanceof BaseListPopupStep) {
    Color bg = ((BaseListPopupStep)step).getBackgroundFor(value);
    Color fg = ((BaseListPopupStep)step).getForegroundFor(value);
    if (fg != null) myTextLabel.setForeground(fg);
    if (bg != null) UIUtil.setBackgroundRecursively(myComponent, bg);
  }

  if (step.isMnemonicsNavigationEnabled()) {
    final int pos = step.getMnemonicNavigationFilter().getMnemonicPos(value);
    if (pos != -1) {
      String text = myTextLabel.getText();
      text = text.substring(0, pos) + text.substring(pos + 1);
      myTextLabel.setText(text);
      myTextLabel.setDisplayedMnemonicIndex(pos);
    }
  }
  else {
    myTextLabel.setDisplayedMnemonicIndex(-1);
  }

  if (step.hasSubstep(value) && isSelectable) {
    myNextStepLabel.setVisible(true);
    final boolean isDark = ColorUtil.isDark(UIUtil.getListSelectionBackground());
    myNextStepLabel.setIcon(isSelected ? isDark ? AllIcons.Icons.Ide.NextStepInverted
                                                : AllIcons.Icons.Ide.NextStep
                                       : AllIcons.Icons.Ide.NextStepGrayed);
  }
  else {
    myNextStepLabel.setVisible(false);
    //myNextStepLabel.setIcon(PopupIcons.EMPTY_ICON);
  }

  setSelected(myNextStepLabel, isSelected);


  if (myShortcutLabel != null) {
    myShortcutLabel.setText("");
    if (value instanceof ShortcutProvider) {
      ShortcutSet set = ((ShortcutProvider)value).getShortcut();
      if (set != null) {
        Shortcut shortcut = ArrayUtil.getFirstElement(set.getShortcuts());
        if (shortcut != null) {
          myShortcutLabel.setText("     " + KeymapUtil.getShortcutText(shortcut));
        }
      }
    }
    setSelected(myShortcutLabel, isSelected);
    myShortcutLabel.setForeground(isSelected ? UIManager.getColor("MenuItem.acceleratorSelectionForeground") : UIManager.getColor("MenuItem.acceleratorForeground"));
  }
}
项目:intellij-ce-playground    文件:IntentionActionWithTextCaching.java   
@Nullable
@Override
public ShortcutSet getShortcut() {
  return myAction instanceof ShortcutProvider ? ((ShortcutProvider)myAction).getShortcut() : null;
}
项目:intellij-ce-playground    文件:OccurrenceAction.java   
@Nullable
@Override
public ShortcutSet getShortcut() {
  return getShortcutSet();
}
项目:intellij-ce-playground    文件:ContextAwareShortcutProvider.java   
@Nullable
ShortcutSet getShortcut(@NotNull DataContext context);
项目:tools-idea    文件:ComponentWithBrowseButton.java   
public void registerShortcut(JComponent textField) {
  ShortcutSet shiftEnter = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, KeyEvent.SHIFT_DOWN_MASK));
  registerCustomShortcutSet(shiftEnter, textField);
  myBrowseButton.setToolTipText(KeymapUtil.getShortcutsText(shiftEnter.getShortcuts()));
}
项目:tools-idea    文件:EnableLeft.java   
@Override
public ShortcutSet getShortcut() {
  return CustomShortcutSet.fromString("alt RIGHT");
}
项目:tools-idea    文件:RefreshDirDiffAction.java   
@Override
public ShortcutSet getShortcut() {
  return REFRESH_SHORTCUT;
}
项目:tools-idea    文件:EnableEqual.java   
@Override
public ShortcutSet getShortcut() {
  return CustomShortcutSet.fromString("alt EQUALS");
}
项目:tools-idea    文件:SynchronizeDiff.java   
@Override
public ShortcutSet getShortcut() {
  return CustomShortcutSet.fromString(mySelectedOnly ? "ENTER" : SystemInfo.isMac ? "meta ENTER" : "control ENTER");
}
项目:tools-idea    文件:EnableNotEqual.java   
@Override
public ShortcutSet getShortcut() {
  return CustomShortcutSet.fromString("alt MINUS");
}
项目:tools-idea    文件:EnableRight.java   
@Override
public ShortcutSet getShortcut() {
  return CustomShortcutSet.fromString("alt LEFT");
}
项目:consulo    文件:RefreshDirDiffAction.java   
@Override
public ShortcutSet getShortcut() {
  return REFRESH_SHORTCUT;
}
项目:consulo    文件:SynchronizeDiff.java   
@Override
public ShortcutSet getShortcut() {
  return CustomShortcutSet.fromString(mySelectedOnly ? "ENTER" : SystemInfo.isMac ? "meta ENTER" : "control ENTER");
}
项目:consulo    文件:DirDiffAction.java   
@javax.annotation.Nullable
@Override
public ShortcutSet getShortcut() {
  return getShortcutSet();
}
项目:consulo    文件:ComponentWithBrowseButton.java   
public void registerShortcut(JComponent textField) {
  ShortcutSet shiftEnter = new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK));
  registerCustomShortcutSet(shiftEnter, textField);
  myBrowseButton.setToolTipText(KeymapUtil.getShortcutsText(shiftEnter.getShortcuts()));
}
项目:consulo    文件:ScrollingUtil.java   
protected ListScrollAction(final ShortcutSet shortcutSet, final JComponent component) {
  super(component);
  registerCustomShortcutSet(shortcutSet, component);
}
项目:consulo    文件:Updater.java   
protected ShortcutSet getNextErrorShortcut() {
  return new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("GotoNextError"));
}
项目:consulo    文件:Updater.java   
protected ShortcutSet getPreviousErrorShortcut() {
  return new CustomShortcutSet(KeymapManager.getInstance().getActiveKeymap().getShortcuts("GotoPreviousError"));
}
项目:consulo    文件:PopupListElementRenderer.java   
@Override
protected void customizeComponent(JList<? extends E> list, E value, boolean isSelected) {
  ListPopupStep<Object> step = myPopup.getListStep();
  boolean isSelectable = step.isSelectable(value);
  myTextLabel.setEnabled(isSelectable);
  if (!isSelected && step instanceof BaseListPopupStep) {
    Color bg = ((BaseListPopupStep)step).getBackgroundFor(value);
    Color fg = ((BaseListPopupStep)step).getForegroundFor(value);
    if (fg != null) myTextLabel.setForeground(fg);
    if (bg != null) UIUtil.setBackgroundRecursively(myComponent, bg);
  }

  if (step.isMnemonicsNavigationEnabled()) {
    final int pos = step.getMnemonicNavigationFilter().getMnemonicPos(value);
    if (pos != -1) {
      String text = myTextLabel.getText();
      text = text.substring(0, pos) + text.substring(pos + 1);
      myTextLabel.setText(text);
      myTextLabel.setDisplayedMnemonicIndex(pos);
    }
  }
  else {
    myTextLabel.setDisplayedMnemonicIndex(-1);
  }

  if (step.hasSubstep(value) && isSelectable) {
    myNextStepLabel.setVisible(true);
    final boolean isDark = ColorUtil.isDark(UIUtil.getListSelectionBackground());
    myNextStepLabel.setIcon(isSelected ? isDark ? AllIcons.Icons.Ide.NextStepInverted
                                                : AllIcons.Icons.Ide.NextStep
                                       : AllIcons.Icons.Ide.NextStepGrayed);
  }
  else {
    myNextStepLabel.setVisible(false);
    //myNextStepLabel.setIcon(PopupIcons.EMPTY_ICON);
  }

  setSelected(myNextStepLabel, isSelected);


  if (myShortcutLabel != null) {
    myShortcutLabel.setEnabled(isSelectable);
    myShortcutLabel.setText("");
    if (value instanceof ShortcutProvider) {
      ShortcutSet set = ((ShortcutProvider)value).getShortcut();
      if (set != null) {
        Shortcut shortcut = ArrayUtil.getFirstElement(set.getShortcuts());
        if (shortcut != null) {
          myShortcutLabel.setText("     " + KeymapUtil.getShortcutText(shortcut));
        }
      }
    }
    setSelected(myShortcutLabel, isSelected);
    myShortcutLabel.setForeground(isSelected ? UIManager.getColor("MenuItem.acceleratorSelectionForeground") : UIManager.getColor("MenuItem.acceleratorForeground"));
  }
}
项目:consulo    文件:IntentionActionWithTextCaching.java   
@Nullable
@Override
public ShortcutSet getShortcut() {
  return myAction instanceof ShortcutProvider ? ((ShortcutProvider)myAction).getShortcut() : null;
}
项目:consulo    文件:IntentionActionWithTextCaching.java   
@Nullable
@Override
public ShortcutSet getShortcut() {
  return myAction instanceof ShortcutProvider ? ((ShortcutProvider)myAction).getShortcut() : null;
}
项目:consulo    文件:IntentionActionWrapper.java   
@Nullable
@Override
public ShortcutSet getShortcut() {
  IntentionAction delegate = getDelegate();
  return delegate instanceof ShortcutProvider ? ((ShortcutProvider)delegate).getShortcut() : null;
}
项目:consulo    文件:OccurrenceAction.java   
@Nullable
@Override
public ShortcutSet getShortcut() {
  return getShortcutSet();
}
项目:consulo    文件:ContextAwareShortcutProvider.java   
@Nullable
ShortcutSet getShortcut(@Nonnull DataContext context);
项目:ddescriber    文件:DescriberDialog.java   
MyAction(String name, TestState changeState, ShortcutSet shortcut, String tooltip) {
  super(name);
  this.changeState = changeState;
  registerForEveryKeyboardShortcut(this, shortcut);
  putValue(Action.SHORT_DESCRIPTION, tooltip);
}