当前位置: 首页>>代码示例>>Java>>正文


Java AnAction.actionPerformed方法代码示例

本文整理汇总了Java中com.intellij.openapi.actionSystem.AnAction.actionPerformed方法的典型用法代码示例。如果您正苦于以下问题:Java AnAction.actionPerformed方法的具体用法?Java AnAction.actionPerformed怎么用?Java AnAction.actionPerformed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.actionSystem.AnAction的用法示例。


在下文中一共展示了AnAction.actionPerformed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
private void run(KeyEvent event) {
  myIsRunningAction = true;
  try {
    ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
    AnAction action = actionManager.getAction(myActionId);
    DataContext context = DataManager.getInstance().getDataContext(IdeFocusManager.findInstance().getFocusOwner());
    AnActionEvent anActionEvent = AnActionEvent.createFromAnAction(action, event, ActionPlaces.MAIN_MENU, context);

    actionManager.fireBeforeActionPerformed(action, anActionEvent.getDataContext(), anActionEvent);
    action.actionPerformed(anActionEvent);
    actionManager.fireAfterActionPerformed(action, anActionEvent.getDataContext(), anActionEvent);
  }
  finally {
    myIsRunningAction = false;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ModifierKeyDoubleClickHandler.java

示例2: testResolvedDtdElementReferences

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
public void testResolvedDtdElementReferences() throws Exception {
  configureByFile(BASE_PATH + getTestName(false)+".dtd");
  doDoTest(true, false);

  final String text = myEditor.getDocument().getText();
  WriteCommandAction.runWriteCommandAction(null, new Runnable() {
    @Override
    public void run() {
      myEditor.getSelectionModel().setSelection(0, myEditor.getDocument().getTextLength());
    }
  });

  AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_COMMENT_BLOCK);
  action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext()));
  assertNotSame(text,myEditor.getDocument().getText());
  PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument());
  Collection<HighlightInfo> infos = doHighlighting();
  assertEquals(0, infos.size());

  action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext()));
  assertEquals(text,myEditor.getDocument().getText().trim());
  PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument());
  infos = doHighlighting();
  assertEquals(0, infos.size());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:XmlHighlightingTest.java

示例3: testSatisfied

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
public void testSatisfied() throws Exception {
  ProjectSdksModel model = new ProjectSdksModel();
  model.addSdk(IdeaTestUtil.getMockJdk17());
  ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
  Sdk sdk = jdkTable.createSdk("a", AndroidSdkType.getInstance());
  mySdks.add(sdk);
  jdkTable.addJdk(sdk);
  AnAction action = getAddAction(model);
  try {
    action.actionPerformed(new TestActionEvent(action));
    fail("Exception should be thrown");
  }
  catch (Exception e) {
    assertEquals(AndroidBundle.message("cannot.parse.sdk.error"), e.getMessage());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AndroidSdkTypeNewProjectWizardTest.java

示例4: executeAction

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
public static void executeAction(String actionId, InputEvent e) {
    ActionManager actionManager = ActionManager.getInstance();
    AnAction action = actionManager.getAction(actionId);
    if (action != null) {
        Presentation presentation = new Presentation();
        AnActionEvent event = new AnActionEvent(e, DataManager.getInstance().getDataContext(e.getComponent()), "", presentation, actionManager, 0);
        action.update(event);
        if (presentation.isEnabled()) {
            action.actionPerformed(event);
        }
    }
}
 
开发者ID:seedstack,项目名称:intellij-plugin,代码行数:13,代码来源:NavigatorUtil.java

示例5: invoke

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
    final PsiElement intentionElement = getIntentionElement(element);
    for (PsiReference psiReference : intentionElement.getReferences()) {
        if (psiReference instanceof CssModulesUnknownClassPsiReference) {
            final String className = psiReference.getRangeInElement().substring(intentionElement.getText());
            final StylesheetFile stylesheetFile = ((CssModulesUnknownClassPsiReference) psiReference).getStylesheetFile();
            stylesheetFile.navigate(true);
            PsiElement ruleset = CssElementFactory.getInstance(project).createRuleset("." + className + " {\n\n}", stylesheetFile.getLanguage());
            ruleset = stylesheetFile.add(ruleset);
            final int newCaretOffset = ruleset.getTextOffset() + ruleset.getText().indexOf("{") + 2; // after '{\n'
            final FileEditor[] editors = FileEditorManager.getInstance(project).getEditors(stylesheetFile.getVirtualFile());
            for (FileEditor fileEditor : editors) {
                if (fileEditor instanceof TextEditor) {
                    final Editor cssEditor = ((TextEditor) fileEditor).getEditor();
                    cssEditor.getCaretModel().moveToOffset(newCaretOffset);
                    AnAction editorLineEnd = ActionManager.getInstance().getAction("EditorLineEnd");
                    if (editorLineEnd != null) {
                        final AnActionEvent actionEvent = AnActionEvent.createFromDataContext(
                                ActionPlaces.UNKNOWN,
                                null,
                                new DataManagerImpl.MyDataContext(cssEditor.getComponent())
                        );
                        PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(cssEditor.getDocument());
                        editorLineEnd.actionPerformed(actionEvent);
                    }
                }
            }
            return;
        }
    }
}
 
开发者ID:jimkyndemeyer,项目名称:react-css-modules-intellij-plugin,代码行数:33,代码来源:CssModulesCreateClassIntention.java

示例6: invokeAction

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
private void invokeAction() {
  final String actionId = getActionId();
  final AnAction action = ActionManager.getInstance().getAction(actionId);
  //noinspection HardCodedStringLiteral
  assertNotNull("Can find registered action with id=" + actionId, action);
  action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:EditorActionTestCase.java

示例7: performActionDumbAware

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
public static void performActionDumbAware(AnAction action, AnActionEvent e) {
  try {
    action.actionPerformed(e);
  }
  catch (IndexNotReadyException e1) {
    showDumbModeWarning(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ActionUtil.java

示例8: executeAction

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
protected void executeAction(final String actionId) {
  final AnAction action = ActionManager.getInstance().getAction(actionId);
  final AnActionEvent event = AnActionEvent.createFromAnAction(action, null, ActionPlaces.UNKNOWN,
                                                               DataManager.getInstance().getDataContext(this));
  action.beforeActionPerformedUpdate(event);
  action.update(event);

  if (event.getPresentation().isEnabled() && event.getPresentation().isVisible()) {
    action.actionPerformed(event);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:EditorNotificationPanel.java

示例9: actionPerformed

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  List<AnAction> elements = getSelectedElements(e);
  e = new AnActionEvent(e.getInputEvent(), e.getDataContext(), e.getPlace(), e.getPresentation(), e.getActionManager(), InputEvent.SHIFT_MASK);
  for (AnAction element : elements) {
    if (element instanceof ProjectGroupActionGroup) {
      for (AnAction action : ((ProjectGroupActionGroup)element).getChildren(e)) {
        action.actionPerformed(e);
      }
    } else {
      element.actionPerformed(e);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:OpenSelectedProjectsAction.java

示例10: actionPerformed

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
@Override
public final void actionPerformed(AnActionEvent e){
  DataContext dataContext = e.getDataContext();

  IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
  if (view == null) {
    return;
  }
  PsiDirectory dir = getTargetDirectory(dataContext, view);
  if (dir == null) return;
  Project project = dir.getProject();

  FileTemplate selectedTemplate = getTemplate(project, dir);
  if (selectedTemplate != null){
    AnAction action = getReplacedAction(selectedTemplate);
    if (action != null) {
      action.actionPerformed(e);
    }
    else {
      FileTemplateManager.getInstance(project).addRecentName(selectedTemplate.getName());
      final AttributesDefaults defaults = getAttributesDefaults(dataContext);
      final CreateFromTemplateDialog dialog = new CreateFromTemplateDialog(project, dir, selectedTemplate, defaults,
                                                                           defaults != null ? defaults.getDefaultProperties() : null);
      PsiElement createdElement = dialog.create();
      if (createdElement != null) {
        elementCreated(dialog, createdElement);
        view.selectElement(createdElement);
        if (selectedTemplate.isLiveTemplateEnabled() && createdElement instanceof PsiFile) {
          startLiveTemplate((PsiFile)createdElement);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:CreateFromTemplateActionBase.java

示例11: testUnsatisfied

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
public void testUnsatisfied() throws Exception {
  ProjectSdksModel model = new ProjectSdksModel();
  AnAction action = getAddAction(model);
  try {
    action.actionPerformed(new TestActionEvent(action));
    fail("Exception should be thrown");
  }
  catch (Exception e) {
    e.printStackTrace();
    assertEquals(AndroidSdkType.getInstance().getUnsatisfiedDependencyMessage(), e.getMessage());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:AndroidSdkTypeNewProjectWizardTest.java

示例12: executeAction

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
public static void executeAction(final String actionId, final InputEvent e) {
  final ActionManager actionManager = ActionManager.getInstance();
  final AnAction action = actionManager.getAction(actionId);
  if (action != null) {
    final Presentation presentation = new Presentation();
    final AnActionEvent event =
      new AnActionEvent(e, DataManager.getInstance().getDataContext(e.getComponent()), "", presentation, actionManager, 0);
    action.update(event);
    if (presentation.isEnabled()) {
      action.actionPerformed(event);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:MavenUIUtil.java

示例13: invokeAction

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
private void invokeAction(final AnActionEvent e) {
  final AnAction action = ActionManager.getInstance().getAction(myActionId);
  if (action == null || action instanceof TargetActionStub) {
    return;
  }
  if (!myActionInvoked.getAndSet(true)) {
    //final DataContext context = e.getDataContext();
    //if (context instanceof DataManagerImpl.MyDataContext) {
    //  // hack: macro.expand() can cause UI events such as showing dialogs ('Prompt' macro) which may 'invalidate' the datacontext
    //  // since we know exactly that context is valid, we need to update its event count
    //  ((DataManagerImpl.MyDataContext)context).setEventCount(IdeEventQueue.getInstance().getEventCount());
    //}
    action.actionPerformed(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:TargetActionStub.java

示例14: launchAction

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
private void launchAction(VirtualFile virtualFile, AnAction action) {
  TestActionEvent e = getActionEvent(virtualFile, action);
  action.beforeActionPerformedUpdate(e);
  assertTrue(e.getPresentation().isEnabled() && e.getPresentation().isVisible());
  action.actionPerformed(e);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:7,代码来源:CCTaskFileActionTest.java

示例15: doAction

import com.intellij.openapi.actionSystem.AnAction; //导入方法依赖的package包/类
public static void doAction(CodeInsightTestCase testCase, AnAction action, String testName, String ext) throws Exception {
  testCase.configureByFile(testName + "." + ext);

  action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext()));

  testCase.checkResultByFile(testName + "_after." + ext);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:CodeInsightTestCaseUtil.java


注:本文中的com.intellij.openapi.actionSystem.AnAction.actionPerformed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。