Search in sources :

Example 1 with MoveModulesToSubGroupAction

use of com.intellij.ide.projectView.actions.MoveModulesToSubGroupAction in project intellij-community by JetBrains.

the class MoveModuleToGroup method getChildren.

@Override
@NotNull
public AnAction[] getChildren(@Nullable AnActionEvent e) {
    if (e == null)
        return EMPTY_ARRAY;
    Project project = getEventProject(e);
    if (project == null)
        return EMPTY_ARRAY;
    ModifiableModuleModel modifiableModuleModel = LangDataKeys.MODIFIABLE_MODULE_MODEL.getData(e.getDataContext());
    List<AnAction> result = new ArrayList<>();
    result.add(new MoveModulesToGroupAction(myModuleGroup, IdeBundle.message("action.move.module.to.this.group")));
    result.add(new MoveModulesToSubGroupAction(myModuleGroup));
    result.add(Separator.getInstance());
    ModuleGrouper grouper = ModuleGrouper.instanceFor(project, modifiableModuleModel);
    result.addAll(myModuleGroup.childGroups(grouper).stream().sorted((moduleGroup1, moduleGroup2) -> {
        assert moduleGroup1.getGroupPath().length == moduleGroup2.getGroupPath().length;
        return moduleGroup1.toString().compareToIgnoreCase(moduleGroup2.toString());
    }).map(MoveModuleToGroup::new).collect(Collectors.toList()));
    return result.toArray(new AnAction[result.size()]);
}
Also used : ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) IdeBundle(com.intellij.ide.IdeBundle) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) ModuleGrouper(com.intellij.openapi.module.ModuleGrouper) Project(com.intellij.openapi.project.Project) MoveModulesToSubGroupAction(com.intellij.ide.projectView.actions.MoveModulesToSubGroupAction) Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull) MoveModulesToGroupAction(com.intellij.ide.projectView.actions.MoveModulesToGroupAction) Project(com.intellij.openapi.project.Project) ModuleGrouper(com.intellij.openapi.module.ModuleGrouper) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) ArrayList(java.util.ArrayList) MoveModulesToGroupAction(com.intellij.ide.projectView.actions.MoveModulesToGroupAction) MoveModulesToSubGroupAction(com.intellij.ide.projectView.actions.MoveModulesToSubGroupAction) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with MoveModulesToSubGroupAction

use of com.intellij.ide.projectView.actions.MoveModulesToSubGroupAction in project intellij-community by JetBrains.

the class MoveModuleToGroupTopLevel method getChildren.

@Override
@NotNull
public AnAction[] getChildren(@Nullable AnActionEvent e) {
    if (e == null)
        return EMPTY_ARRAY;
    Project project = getEventProject(e);
    if (project == null)
        return EMPTY_ARRAY;
    ModifiableModuleModel moduleModel = LangDataKeys.MODIFIABLE_MODULE_MODEL.getData(e.getDataContext());
    ModuleGrouper grouper = ModuleGrouper.instanceFor(project, moduleModel);
    List<String> topLevelGroupNames = new ArrayList<>(getTopLevelGroupNames(grouper));
    Collections.sort(topLevelGroupNames);
    List<AnAction> result = new ArrayList<>();
    result.add(new MoveModulesOutsideGroupAction());
    result.add(new MoveModulesToSubGroupAction(null));
    result.add(Separator.getInstance());
    for (String name : topLevelGroupNames) {
        result.add(new MoveModuleToGroup(new ModuleGroup(Collections.singletonList(name))));
    }
    return result.toArray(new AnAction[result.size()]);
}
Also used : Project(com.intellij.openapi.project.Project) ModuleGrouper(com.intellij.openapi.module.ModuleGrouper) MoveModulesOutsideGroupAction(com.intellij.ide.projectView.actions.MoveModulesOutsideGroupAction) ModifiableModuleModel(com.intellij.openapi.module.ModifiableModuleModel) MoveModulesToSubGroupAction(com.intellij.ide.projectView.actions.MoveModulesToSubGroupAction) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

MoveModulesToSubGroupAction (com.intellij.ide.projectView.actions.MoveModulesToSubGroupAction)2 ModifiableModuleModel (com.intellij.openapi.module.ModifiableModuleModel)2 ModuleGrouper (com.intellij.openapi.module.ModuleGrouper)2 Project (com.intellij.openapi.project.Project)2 NotNull (org.jetbrains.annotations.NotNull)2 IdeBundle (com.intellij.ide.IdeBundle)1 MoveModulesOutsideGroupAction (com.intellij.ide.projectView.actions.MoveModulesOutsideGroupAction)1 MoveModulesToGroupAction (com.intellij.ide.projectView.actions.MoveModulesToGroupAction)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 Module (com.intellij.openapi.module.Module)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Nullable (org.jetbrains.annotations.Nullable)1