com.intellij.ide.projectView.impl.ModuleGroup Java Examples
The following examples show how to use
com.intellij.ide.projectView.impl.ModuleGroup.
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: ScopeTreeViewPanel.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private Module[] getSelectedModules() { final TreePath[] treePaths = myTree.getSelectionPaths(); if (treePaths != null) { Set<Module> result = new HashSet<Module>(); for (TreePath path : treePaths) { PackageDependenciesNode node = (PackageDependenciesNode)path.getLastPathComponent(); if (node instanceof ModuleNode) { result.add(((ModuleNode)node).getModule()); } else if (node instanceof ModuleGroupNode) { final ModuleGroupNode groupNode = (ModuleGroupNode)node; final ModuleGroup moduleGroup = groupNode.getModuleGroup(); result.addAll(moduleGroup.modulesInGroup(myProject, true)); } } return result.isEmpty() ? null : result.toArray(new Module[result.size()]); } return null; }
Example #2
Source File: ModuleStructureConfigurable.java From consulo with Apache License 2.0 | 6 votes |
@Override public int compare(final MyNode o1, final MyNode o2) { final NamedConfigurable configurable1 = o1.getConfigurable(); final NamedConfigurable configurable2 = o2.getConfigurable(); if (configurable1.getClass() == configurable2.getClass()) { return o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName()); } final Object editableObject1 = configurable1.getEditableObject(); final Object editableObject2 = configurable2.getEditableObject(); if (editableObject2 instanceof Module && editableObject1 instanceof ModuleGroup) return -1; if (editableObject1 instanceof Module && editableObject2 instanceof ModuleGroup) return 1; if (editableObject2 instanceof Module && editableObject1 instanceof String) return 1; if (editableObject1 instanceof Module && editableObject2 instanceof String) return -1; if (editableObject2 instanceof ModuleGroup && editableObject1 instanceof String) return 1; if (editableObject1 instanceof ModuleGroup && editableObject2 instanceof String) return -1; return 0; }
Example #3
Source File: FavoritesTreeViewPanel.java From consulo with Apache License 2.0 | 6 votes |
private Module[] getSelectedModules() { final Object[] elements = getSelectedNodeElements(); if (elements == null) { return null; } ArrayList<Module> result = new ArrayList<>(); for (Object element : elements) { if (element instanceof Module) { result.add((Module)element); } else if (element instanceof ModuleGroup) { result.addAll(((ModuleGroup)element).modulesInGroup(myProject, true)); } } return result.isEmpty() ? null : result.toArray(new Module[result.size()]); }
Example #4
Source File: DirectoryChooserModuleTreeView.java From consulo with Apache License 2.0 | 6 votes |
@Override @RequiredUIAccess public void customizeCellRenderer(JTree tree, Object nodeValue, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { final Object value = ((DefaultMutableTreeNode)nodeValue).getUserObject(); if (value instanceof DirectoryChooser.ItemWrapper) { DirectoryChooser.ItemWrapper wrapper = (DirectoryChooser.ItemWrapper)value; DirectoryChooser.PathFragment[] fragments = wrapper.getFragments(); for (DirectoryChooser.PathFragment fragment : fragments) { append(fragment.getText(), fragment.isCommon() ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES); } setIcon(wrapper.getIcon()); } else if (value instanceof Module) { final Module module = (Module)value; append(module.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); setIcon(AllIcons.Nodes.Module); } else if (value instanceof ModuleGroup) { append(value.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES); setIcon(AllIcons.Nodes.Module); } }
Example #5
Source File: FileTreeModelBuilder.java From consulo with Apache License 2.0 | 6 votes |
private PackageDependenciesNode getParentModuleGroup(String[] groupPath){ final String key = StringUtil.join(groupPath); ModuleGroupNode groupNode = myModuleGroupNodes.get(key); if (groupNode == null) { groupNode = new ModuleGroupNode(new ModuleGroup(groupPath), myProject); myModuleGroupNodes.put(key, groupNode); myRoot.add(groupNode); } if (groupPath.length > 1) { String [] path = new String[groupPath.length - 1]; System.arraycopy(groupPath, 0, path, 0, groupPath.length - 1); final PackageDependenciesNode node = getParentModuleGroup(path); node.add(groupNode); } return groupNode; }
Example #6
Source File: DirectoryChooserModuleTreeView.java From consulo with Apache License 2.0 | 5 votes |
@Override public void addItem(DirectoryChooser.ItemWrapper itemWrapper) { myItems.add(itemWrapper); final PsiDirectory directory = itemWrapper.getDirectory(); final Module module = myFileIndex.getModuleForFile(directory.getVirtualFile()); DefaultMutableTreeNode node = myModuleNodes.get(module); if (node == null) { node = new DefaultMutableTreeNode(module, true); final String[] groupPath = module != null ? ModuleManager.getInstance(myProject).getModuleGroupPath(module) : null; if (groupPath == null || groupPath.length == 0){ insertNode(node, myRootNode); } else { final DefaultMutableTreeNode parentNode = ModuleGroupUtil.buildModuleGroupPath(new ModuleGroup(groupPath), myRootNode, myModuleGroupNodes, new Consumer<ModuleGroupUtil.ParentChildRelation<DefaultMutableTreeNode>>() { @Override public void consume(final ModuleGroupUtil.ParentChildRelation<DefaultMutableTreeNode> parentChildRelation) { insertNode(parentChildRelation.getChild(), parentChildRelation.getParent()); } }, new Function<ModuleGroup, DefaultMutableTreeNode>() { @Override public DefaultMutableTreeNode fun(final ModuleGroup moduleGroup) { return new DefaultMutableTreeNode(moduleGroup, true); } }); insertNode(node, parentNode); } myModuleNodes.put(module, node); } final DefaultMutableTreeNode itemNode = new DefaultMutableTreeNode(itemWrapper, false); myItemNodes.put(itemWrapper, itemNode); insertNode(itemNode, node); ((DefaultTreeModel)myTree.getModel()).nodeStructureChanged(node); }
Example #7
Source File: MoveModulesToGroupAction.java From consulo with Apache License 2.0 | 5 votes |
public static void doMove(final Module[] modules, final ModuleGroup group, @Nullable final DataContext dataContext) { Project project = modules[0].getProject(); for (final Module module : modules) { ModifiableModuleModel model = dataContext != null ? dataContext.getData(LangDataKeys.MODIFIABLE_MODULE_MODEL) : null; if (model != null){ model.setModuleGroupPath(module, group == null ? null : group.getGroupPath()); } else { ModuleManagerImpl.getInstanceImpl(project).setModuleGroupPath(module, group == null ? null : group.getGroupPath()); } } AbstractProjectViewPane pane = ProjectView.getInstance(project).getCurrentProjectViewPane(); if (pane != null) { pane.updateFromRoot(true); } if (!ProjectSettingsService.getInstance(project).processModulesMoved(modules, group) && pane != null) { if (group != null) { pane.selectModuleGroup(group, true); } else { pane.selectModule(modules[0], true); } } }
Example #8
Source File: AddToFavoritesAction.java From consulo with Apache License 2.0 | 5 votes |
private static Object collectSelectedElements(final DataContext dataContext) { Object elements = retrieveData(null, dataContext.getData(LangDataKeys.PSI_ELEMENT)); elements = retrieveData(elements, dataContext.getData(LangDataKeys.PSI_ELEMENT_ARRAY)); elements = retrieveData(elements, dataContext.getData(LangDataKeys.PSI_FILE)); elements = retrieveData(elements, dataContext.getData(ModuleGroup.ARRAY_DATA_KEY)); elements = retrieveData(elements, dataContext.getData(LangDataKeys.MODULE_CONTEXT_ARRAY)); elements = retrieveData(elements, dataContext.getData(LibraryGroupElement.ARRAY_DATA_KEY)); elements = retrieveData(elements, dataContext.getData(NamedLibraryElement.ARRAY_DATA_KEY)); elements = retrieveData(elements, dataContext.getData(PlatformDataKeys.VIRTUAL_FILE)); elements = retrieveData(elements, dataContext.getData(PlatformDataKeys.VIRTUAL_FILE_ARRAY)); return elements; }
Example #9
Source File: ProjectSettingsService.java From consulo with Apache License 2.0 | 5 votes |
public boolean processModulesMoved(final Module[] modules, @Nullable final ModuleGroup targetGroup) { final ModuleStructureConfigurable rootConfigurable = ModuleStructureConfigurable.getInstance(myProject); if (rootConfigurable.updateProjectTree(modules, targetGroup)) { //inside project root editor if (targetGroup != null) { rootConfigurable.selectNodeInTree(targetGroup.toString()); } else { rootConfigurable.selectNodeInTree(modules[0].getName()); } return true; } return false; }
Example #10
Source File: ModuleStructureConfigurable.java From consulo with Apache License 2.0 | 5 votes |
private void removeModuleGroups() { for(int i = myRoot.getChildCount() - 1; i >=0; i--){ final MyNode node = (MyNode)myRoot.getChildAt(i); if (node.getConfigurable().getEditableObject() instanceof ModuleGroup){ node.removeFromParent(); } } ((DefaultTreeModel)myTree.getModel()).reload(myRoot); }
Example #11
Source File: ModuleStructureConfigurable.java From consulo with Apache License 2.0 | 5 votes |
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 }
Example #12
Source File: ModuleStructureConfigurable.java From consulo with Apache License 2.0 | 5 votes |
private void createProjectNodes() { final Map<ModuleGroup, MyNode> moduleGroup2NodeMap = new HashMap<ModuleGroup, MyNode>(); final Module[] modules = myModuleManager.getModules(); for (final Module module : modules) { ModuleConfigurable configurable = new ModuleConfigurable(myContext.myModulesConfigurator, module, TREE_UPDATER); final MyNode moduleNode = new MyNode(configurable); final String[] groupPath = myPlainMode ? null : myContext.myModulesConfigurator.getModuleModel().getModuleGroupPath(module); if (groupPath == null || groupPath.length == 0){ addNode(moduleNode, myRoot); } else { final MyNode moduleGroupNode = ModuleGroupUtil .buildModuleGroupPath(new ModuleGroup(groupPath), myRoot, moduleGroup2NodeMap, new Consumer<ModuleGroupUtil.ParentChildRelation<MyNode>>() { @Override public void consume(final ModuleGroupUtil.ParentChildRelation<MyNode> parentChildRelation) { addNode(parentChildRelation.getChild(), parentChildRelation.getParent()); } }, new Function<ModuleGroup, MyNode>() { @Override public MyNode fun(final ModuleGroup moduleGroup) { final NamedConfigurable moduleGroupConfigurable = createModuleGroupConfigurable(moduleGroup); return new MyNode(moduleGroupConfigurable, true); } }); addNode(moduleNode, moduleGroupNode); } } if (myProject.isDefault()) { //do not add modules node in case of template project myRoot.removeAllChildren(); } }
Example #13
Source File: ModuleDecoration.java From SVNToolBox with Apache License 2.0 | 5 votes |
@Override public boolean isForMe(ProjectViewNode node) { if (node instanceof PsiDirectoryNode) { PsiDirectoryNode dirNode = (PsiDirectoryNode) node; final Object parentValue = dirNode.getParent().getValue(); return parentValue instanceof Project || parentValue instanceof ModuleGroup; } return false; }
Example #14
Source File: MoveModulesToGroupAction.java From consulo with Apache License 2.0 | 4 votes |
public MoveModulesToGroupAction(ModuleGroup moduleGroup, String title) { super(title); myModuleGroup = moduleGroup; }
Example #15
Source File: PackageViewModuleGroupNode.java From consulo with Apache License 2.0 | 4 votes |
@Override protected ModuleGroupNode createModuleGroupNode(ModuleGroup moduleGroup) { return new PackageViewModuleGroupNode(getProject(), moduleGroup, getSettings()); }
Example #16
Source File: PackageViewModuleGroupNode.java From consulo with Apache License 2.0 | 4 votes |
public PackageViewModuleGroupNode(final Project project, final ModuleGroup value, final ViewSettings viewSettings) { super(project, value, viewSettings); }
Example #17
Source File: PackageViewProjectNode.java From consulo with Apache License 2.0 | 4 votes |
@Override protected AbstractTreeNode createModuleGroupNode(final ModuleGroup moduleGroup) { return new PackageViewModuleGroupNode(getProject(), moduleGroup, getSettings()); }
Example #18
Source File: ModuleGroupNode.java From consulo with Apache License 2.0 | 4 votes |
@Override public void update(PresentationData presentation) { final String[] groupPath = getValue().getGroupPath(); presentation.setPresentableText(groupPath[groupPath.length - 1]); presentation.setIcon(AllIcons.Nodes.ModuleGroup); }
Example #19
Source File: ModuleGroupNode.java From consulo with Apache License 2.0 | 4 votes |
public ModuleGroupNode(final Project project, final Object value, final ViewSettings viewSettings) { this(project, (ModuleGroup)value, viewSettings); }
Example #20
Source File: ModuleGroupNode.java From consulo with Apache License 2.0 | 4 votes |
public ModuleGroupNode(final Project project, final ModuleGroup value, final ViewSettings viewSettings) { super(project, value, viewSettings); }
Example #21
Source File: ProjectViewModuleGroupNode.java From consulo with Apache License 2.0 | 4 votes |
@Override protected ModuleGroupNode createModuleGroupNode(ModuleGroup moduleGroup) { return new ProjectViewModuleGroupNode(getProject(), moduleGroup, getSettings()); }
Example #22
Source File: ProjectViewModuleGroupNode.java From consulo with Apache License 2.0 | 4 votes |
public ProjectViewModuleGroupNode(final Project project, final ModuleGroup value, final ViewSettings viewSettings) { super(project, value, viewSettings); }
Example #23
Source File: ProjectViewModuleGroupNode.java From consulo with Apache License 2.0 | 4 votes |
public ProjectViewModuleGroupNode(final Project project, final Object value, final ViewSettings viewSettings) { super(project, (ModuleGroup)value, viewSettings); }
Example #24
Source File: ProjectViewProjectNode.java From consulo with Apache License 2.0 | 4 votes |
@Override protected AbstractTreeNode createModuleGroupNode(final ModuleGroup moduleGroup) { return new ProjectViewModuleGroupNode(getProject(), moduleGroup, getSettings()); }
Example #25
Source File: KnowledgeViewProjectNode.java From netbeans-mmd-plugin with Apache License 2.0 | 4 votes |
@Override protected AbstractTreeNode createModuleGroupNode(final ModuleGroup moduleGroup) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { return null; }
Example #26
Source File: MoveModulesToSubGroupAction.java From consulo with Apache License 2.0 | 4 votes |
public MoveModulesToSubGroupAction(ModuleGroup moduleGroup) { super(moduleGroup, moduleGroup == null ? IdeBundle.message("action.move.module.new.top.level.group") : IdeBundle.message("action.move.module.to.new.sub.group")); }
Example #27
Source File: CommanderPanel.java From consulo with Apache License 2.0 | 4 votes |
public final Object getDataImpl(final Key<?> dataId) { if (myBuilder == null) return null; final Object selectedValue = getSelectedValue(); if (LangDataKeys.PSI_ELEMENT == dataId) { final PsiElement selectedElement = getSelectedElement(); return selectedElement != null && selectedElement.isValid() ? selectedElement : null; } if (LangDataKeys.PSI_ELEMENT_ARRAY == dataId) { return filterInvalidElements(getSelectedElements()); } if (LangDataKeys.PASTE_TARGET_PSI_ELEMENT == dataId) { final AbstractTreeNode parentNode = myBuilder.getParentNode(); final Object element = parentNode != null ? parentNode.getValue() : null; return element instanceof PsiElement && ((PsiElement)element).isValid() ? element : null; } if (PlatformDataKeys.NAVIGATABLE_ARRAY == dataId) { return getNavigatables(); } if (PlatformDataKeys.COPY_PROVIDER == dataId) { return myCopyPasteDelegator != null ? myCopyPasteDelegator.getCopyProvider() : null; } if (PlatformDataKeys.CUT_PROVIDER == dataId) { return myCopyPasteDelegator != null ? myCopyPasteDelegator.getCutProvider() : null; } if (PlatformDataKeys.PASTE_PROVIDER == dataId) { return myCopyPasteDelegator != null ? myCopyPasteDelegator.getPasteProvider() : null; } if (LangDataKeys.IDE_VIEW == dataId) { return myIdeView; } if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER == dataId) { return myDeleteElementProvider; } if (LangDataKeys.MODULE == dataId) { return selectedValue instanceof Module ? selectedValue : null; } if (ModuleGroup.ARRAY_DATA_KEY == dataId) { return selectedValue instanceof ModuleGroup ? new ModuleGroup[]{(ModuleGroup)selectedValue} : null; } if (LibraryGroupElement.ARRAY_DATA_KEY == dataId) { return selectedValue instanceof LibraryGroupElement ? new LibraryGroupElement[]{(LibraryGroupElement)selectedValue} : null; } if (NamedLibraryElement.ARRAY_DATA_KEY == dataId) { return selectedValue instanceof NamedLibraryElement ? new NamedLibraryElement[]{(NamedLibraryElement)selectedValue} : null; } if (myProjectTreeStructure != null) { return myProjectTreeStructure.getDataFromProviders(getSelectedNodes(), dataId); } return null; }
Example #28
Source File: ModuleGroupNode.java From consulo with Apache License 2.0 | 4 votes |
public ModuleGroup getModuleGroup() { return myModuleGroup; }
Example #29
Source File: ModuleGroupNode.java From consulo with Apache License 2.0 | 4 votes |
@Override public Icon getIcon() { return AllIcons.Nodes.ModuleGroup; }
Example #30
Source File: ModuleGroupNode.java From consulo with Apache License 2.0 | 4 votes |
public ModuleGroupNode(ModuleGroup moduleGroup, Project project) { super(project); myModuleGroup = moduleGroup; }