Search in sources :

Example 26 with AnActionEvent

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

the class LocalHistoryActionsTest method testShowSelectionHistoryActionForSelection.

public void testShowSelectionHistoryActionForSelection() throws Exception {
    editor.getSelectionModel().setSelection(0, 2);
    ShowSelectionHistoryAction a = new ShowSelectionHistoryAction();
    AnActionEvent e = createEventFor(a, new VirtualFile[] { f }, myProject);
    a.update(e);
    assertTrue(e.getPresentation().isEnabled());
    assertEquals("Show History for Selection", e.getPresentation().getText());
}
Also used : ShowSelectionHistoryAction(com.intellij.history.integration.ui.actions.ShowSelectionHistoryAction) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent)

Example 27 with AnActionEvent

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

the class ModifierKeyDoubleClickHandlerTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    Clock.setTime(0);
    ActionManager.getInstance().registerAction(MY_SHIFT_SHIFT_ACTION, new AnAction() {

        @Override
        public void actionPerformed(AnActionEvent e) {
            myShiftShiftActionInvocationCount++;
        }
    });
    ActionManager.getInstance().registerAction(MY_SHIFT_KEY_ACTION, new AnAction() {

        @Override
        public void actionPerformed(AnActionEvent e) {
            myShiftKeyActionInvocationCount++;
        }
    });
    ActionManager.getInstance().registerAction(MY_SHIFT_SHIFT_KEY_ACTION, new AnAction() {

        @Override
        public void actionPerformed(AnActionEvent e) {
            myShiftShiftKeyActionInvocationCount++;
        }
    });
    ActionManager.getInstance().registerAction(MY_SHIFT_OTHER_KEY_ACTION, new AnAction() {

        @Override
        public void actionPerformed(AnActionEvent e) {
            myShiftOtherKeyActionInvocationCount++;
        }
    });
    KeymapManager.getInstance().getActiveKeymap().addShortcut(MY_SHIFT_KEY_ACTION, SHIFT_KEY_SHORTCUT);
    KeymapManager.getInstance().getActiveKeymap().addShortcut(MY_SHIFT_OTHER_KEY_ACTION, SHIFT_OTHER_KEY_SHORTCUT);
    ModifierKeyDoubleClickHandler.getInstance().registerAction(MY_SHIFT_SHIFT_ACTION, KeyEvent.VK_SHIFT, -1);
    ModifierKeyDoubleClickHandler.getInstance().registerAction(MY_SHIFT_SHIFT_KEY_ACTION, KeyEvent.VK_SHIFT, KeyEvent.VK_BACK_SPACE);
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 28 with AnActionEvent

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

the class XValueHint method showHint.

@Override
protected boolean showHint(final JComponent component) {
    boolean result = super.showHint(component);
    if (result && getType() == ValueHintType.MOUSE_OVER_HINT) {
        myDisposable = Disposer.newDisposable();
        ShortcutSet shortcut = ActionManager.getInstance().getAction("ShowErrorDescription").getShortcutSet();
        new DumbAwareAction() {

            @Override
            public void actionPerformed(@NotNull AnActionEvent e) {
                hideHint();
                final Point point = new Point(myPoint.x, myPoint.y + getEditor().getLineHeight());
                new XValueHint(getProject(), getEditor(), point, ValueHintType.MOUSE_CLICK_HINT, myExpressionInfo, myEvaluator, myDebugSession).invokeHint();
            }
        }.registerCustomShortcutSet(shortcut, getEditor().getContentComponent(), myDisposable);
    }
    if (result) {
        XValueHint prev = getEditor().getUserData(HINT_KEY);
        if (prev != null) {
            prev.hideHint();
        }
        getEditor().putUserData(HINT_KEY, this);
    }
    return result;
}
Also used : ShortcutSet(com.intellij.openapi.actionSystem.ShortcutSet) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) DumbAwareAction(com.intellij.openapi.project.DumbAwareAction)

Example 29 with AnActionEvent

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

the class AbstractLanguageInjectionSupport method createDefaultAddAction.

public static AnAction createDefaultAddAction(final Project project, final Consumer<BaseInjection> consumer, final AbstractLanguageInjectionSupport support) {
    final String supportTitle = StringUtil.capitalize(support.getId());
    Icon icon = FileTypeManager.getInstance().getFileTypeByExtension(support.getId()).getIcon();
    return new AnAction("Generic " + supportTitle, null, icon) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            final BaseInjection injection = new BaseInjection(support.getId());
            injection.setDisplayName("New " + supportTitle + " Injection");
            final BaseInjection newInjection = showDefaultInjectionUI(project, injection);
            if (newInjection != null) {
                consumer.consume(injection);
            }
        }
    };
}
Also used : AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) BaseInjection(org.intellij.plugins.intelliLang.inject.config.BaseInjection)

Example 30 with AnActionEvent

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

the class ImportTree method createIncludeAction.

public AnAction createIncludeAction() {
    return new AnAction(CvsBundle.message("import.wizard.include.to.import.action.name"), null, IconUtil.getAddIcon()) {

        public void update(AnActionEvent e) {
            final VirtualFile[] selectedFiles = myFileSystemTree.getSelectedFiles();
            final Presentation presentation = e.getPresentation();
            presentation.setEnabled(isAtLeastOneFileExcluded(selectedFiles));
        }

        public void actionPerformed(AnActionEvent e) {
            final VirtualFile[] selectedFiles = myFileSystemTree.getSelectedFiles();
            for (VirtualFile selectedFile : selectedFiles) {
                include(selectedFile);
            }
            myWizard.updateStep();
            myFileSystemTree.getTree().repaint();
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Presentation(com.intellij.openapi.actionSystem.Presentation) AnAction(com.intellij.openapi.actionSystem.AnAction)

Aggregations

AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)167 AnAction (com.intellij.openapi.actionSystem.AnAction)76 Project (com.intellij.openapi.project.Project)33 NotNull (org.jetbrains.annotations.NotNull)29 VirtualFile (com.intellij.openapi.vfs.VirtualFile)28 DumbAwareAction (com.intellij.openapi.project.DumbAwareAction)27 Nullable (org.jetbrains.annotations.Nullable)21 List (java.util.List)19 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)18 Test (org.junit.Test)16 CustomShortcutSet (com.intellij.openapi.actionSystem.CustomShortcutSet)13 ArrayList (java.util.ArrayList)13 SonarTest (org.sonarlint.intellij.SonarTest)13 Presentation (com.intellij.openapi.actionSystem.Presentation)12 JBTable (com.intellij.ui.table.JBTable)12 AnActionButton (com.intellij.ui.AnActionButton)11 Notification (com.intellij.notification.Notification)10 CommonDataKeys (com.intellij.openapi.actionSystem.CommonDataKeys)10 StringUtil (com.intellij.openapi.util.text.StringUtil)9 ToolbarDecorator (com.intellij.ui.ToolbarDecorator)9