本文整理汇总了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);
}
}
}
示例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..
}
}
}
示例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;
}
示例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());
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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();
}
示例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));
}
示例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);
}
示例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);
}
}
示例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;
}
示例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));
}