Search in sources :

Example 1 with ProjectGroupActionGroup

use of com.intellij.ide.ProjectGroupActionGroup 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 2 with ProjectGroupActionGroup

use of com.intellij.ide.ProjectGroupActionGroup 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 3 with ProjectGroupActionGroup

use of com.intellij.ide.ProjectGroupActionGroup 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 4 with ProjectGroupActionGroup

use of com.intellij.ide.ProjectGroupActionGroup in project intellij-community by JetBrains.

the class EditProjectGroupAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final ProjectGroup group = ((ProjectGroupActionGroup) getSelectedElements(e).get(0)).getGroup();
    JList list = getList(e);
    assert list != null;
    DefaultListModel model = getDataModel(e);
    String name = Messages.showInputDialog(list, "Enter group name: ", "Change Group Name", null, group.getName(), new InputValidatorEx() {

        @Nullable
        @Override
        public String getErrorText(String inputString) {
            inputString = inputString.trim();
            if (inputString.length() == 0) {
                return "Name cannot be empty.";
            }
            if (!checkInput(inputString)) {
                return "Group '" + inputString + "' already exists.";
            }
            return null;
        }

        @Override
        public boolean checkInput(String inputString) {
            inputString = inputString.trim();
            if (inputString.equals(group.getName()))
                return true;
            for (ProjectGroup projectGroup : RecentProjectsManager.getInstance().getGroups()) {
                if (projectGroup.getName().equals(inputString)) {
                    return false;
                }
            }
            return true;
        }

        @Override
        public boolean canClose(String inputString) {
            return true;
        }
    });
    if (name != null && model != null) {
        group.setName(name);
        rebuildRecentProjectDataModel(model);
        for (int i = 0; i < model.getSize(); i++) {
            Object element = model.get(i);
            if (element instanceof ProjectGroupActionGroup) {
                if (((ProjectGroupActionGroup) element).getGroup().equals(group)) {
                    ScrollingUtil.selectItem(list, i);
                    break;
                }
            }
        }
    }
}
Also used : ProjectGroupActionGroup(com.intellij.ide.ProjectGroupActionGroup) InputValidatorEx(com.intellij.openapi.ui.InputValidatorEx) Nullable(org.jetbrains.annotations.Nullable) ProjectGroup(com.intellij.ide.ProjectGroup)

Aggregations

ProjectGroupActionGroup (com.intellij.ide.ProjectGroupActionGroup)4 AnAction (com.intellij.openapi.actionSystem.AnAction)3 ReopenProjectAction (com.intellij.ide.ReopenProjectAction)2 ProjectGroup (com.intellij.ide.ProjectGroup)1 RecentProjectsManager (com.intellij.ide.RecentProjectsManager)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 InputValidatorEx (com.intellij.openapi.ui.InputValidatorEx)1 Nullable (org.jetbrains.annotations.Nullable)1