distinguish annotation interfaces in Ctrl-hover popup (IDEADEV-40633)
[fedora-idea.git] / java / idea-ui / src / com / intellij / openapi / roots / ui / configuration / packaging / PackagingTreeNodeFactoryOld.java
blobdc739fd0a3ca7b1abe8797046ef012e274a5164e
1 package com.intellij.openapi.roots.ui.configuration.packaging;
3 import com.intellij.openapi.deployment.LibraryLink;
4 import com.intellij.openapi.deployment.ModuleLink;
5 import com.intellij.openapi.roots.libraries.Library;
6 import com.intellij.openapi.vfs.VirtualFile;
7 import org.jetbrains.annotations.NotNull;
8 import org.jetbrains.annotations.Nullable;
10 import java.util.StringTokenizer;
12 /**
13 * @author nik
15 public class PackagingTreeNodeFactoryOld {
16 private PackagingTreeNodeFactoryOld() {
19 @NotNull
20 public static PackagingTreeNode getOrCreateDirectoryNode(@NotNull String path, @NotNull PackagingTreeNode root, PackagingArtifact owner) {
21 StringTokenizer tokenizer = new StringTokenizer(path, "/");
22 PackagingTreeNode current = root;
23 while (tokenizer.hasMoreTokens()) {
24 String name = tokenizer.nextToken();
25 if (name.length() == 0 || name.equals(".")) continue;
27 PackagingTreeNode child = current.findChildByName(name);
28 if (child == null) {
29 child = new DirectoryNode(name, owner);
30 current.add(child);
32 current = child;
34 return current;
37 @NotNull
38 public static PackagingTreeNode getOrCreateArchiveNode(@NotNull String path, @NotNull PackagingTreeNode root, PackagingArtifact owner) {
39 int i = path.lastIndexOf('/');
40 String archiveName = path.substring(i+1);
41 PackagingTreeNode parent = i != -1 ? getOrCreateDirectoryNode(path.substring(0, i), root, owner) : root;
42 PackagingTreeNode child = parent.findChildByName(archiveName);
43 if (child == null) {
44 child = new ArchiveNode(archiveName, owner);
45 parent.add(child);
47 return child;
50 @NotNull
51 public static PackagingTreeNode createLibraryNode(@NotNull LibraryLink libraryLink, @NotNull PackagingTreeNode parent, final PackagingArtifact owner) {
52 for (PackagingTreeNode child : parent.getChildren()) {
53 if (child instanceof LibraryNode && ((LibraryNode)child).getLibraryLink().equals(libraryLink)) {
54 return child;
57 LibraryNode node = new LibraryNode(libraryLink, owner);
58 parent.add(node);
59 return node;
62 @NotNull
63 public static PackagingTreeNode createPackedModuleOutputNode(@NotNull ModuleLink moduleLink, String jarName, @NotNull PackagingTreeNode parent, final PackagingArtifact owner) {
64 for (PackagingTreeNode child : parent.getChildren()) {
65 if (child instanceof PackedModuleOutputNode && ((PackedModuleOutputNode)child).getModuleLink().equals(moduleLink)) {
66 return child;
69 PackedModuleOutputNode node = new PackedModuleOutputNode(moduleLink, jarName, owner);
70 parent.add(node);
71 return node;
74 @NotNull
75 public static PackagingTreeNode createModuleOutputNode(@NotNull ModuleLink moduleLink, @NotNull PackagingTreeNode parent, final PackagingArtifact owner) {
76 for (PackagingTreeNode child : parent.getChildren()) {
77 if (child instanceof ModuleOutputNode && ((ModuleOutputNode)child).getModuleLink().equals(moduleLink)) {
78 return child;
81 ModuleOutputNode node = new ModuleOutputNode(moduleLink, owner);
82 parent.add(node);
83 return node;
86 public static PackagingArtifactNode createArtifactNode(@NotNull PackagingArtifact artifact, @NotNull PackagingTreeNode parent,
87 PackagingArtifact owner) {
88 PackagingArtifactNode node = new PackagingArtifactNode(artifact, owner);
89 parent.add(node);
90 return node;
93 public static PackagingTreeNode createLibraryFileNode(@NotNull VirtualFile file, @NotNull Library library, @NotNull LibraryLink libraryLink,
94 @NotNull PackagingTreeNode parent, @Nullable PackagingArtifact owner) {
95 for (PackagingTreeNode child : parent.getChildren()) {
96 if (child instanceof LibraryFileNode && ((LibraryFileNode)child).getFile().equals(file)) {
97 return child;
100 LibraryFileNode node = new LibraryFileNode(file, library, libraryLink, owner);
101 parent.add(node);
102 return node;