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
;
15 public class PackagingTreeNodeFactoryOld
{
16 private PackagingTreeNodeFactoryOld() {
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
);
29 child
= new DirectoryNode(name
, owner
);
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
);
44 child
= new ArchiveNode(archiveName
, owner
);
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
)) {
57 LibraryNode node
= new LibraryNode(libraryLink
, owner
);
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
)) {
69 PackedModuleOutputNode node
= new PackedModuleOutputNode(moduleLink
, jarName
, owner
);
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
)) {
81 ModuleOutputNode node
= new ModuleOutputNode(moduleLink
, owner
);
86 public static PackagingArtifactNode
createArtifactNode(@NotNull PackagingArtifact artifact
, @NotNull PackagingTreeNode parent
,
87 PackagingArtifact owner
) {
88 PackagingArtifactNode node
= new PackagingArtifactNode(artifact
, owner
);
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
)) {
100 LibraryFileNode node
= new LibraryFileNode(file
, library
, libraryLink
, owner
);