Search in sources :

Example 11 with AnAction

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

the class PyUnwrapperTest method doNegativeTest.

private void doNegativeTest(final String optionName) {
    String before = "refactoring/unwrap/" + getTestName(true) + "_before.py";
    myFixture.configureByFile(before);
    UnwrapHandler h = new UnwrapHandler() {

        @Override
        protected void selectOption(List<AnAction> options, Editor editor, PsiFile file) {
            for (AnAction option : options) {
                assertFalse("\"" + optionName + "\" is available to unwrap ", option.toString().contains(optionName));
            }
        }
    };
    h.invoke(myFixture.getProject(), myFixture.getEditor(), myFixture.getFile());
}
Also used : UnwrapHandler(com.intellij.codeInsight.unwrap.UnwrapHandler) List(java.util.List) PsiFile(com.intellij.psi.PsiFile) Editor(com.intellij.openapi.editor.Editor) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 12 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 13 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)

Example 14 with AnAction

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

the class HgBranchPopup method getInstance.

/**
   * @param currentRepository Current repository, which means the repository of the currently open or selected file.
   */
public static HgBranchPopup getInstance(@NotNull Project project, @NotNull HgRepository currentRepository) {
    HgRepositoryManager manager = HgUtil.getRepositoryManager(project);
    HgProjectSettings hgProjectSettings = ServiceManager.getService(project, HgProjectSettings.class);
    HgMultiRootBranchConfig hgMultiRootBranchConfig = new HgMultiRootBranchConfig(manager.getRepositories());
    Condition<AnAction> preselectActionCondition = new Condition<AnAction>() {

        @Override
        public boolean value(AnAction action) {
            return false;
        }
    };
    return new HgBranchPopup(currentRepository, manager, hgMultiRootBranchConfig, hgProjectSettings, preselectActionCondition);
}
Also used : Condition(com.intellij.openapi.util.Condition) HgRepositoryManager(org.zmlx.hg4idea.repo.HgRepositoryManager) HgProjectSettings(org.zmlx.hg4idea.HgProjectSettings) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 15 with AnAction

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

the class JBTabbedTerminalWidget method convertActions.

public static void convertActions(@NotNull JComponent component, @NotNull List<TerminalAction> actions, @Nullable final Predicate<KeyEvent> elseAction) {
    for (final TerminalAction action : actions) {
        if (action.isHidden()) {
            continue;
        }
        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);
    }
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction)

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