1 package com
.intellij
.util
.xml
.tree
;
3 import jetbrains
.fabrique
.ui
.treeStructure
.SimpleNode
;
4 import com
.intellij
.util
.xml
.DomElement
;
5 import com
.intellij
.util
.xml
.DomUtil
;
6 import com
.intellij
.openapi
.util
.Key
;
9 import java
.lang
.reflect
.Type
;
12 abstract public class AbstractDomElementNode
extends SimpleNode
{
13 public static final Key
<Map
<Class
, Boolean
>> TREE_NODES_HIDERS_KEY
= Key
.create("TREE_NODES_HIDERS_KEY");
14 private boolean isExpanded
;
16 protected AbstractDomElementNode() {
20 public AbstractDomElementNode(final SimpleNode parent
) {
24 abstract public DomElement
getDomElement();
26 abstract public String
getNodeName();
28 abstract public String
getTagName();
30 public Icon
getNodeIcon() {
31 return getDomElement().getPresentation().getIcon();
34 protected String
getPropertyName() {
35 return getDomElement().getPresentation().getTypeName();
38 protected boolean shouldBeShowed(final Type type
) {
39 final Map
<Class
, Boolean
> hiders
= getDomElement().getRoot().getUserData(TREE_NODES_HIDERS_KEY
);
40 if (type
== null || hiders
== null || hiders
.size() == 0) return true;
42 final Class aClass
= DomUtil
.getRawType(type
);
44 List
<Class
> allParents
= new ArrayList
<Class
>();
45 for (Map
.Entry
<Class
, Boolean
> entry
: hiders
.entrySet()) {
46 if (entry
.getKey().isAssignableFrom(aClass
)) {
47 allParents
.add(entry
.getKey());
51 if (allParents
.size() == 0) return false;
53 final Class
[] classes
= allParents
.toArray(new Class
[allParents
.size()]);
54 Arrays
.sort(classes
, new Comparator
<Class
>() {
55 public int compare(final Class o1
, final Class o2
) {
56 return o1
.isAssignableFrom(o2
) ?
1 : -1;
60 return hiders
.get(classes
[0]).booleanValue();
63 public boolean isExpanded() {
67 public void setExpanded(final boolean expanded
) {
68 isExpanded
= expanded
;