當前位置: 首頁>>代碼示例>>Java>>正文


Java AnAction類代碼示例

本文整理匯總了Java中com.intellij.openapi.actionSystem.AnAction的典型用法代碼示例。如果您正苦於以下問題:Java AnAction類的具體用法?Java AnAction怎麽用?Java AnAction使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AnAction類屬於com.intellij.openapi.actionSystem包,在下文中一共展示了AnAction類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: initBPMNModelMenu

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
public void initBPMNModelMenu() {
    DefaultActionGroup modelMenu = (DefaultActionGroup) ActionManager.getInstance().getAction("yaoqiang.actions.BPMNModelMenu");
    AppMenu model = new ModelMenu();
    for (int i = 0; i < model.getItemCount(); i++) {
        JMenuItem item = model.getItem(i);
        if (item == null) {
            modelMenu.addSeparator();
        } else {
            AnAction action = new AnAction(item.getText()) {
                @Override
                public void actionPerformed(AnActionEvent e) {
                    item.getAction().actionPerformed(new ActionEvent(e, 0, ""));
                }
            };
            modelMenu.add(action);
        }
    }
}
 
開發者ID:Blenta,項目名稱:intellij-bpmn-editor,代碼行數:19,代碼來源:BPMNEditor.java

示例2: analyzeActionMenuItem

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
/**
 * Information extraction for entries in the menu
 *
 * @param source source of the action
 */
private void analyzeActionMenuItem(ActionMenuItem source) {
    mySource = ActionSource.MENU_ENTRY;
    myDescription = source.getText();
    myMnemonic = source.getMnemonic();
    final Field actionField = findActionField(source, ActionRef.class);
    if (actionField != null) {
        try {
            final ActionRef o = (ActionRef) actionField.get(source);
            final AnAction action = o.getAction();
            if (action != null) {
                fixValuesFromAction(action);
            }
        } catch (Exception e) {
            // happens..
        }
    }
}
 
開發者ID:halirutan,項目名稱:IntelliJ-Key-Promoter-X,代碼行數:23,代碼來源:KeyPromoterAction.java

示例3: getListCellRendererComponent

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
@Override
public JLabel getListCellRendererComponent(JList<? extends StatisticsItem> list, StatisticsItem value, int index, boolean isSelected, boolean cellHasFocus) {
    final Color foreground = list.getForeground();
    final String message = KeyPromoterBundle.message(
            "kp.list.item",
            value.getShortcut(),
            value.description,
            value.count,
            value.count == 1 ? "time" : "times"
            );
    setText(message);
    setForeground(foreground);
    setBorder(new EmptyBorder(2,10,2,10));
    if (value.ideaActionID != null && !"".equals(value.ideaActionID)) {
        final AnAction action = ActionManager.getInstance().getAction(value.ideaActionID);
        if (action != null) {
            final Icon icon = action.getTemplatePresentation().getIcon();
            if (icon != null) {
                setIcon(icon);
            }
        }
    }
    return this;
}
 
開發者ID:halirutan,項目名稱:IntelliJ-Key-Promoter-X,代碼行數:25,代碼來源:StatisticsList.java

示例4: run

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
@Override
public void run(AnActionButton button) {
    // 獲取選中節點
    final DefaultMutableTreeNode selectedNode = getSelectedNode();
    if (selectedNode == null) {
        return;
    }
    List<AnAction> actions = getMultipleActions(selectedNode);
    if (actions == null || actions.isEmpty()) {
        return;
    }
    // 顯示新增按鈕
    final DefaultActionGroup group = new DefaultActionGroup(actions);
    JBPopupFactory.getInstance()
            .createActionGroupPopup(null, group, DataManager.getInstance().getDataContext(button.getContextComponent()),
                    JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, true).show(button.getPreferredPopupPoint());
}
 
開發者ID:hykes,項目名稱:CodeGen,代碼行數:18,代碼來源:TemplateAddAction.java

示例5: getComponentAction

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
@Nullable
public AnAction getComponentAction(){
  if (myComponent instanceof Separator){
    return Separator.getInstance();
  }
  if (myComponent instanceof String){
    return ActionManager.getInstance().getAction((String)myComponent);
  }
  if (myComponent instanceof Group){
    final String id = ((Group)myComponent).getId();
    if (id == null || id.length() == 0){
      return ((Group)myComponent).constructActionGroup(true);
    }
    return ActionManager.getInstance().getAction(id);
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:18,代碼來源:ActionUrl.java

示例6: actionPerformed

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
@Override
public void actionPerformed(AnActionEvent e) {
  List<AnAction> elements = getSelectedElements(e);
  String path = ((ReopenProjectAction)elements.get(0)).getProjectPath();
  final ChangeProjectIconForm form = new ChangeProjectIconForm(path);
  DialogWrapper dialog = new DialogWrapper(null) {
    {
      init();
    }

    @Nullable
    @Override
    protected JComponent createCenterPanel() {
      return form.myRootPanel;
    }
  };
  dialog.show();
  if (dialog.isOK()) {
    try {
      form.apply();
    }
    catch (IOException e1) {
      System.out.println(e1);
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:ChangeProjectIconAction.java

示例7: processKeymap

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
private static void processKeymap(final Element configurableElement){
  final ActionManager actionManager = ActionManager.getInstance();
  final String componentName = actionManager.getComponentName();
  final SearchableOptionsRegistrar searchableOptionsRegistrar = SearchableOptionsRegistrar.getInstance();
  final Set<String> ids = ((ActionManagerImpl)actionManager).getActionIds();
  final TreeSet<OptionDescription> options = new TreeSet<OptionDescription>();
  for (String id : ids) {
    final AnAction anAction = actionManager.getAction(id);
    final String text = anAction.getTemplatePresentation().getText();
    if (text != null) {
      collectOptions(searchableOptionsRegistrar, options, text, componentName);
    }
    final String description = anAction.getTemplatePresentation().getDescription();
    if (description != null) {
      collectOptions(searchableOptionsRegistrar, options, description, componentName);
    }
  }
  writeOptions(configurableElement, options);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:TraverseUIStarter.java

示例8: convertActions

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
public static void convertActions(@NotNull JComponent component,
                                  @NotNull List<TerminalAction> actions,
                                  @Nullable final Predicate<KeyEvent> elseAction) {
  for (final TerminalAction action : actions) {
    AnAction a = new DumbAwareAction() {
      @Override
      public void actionPerformed(AnActionEvent e) {
        KeyEvent event = e.getInputEvent() instanceof KeyEvent ? (KeyEvent)e.getInputEvent() : null;
        if (!action.perform(event)) {
          if (elseAction != null) {
            elseAction.apply(event);
          }
        }
      }
    };
    a.registerCustomShortcutSet(action.getKeyCode(), action.getModifiers(), component);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:JBTabbedTerminalWidget.java

示例9: execute

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
@Override
public ExecutionResult execute(Executor executor, CommandLinePatcher... patchers) throws ExecutionException {
  final ProcessHandler processHandler = startProcess(patchers);
  final ConsoleView console = createAndAttachConsole(myConfiguration.getProject(), processHandler, executor);

  List<AnAction> actions = Lists
    .newArrayList(createActions(console, processHandler));

  DefaultExecutionResult executionResult =
    new DefaultExecutionResult(console, processHandler, actions.toArray(new AnAction[actions.size()]));

  PyRerunFailedTestsAction rerunFailedTestsAction = new PyRerunFailedTestsAction(console);
  if (console instanceof SMTRunnerConsoleView) {
    rerunFailedTestsAction.init(((BaseTestsOutputConsoleView)console).getProperties());
    rerunFailedTestsAction.setModelProvider(new Getter<TestFrameworkRunningModel>() {
    @Override
    public TestFrameworkRunningModel get() {
      return ((SMTRunnerConsoleView)console).getResultsViewer();
    }
  });
  }

  executionResult.setRestartActions(rerunFailedTestsAction, new ToggleAutoTestAction());
  return executionResult;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:PythonTestCommandLineStateBase.java

示例10: disposeComponent

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
@Override
public void disposeComponent() {
    ActionManager am = ActionManager.getInstance();

    // Gets an instance of the WindowMenu action group.
    DefaultActionGroup menuManager = (DefaultActionGroup) am.getAction(COMPONENT_GROUP); //(IdeActions.GROUP_EDITOR_POPUP); //"EditorPopupMenu");

    for (AnAction a : menuManager.getChildActionsOrStubs()) {
        if (a.getClass() == LaunchSearchAction.class) {
            am.unregisterAction(getActionId((LaunchSearchAction) a));
        }
    }

    // Adds a separator and a new menu command to the WindowMenu group on the main menu.
    menuManager.removeAll();
}
 
開發者ID:maddouri,項目名稱:IntelliJ-OnlineSearch,代碼行數:17,代碼來源:LaunchSearchActionRegistration.java

示例11: enableSetIconButton

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
protected void enableSetIconButton(ActionManager actionManager) {
  final TreePath selectionPath = myTree.getSelectionPath();
  Object userObject = null;
  if (selectionPath != null) {
    userObject = ((DefaultMutableTreeNode)selectionPath.getLastPathComponent()).getUserObject();
    if (userObject instanceof String) {
      final AnAction action = actionManager.getAction((String)userObject);
      if (action != null && action.getTemplatePresentation().getIcon() != null) {
        mySetIconButton.setEnabled(true);
        return;
      }
    }
  }
  mySetIconButton.setEnabled(myTextField.getText().length() != 0 &&
                             selectionPath != null &&
                             new DefaultMutableTreeNode(selectionPath).isLeaf() &&
                             !(userObject instanceof Separator));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:CustomizableActionsPanel.java

示例12: assertOptions

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
protected void assertOptions(String code, String... expectedOptions) throws IOException {
  configureCode(code);

  final List<String> actualOptions = new ArrayList<String>();

  UnwrapHandler h = new UnwrapHandler() {
    @Override
    protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
      for (AnAction each : options) {
        actualOptions.add(each.getTemplatePresentation().getText());
      }
    }
  };

  h.invoke(getProject(), getEditor(), getFile());

  assertEquals(Arrays.asList(expectedOptions), actualOptions);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:UnwrapTestCase.java

示例13: updateRecentProjectsMenu

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
@Override
public void updateRecentProjectsMenu () {
  RecentProjectsManager projectsManager = RecentProjectsManager.getInstance();
  if (projectsManager == null) return;
  final AnAction[] recentProjectActions = projectsManager.getRecentProjectsActions(false);
  recentProjectsMenu.removeAll();

  for (final AnAction action : recentProjectActions) {
    MenuItem menuItem = new MenuItem(((ReopenProjectAction)action).getProjectName());
    menuItem.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        action.actionPerformed(AnActionEvent.createFromAnAction(action, null, ActionPlaces.DOCK_MENU, DataManager.getInstance().getDataContext(null)));
      }
    });
    recentProjectsMenu.add(menuItem);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:MacDockDelegate.java

示例14: createTreePanel

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
@NotNull
public static ToolWindowAlikePanel createTreePanel(@NotNull String title, @NotNull JTree tree) {
  ToolWindowAlikePanel panel = new ToolWindowAlikePanel(title, createScrollPane(tree));

  Object root = tree.getModel().getRoot();
  if (root instanceof TreeNode && ((TreeNode)root).getChildCount() > 0) {
    TreeExpander expander = new DefaultTreeExpander(tree);
    CommonActionsManager actions = CommonActionsManager.getInstance();

    AnAction expandAllAction = actions.createExpandAllAction(expander, tree);
    expandAllAction.getTemplatePresentation().setIcon(ExpandAll);

    AnAction collapseAllAction = actions.createCollapseAllAction(expander, tree);
    collapseAllAction.getTemplatePresentation().setIcon(CollapseAll);

    panel.setAdditionalTitleActions(expandAllAction, collapseAllAction);
  }

  return panel;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:21,代碼來源:ToolWindowAlikePanel.java

示例15: createActions

import com.intellij.openapi.actionSystem.AnAction; //導入依賴的package包/類
@NotNull
public VcsCommittedViewAuxiliary createActions(@NotNull DecoratorManager manager, @Nullable RepositoryLocation location) {
  final RootsAndBranches rootsAndBranches = new RootsAndBranches(myVcs, manager, location);
  refreshMergeInfo(rootsAndBranches);

  final DefaultActionGroup popup = new DefaultActionGroup(myVcs.getDisplayName(), true);
  popup.add(rootsAndBranches.getIntegrateAction());
  popup.add(rootsAndBranches.getUndoIntegrateAction());
  popup.add(new ConfigureBranchesAction());

  final ShowHideMergePanelAction action = new ShowHideMergePanelAction(manager, rootsAndBranches.getStrategy());

  return new VcsCommittedViewAuxiliary(Collections.<AnAction>singletonList(popup), new Runnable() {
    public void run() {
      if (myMergeInfoUpdatesListener != null) {
        myMergeInfoUpdatesListener.removePanel(rootsAndBranches);
        rootsAndBranches.dispose();
      }
    }
  }, Collections.<AnAction>singletonList(action));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:SvnCommittedChangesProvider.java


注:本文中的com.intellij.openapi.actionSystem.AnAction類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。