Search in sources :

Example 1 with ProjectGroup

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

the class CreateNewProjectGroupAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final InputValidator validator = new InputValidator() {

        @Override
        public boolean checkInput(String inputString) {
            inputString = inputString.trim();
            return getGroup(inputString) == null;
        }

        @Override
        public boolean canClose(String inputString) {
            return true;
        }
    };
    final String newGroup = Messages.showInputDialog((Project) null, "Project group name", "Create New Project Group", null, null, validator);
    if (newGroup != null) {
        final ProjectGroup group = new ProjectGroup(newGroup);
        RecentProjectsManager.getInstance().addGroup(group);
        rebuildRecentProjectsList(e);
    }
}
Also used : InputValidator(com.intellij.openapi.ui.InputValidator) ProjectGroup(com.intellij.ide.ProjectGroup)

Example 2 with ProjectGroup

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

the class MoveProjectToGroupAction method actionPerformed.

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

Example 3 with ProjectGroup

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

use of com.intellij.ide.ProjectGroup 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)

Example 5 with ProjectGroup

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

the class MoveProjectToGroupActionGroup method update.

@Override
public void update(AnActionEvent e) {
    removeAll();
    final List<ProjectGroup> groups = new ArrayList<>(RecentProjectsManager.getInstance().getGroups());
    Collections.sort(groups, (o1, o2) -> StringUtil.naturalCompare(o1.getName(), o2.getName()));
    for (ProjectGroup group : groups) {
        add(new MoveProjectToGroupAction(group));
    }
    if (groups.size() > 0) {
        add(Separator.getInstance());
        add(new RemoveSelectedProjectsFromGroupsAction());
    }
}
Also used : ArrayList(java.util.ArrayList) ProjectGroup(com.intellij.ide.ProjectGroup)

Aggregations

ProjectGroup (com.intellij.ide.ProjectGroup)5 ReopenProjectAction (com.intellij.ide.ReopenProjectAction)2 AnAction (com.intellij.openapi.actionSystem.AnAction)2 ProjectGroupActionGroup (com.intellij.ide.ProjectGroupActionGroup)1 InputValidator (com.intellij.openapi.ui.InputValidator)1 InputValidatorEx (com.intellij.openapi.ui.InputValidatorEx)1 ArrayList (java.util.ArrayList)1 Nullable (org.jetbrains.annotations.Nullable)1