Java Code Examples for com.intellij.openapi.module.ModifiableModuleModel#getModuleGroupPath()

The following examples show how to use com.intellij.openapi.module.ModifiableModuleModel#getModuleGroupPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoveModuleToGroupTopLevel.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static Collection<String> getTopLevelGroupNames(final DataContext dataContext) {
  final Project project = dataContext.getData(CommonDataKeys.PROJECT);

  final ModifiableModuleModel model = dataContext.getData(LangDataKeys.MODIFIABLE_MODULE_MODEL);

  Module[] allModules;
  if ( model != null ) {
    allModules = model.getModules();
  } else {
    allModules = ModuleManager.getInstance(project).getModules();
  }

  Set<String> topLevelGroupNames = new HashSet<String>();
  for (final Module child : allModules) {
    String[] group;
    if ( model != null ) {
      group = model.getModuleGroupPath(child);
    } else {
      group = ModuleManager.getInstance(project).getModuleGroupPath(child);
    }
    if (group != null) {
      topLevelGroupNames.add(group[0]);
    }
  }
  return topLevelGroupNames;
}
 
Example 2
Source File: ModuleGroup.java    From consulo with Apache License 2.0 6 votes vote down vote up
public Collection<ModuleGroup> childGroups(ModifiableModuleModel model, Project project) {
  final Module[] allModules;
  if ( model != null ) {
    allModules = model.getModules();
  } else {
    allModules = ModuleManager.getInstance(project).getModules();
  }

  Set<ModuleGroup> result = new THashSet<ModuleGroup>();
  for (Module module : allModules) {
    String[] group;
    if ( model != null ) {
      group = model.getModuleGroupPath(module);
    } else {
      group = ModuleManager.getInstance(project).getModuleGroupPath(module);
    }
    if (group == null) continue;
    final String[] directChild = directChild(myGroupPath, group);
    if (directChild != null) {
      result.add(new ModuleGroup(directChild));
    }
  }

  return result;
}
 
Example 3
Source File: ModuleStructureConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void addModuleNode(final Module module) {
  final MyNode node = new MyNode(new ModuleConfigurable(myContext.myModulesConfigurator, module, TREE_UPDATER));
  final TreePath selectionPath = myTree.getSelectionPath();
  MyNode parent = null;
  if (selectionPath != null) {
    MyNode selected = (MyNode)selectionPath.getLastPathComponent();
    final Object o = selected.getConfigurable().getEditableObject();
    if (o instanceof ModuleGroup) {
      myContext.myModulesConfigurator.getModuleModel().setModuleGroupPath(module, ((ModuleGroup)o).getGroupPath());
      parent = selected;
    } else if (o instanceof Module) { //create near selected
      final ModifiableModuleModel modifiableModuleModel = myContext.myModulesConfigurator.getModuleModel();
      final String[] groupPath = modifiableModuleModel.getModuleGroupPath((Module)o);
      if (groupPath != null) {
        modifiableModuleModel.setModuleGroupPath(module, groupPath);
        parent = findNodeByObject(myRoot, new ModuleGroup(groupPath));
      }
    }
  }
  if (parent == null) parent = myRoot;
  addNode(node, parent);
  ((DefaultTreeModel)myTree.getModel()).reload(parent);
  selectNodeInTree(node);
  final ProjectStructureDaemonAnalyzer daemonAnalyzer = myContext.getDaemonAnalyzer();
  daemonAnalyzer.queueUpdate(new ModuleProjectStructureElement(myContext, module));
  daemonAnalyzer.queueUpdateForAllElementsWithErrors(); //missing modules added
}