1 package com
.intellij
.openapi
.roots
.ui
.configuration
.packaging
;
3 import com
.intellij
.ui
.ColoredTreeCellRenderer
;
4 import com
.intellij
.ui
.SimpleTextAttributes
;
5 import com
.intellij
.openapi
.deployment
.ContainerElement
;
6 import com
.intellij
.openapi
.roots
.ui
.configuration
.projectRoot
.ModuleStructureConfigurable
;
7 import org
.jetbrains
.annotations
.NotNull
;
8 import org
.jetbrains
.annotations
.Nullable
;
10 import javax
.swing
.tree
.DefaultMutableTreeNode
;
11 import java
.util
.ArrayList
;
12 import java
.util
.List
;
17 public abstract class PackagingTreeNode
extends DefaultMutableTreeNode
implements Comparable
<PackagingTreeNode
> {
18 private final PackagingArtifact myOwner
;
20 protected PackagingTreeNode(final @Nullable PackagingArtifact owner
) {
25 public abstract String
getOutputFileName();
27 public abstract double getWeight();
29 public String
getSearchName() {
30 return getOutputFileName();
33 public abstract void render(ColoredTreeCellRenderer renderer
);
35 public abstract boolean canNavigate();
37 public abstract void navigate(ModuleStructureConfigurable configurable
);
40 public abstract Object
getSourceObject();
43 public String
getTooltipText() {
47 public void renderTooltip(ColoredTreeCellRenderer renderer
) {
50 public int compareTo(final PackagingTreeNode node
) {
51 return getOutputFileName().compareToIgnoreCase(node
.getOutputFileName());
55 public PackagingArtifact
getOwner() {
60 public ContainerElement
getContainerElement() {
65 public PackagingTreeNode
findChildByName(final @NotNull String outputFileName
) {
66 for (int i
= 0; i
< getChildCount(); i
++) {
67 PackagingTreeNode node
= (PackagingTreeNode
)getChildAt(i
);
68 if (node
.getOutputFileName().equals(outputFileName
)) {
76 public PackagingTreeNode
getParent() {
77 return (PackagingTreeNode
)super.getParent();
81 public List
<PackagingTreeNode
> getChildren() {
82 List
<PackagingTreeNode
> children
= new ArrayList
<PackagingTreeNode
>(getChildCount());
83 for (int i
= 0; i
< getChildCount(); i
++) {
84 children
.add((PackagingTreeNode
)getChildAt(i
));
89 protected SimpleTextAttributes
getMainAttributes() {
90 return !belongsToIncludedArtifact() ? SimpleTextAttributes
.REGULAR_ATTRIBUTES
: SimpleTextAttributes
.GRAY_ATTRIBUTES
;
93 protected SimpleTextAttributes
getCommentAttributes() {
94 return !belongsToIncludedArtifact() ? SimpleTextAttributes
.GRAY_ATTRIBUTES
: SimpleTextAttributes
.GRAY_ITALIC_ATTRIBUTES
;
97 protected boolean belongsToIncludedArtifact() {
98 if (myOwner
== null) return false;
100 PackagingTreeNode parent
= getParent();
101 while (parent
!= null) {
102 if (parent
instanceof PackagingArtifactNode
&& myOwner
.equals(((PackagingArtifactNode
)parent
).getArtifact())) {
105 parent
= parent
.getParent();