コード例 #1
0
  private static boolean itemsHaveMnemonics(final List<ActionItem> items) {
    for (ActionItem item : items) {
      if (item.getAction().getTemplatePresentation().getMnemonic() != 0) return true;
    }

    return false;
  }
コード例 #2
0
    @Override
    public PopupStep onChosen(
        ActionItem actionChoice, boolean finalChoice, final int eventModifiers) {
      if (!actionChoice.isEnabled()) return FINAL_CHOICE;
      final AnAction action = actionChoice.getAction();
      DataManager mgr = DataManager.getInstance();

      final DataContext dataContext =
          myContext != null ? mgr.getDataContext(myContext) : mgr.getDataContext();

      if (action instanceof ActionGroup
          && (!finalChoice || !((ActionGroup) action).canBePerformed(dataContext))) {
        return createActionsStep(
            (ActionGroup) action,
            dataContext,
            myEnableMnemonics,
            true,
            myShowDisabledActions,
            null,
            myContext,
            false,
            myPreselectActionCondition,
            false);
      } else {
        myFinalRunnable =
            new Runnable() {
              @Override
              public void run() {
                action.actionPerformed(
                    new AnActionEvent(
                        null,
                        dataContext,
                        ActionPlaces.UNKNOWN,
                        action.getTemplatePresentation().clone(),
                        ActionManager.getInstance(),
                        eventModifiers));
              }
            };
        return FINAL_CHOICE;
      }
    }
コード例 #3
0
 @Override
 public boolean hasSubstep(final ActionItem selectedValue) {
   return selectedValue != null
       && selectedValue.isEnabled()
       && selectedValue.getAction() instanceof ActionGroup;
 }