Search in sources :

Example 16 with AnAction

use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.

the class XsltConfigImpl method initComponent.

@Override
@SuppressWarnings({ "StringEquality" })
public void initComponent() {
    final Language xmlLang = StdFileTypes.XML.getLanguage();
    //            intentionManager.addAction(new DeleteUnusedParameterFix());
    //            intentionManager.addAction(new DeleteUnusedVariableFix());
    final XsltFormattingModelBuilder builder = new XsltFormattingModelBuilder(LanguageFormatting.INSTANCE.forLanguage(xmlLang));
    LanguageFormatting.INSTANCE.addExplicitExtension(xmlLang, builder);
    try {
        // TODO: put this into com.intellij.refactoring.actions.IntroduceParameterAction, just like IntroduceVariableAction
        final AnAction introduceParameter = ActionManager.getInstance().getAction("IntroduceParameter");
        if (introduceParameter != null) {
            introduceParameter.setInjectedContext(true);
        }
    } catch (Exception e) {
        Logger.getInstance(XsltConfigImpl.class.getName()).error(e);
    }
}
Also used : Language(com.intellij.lang.Language) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 17 with AnAction

use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.

the class AssignShortcutAction method getGoalActionId.

@Nullable
private static String getGoalActionId(DataContext context) {
    final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
    if (goals == null || goals.size() != 1) {
        return null;
    }
    MavenProject project = MavenActionUtil.getMavenProject(context);
    if (project == null)
        return null;
    String goal = goals.get(0);
    final MavenShortcutsManager shortcutsManager = getShortcutsManager(context);
    String actionId = shortcutsManager != null ? shortcutsManager.getActionId(project.getPath(), goal) : null;
    if (actionId != null) {
        AnAction action = ActionManager.getInstance().getAction(actionId);
        if (action == null) {
            MavenKeymapExtension.getOrRegisterAction(project, actionId, goal);
        }
    }
    return actionId;
}
Also used : MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenShortcutsManager(org.jetbrains.idea.maven.tasks.MavenShortcutsManager) AnAction(com.intellij.openapi.actionSystem.AnAction) Nullable(org.jetbrains.annotations.Nullable)

Example 18 with AnAction

use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.

the class BoundIconRenderer method getClickAction.

@Override
@Nullable
public AnAction getClickAction() {
    return new AnAction() {

        @Override
        public void actionPerformed(AnActionEvent e) {
            List<PsiFile> formFiles = getBoundFormFiles();
            if (formFiles.size() > 0) {
                final VirtualFile virtualFile = formFiles.get(0).getVirtualFile();
                if (virtualFile == null) {
                    return;
                }
                Project project = myElement.getProject();
                FileEditor[] editors = FileEditorManager.getInstance(project).openFile(virtualFile, true);
                if (myElement instanceof PsiField) {
                    for (FileEditor editor : editors) {
                        if (editor instanceof UIFormEditor) {
                            ((UIFormEditor) editor).selectComponent(((PsiField) myElement).getName());
                        }
                    }
                }
            }
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) FileEditor(com.intellij.openapi.fileEditor.FileEditor) UIFormEditor(com.intellij.uiDesigner.editor.UIFormEditor) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with AnAction

use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.

the class XmlHighlightingTest method testResolvedDtdElementReferences.

public void testResolvedDtdElementReferences() throws Exception {
    configureByFile(BASE_PATH + getTestName(false) + ".dtd");
    doDoTest(true, false);
    final String text = myEditor.getDocument().getText();
    WriteCommandAction.runWriteCommandAction(null, () -> 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());
}
Also used : HighlightInfo(com.intellij.codeInsight.daemon.impl.HighlightInfo) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 20 with AnAction

use of com.intellij.openapi.actionSystem.AnAction in project intellij-community by JetBrains.

the class GroovyShellRunnerImpl method fillToolBarActions.

@Override
protected List<AnAction> fillToolBarActions(DefaultActionGroup toolbarActions, final Executor defaultExecutor, final RunContentDescriptor contentDescriptor) {
    BuildAndRestartConsoleAction rebuildAction = new BuildAndRestartConsoleAction(myModule, getProject(), defaultExecutor, contentDescriptor, myStarter);
    toolbarActions.add(rebuildAction);
    List<AnAction> actions = super.fillToolBarActions(toolbarActions, defaultExecutor, contentDescriptor);
    actions.add(rebuildAction);
    return actions;
}
Also used : BuildAndRestartConsoleAction(org.jetbrains.plugins.groovy.console.BuildAndRestartConsoleAction) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

AnAction (com.intellij.openapi.actionSystem.AnAction)184 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)62 NotNull (org.jetbrains.annotations.NotNull)31 Project (com.intellij.openapi.project.Project)24 Nullable (org.jetbrains.annotations.Nullable)22 ActionManager (com.intellij.openapi.actionSystem.ActionManager)21 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)21 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)13 ArrayList (java.util.ArrayList)13 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 ActionGroup (com.intellij.openapi.actionSystem.ActionGroup)7 Presentation (com.intellij.openapi.actionSystem.Presentation)7 PsiFile (com.intellij.psi.PsiFile)7 ReopenProjectAction (com.intellij.ide.ReopenProjectAction)6 Editor (com.intellij.openapi.editor.Editor)6 Keymap (com.intellij.openapi.keymap.Keymap)6 Ref (com.intellij.openapi.util.Ref)6 List (java.util.List)6 DataContext (com.intellij.openapi.actionSystem.DataContext)5