Search in sources :

Example 46 with AnAction

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

the class OpenSelectedProjectsAction method actionPerformed.

@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);
        }
    }
}
Also used : ProjectGroupActionGroup(com.intellij.ide.ProjectGroupActionGroup) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 47 with AnAction

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

the class OpenSelectedProjectsAction method update.

@Override
public void update(AnActionEvent e) {
    final Presentation presentation = e.getPresentation();
    List<AnAction> selectedElements = getSelectedElements(e);
    boolean hasProject = false;
    boolean hasGroup = false;
    for (AnAction element : selectedElements) {
        if (element instanceof ReopenProjectAction) {
            hasProject = true;
        }
        if (element instanceof ProjectGroupActionGroup) {
            hasGroup = true;
        }
        if (hasGroup && hasProject) {
            e.getPresentation().setEnabled(false);
            return;
        }
    }
    if (ActionPlaces.WELCOME_SCREEN.equals(e.getPlace())) {
        presentation.setEnabledAndVisible(true);
        if (selectedElements.size() == 1 && selectedElements.get(0) instanceof ProjectGroupActionGroup) {
            presentation.setText("Open All Projects in Group");
        } else {
            presentation.setText("Open Selected");
        }
    } else {
        presentation.setEnabledAndVisible(false);
    }
}
Also used : ReopenProjectAction(com.intellij.ide.ReopenProjectAction) ProjectGroupActionGroup(com.intellij.ide.ProjectGroupActionGroup) Presentation(com.intellij.openapi.actionSystem.Presentation) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 48 with AnAction

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

the class RemoveSelectedProjectsAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    RecentProjectsManager mgr = RecentProjectsManager.getInstance();
    for (AnAction action : getSelectedElements(e)) {
        if (action instanceof ReopenProjectAction) {
            String path = ((ReopenProjectAction) action).getProjectPath();
            mgr.removePath(path);
        } else if (action instanceof ProjectGroupActionGroup) {
            ProjectGroupActionGroup group = (ProjectGroupActionGroup) action;
            for (String path : group.getGroup().getProjects()) {
                mgr.removePath(path);
            }
            mgr.removeGroup(group.getGroup());
        }
        rebuildRecentProjectsList(e);
        JList list = getList(e);
        if (list != null) {
            ScrollingUtil.ensureSelectionExists(list);
        }
    }
}
Also used : ReopenProjectAction(com.intellij.ide.ReopenProjectAction) RecentProjectsManager(com.intellij.ide.RecentProjectsManager) ProjectGroupActionGroup(com.intellij.ide.ProjectGroupActionGroup) AnAction(com.intellij.openapi.actionSystem.AnAction)

Example 49 with AnAction

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

the class RemoveSelectedProjectsFromGroupsAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final List<AnAction> elements = getSelectedElements(e);
    for (AnAction element : elements) {
        if (element instanceof ReopenProjectAction) {
            for (ProjectGroup group : RecentProjectsManager.getInstance().getGroups()) {
                group.removeProject(((ReopenProjectAction) element).getProjectPath());
            }
        }
    }
    rebuildRecentProjectsList(e);
}
Also used : ReopenProjectAction(com.intellij.ide.ReopenProjectAction) AnAction(com.intellij.openapi.actionSystem.AnAction) ProjectGroup(com.intellij.ide.ProjectGroup)

Example 50 with AnAction

use of com.intellij.openapi.actionSystem.AnAction 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)

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