use of com.intellij.openapi.module.ModuleGrouper 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()]);
}
use of com.intellij.openapi.module.ModuleGrouper in project intellij-community by JetBrains.
the class ModuleGroupNode method getChildren.
@Override
@NotNull
public Collection<AbstractTreeNode> getChildren() {
ModuleGrouper grouper = ModuleGrouper.instanceFor(getProject());
final Collection<ModuleGroup> childGroups = getValue().childGroups(grouper);
final List<AbstractTreeNode> result = new ArrayList<>();
for (final ModuleGroup childGroup : childGroups) {
result.add(createModuleGroupNode(childGroup));
}
Collection<Module> modules = getValue().modulesInGroup(grouper, false);
try {
for (Module module : modules) {
result.add(createModuleNode(module));
}
} catch (Exception e) {
LOG.error(e);
}
return result;
}
use of com.intellij.openapi.module.ModuleGrouper in project intellij-community by JetBrains.
the class ModulesAndLibrariesSourceItemsProvider method createModuleItems.
@NotNull
private static Collection<? extends PackagingSourceItem> createModuleItems(@NotNull ArtifactEditorContext editorContext, @NotNull List<String> groupPath) {
final List<PackagingSourceItem> items = new ArrayList<>();
ModuleGrouper grouper = ModuleGrouper.instanceFor(editorContext.getProject(), editorContext.getModifiableModuleModel());
Set<String> groups = new HashSet<>();
for (Module module : grouper.getAllModules()) {
List<String> path = grouper.getGroupPath(module);
if (Comparing.equal(path, groupPath)) {
items.add(new ModuleSourceItemGroup(module));
} else if (ContainerUtil.startsWith(path, groupPath)) {
groups.add(path.get(groupPath.size()));
}
}
for (String group : groups) {
items.add(0, new ModuleGroupItem(ContainerUtil.append(groupPath, group)));
}
return items;
}
use of com.intellij.openapi.module.ModuleGrouper in project intellij-community by JetBrains.
the class PluginDescriptorChooser method createCandidates.
private static List<PluginDescriptorCandidate> createCandidates(final Module currentModule, List<DomFileElement<IdeaPlugin>> elements) {
ModuleGrouper grouper = ModuleGrouper.instanceFor(currentModule.getProject());
final List<String> groupPath = grouper.getGroupPath(currentModule);
elements.sort((o1, o2) -> {
// current module = first group
final Module module1 = o1.getModule();
final Module module2 = o2.getModule();
if (currentModule.equals(module1))
return -1;
if (currentModule.equals(module2))
return 1;
if (module1 != null && module2 != null) {
int groupComparison = Comparing.compare(groupMatchLevel(groupPath, grouper.getGroupPath(module2)), groupMatchLevel(groupPath, grouper.getGroupPath(module1)));
if (groupComparison != 0) {
return groupComparison;
}
}
return ModulesAlphaComparator.INSTANCE.compare(module1, module2);
});
elements.sort((o1, o2) -> {
if (!Comparing.equal(o1.getModule(), o2.getModule()))
return 0;
String pluginId1 = o1.getRootElement().getPluginId();
String pluginId2 = o2.getRootElement().getPluginId();
if (pluginId1 == null && pluginId2 == null) {
return o1.getFile().getName().compareTo(o2.getFile().getName());
}
if (pluginId1 == null)
return 1;
if (pluginId2 == null)
return -1;
return Comparing.compare(pluginId1, pluginId2);
});
return ContainerUtil.map(elements, new Function<DomFileElement<IdeaPlugin>, PluginDescriptorCandidate>() {
private Module myLastModule = currentModule;
@Override
public PluginDescriptorCandidate fun(DomFileElement<IdeaPlugin> element) {
final Module module = element.getModule();
boolean startsNewGroup = !myLastModule.equals(module);
myLastModule = module;
return new PluginDescriptorCandidate(element, startsNewGroup);
}
});
}
use of com.intellij.openapi.module.ModuleGrouper 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()]);
}
Aggregations