faces tree presentations
[fedora-idea.git] / source / com / intellij / util / xml / tree / DomElementsGroupNode.java
blob21ee2cccd6a269a6aa78be529312f902904dcf0e
1 package com.intellij.util.xml.tree;
3 import com.intellij.ui.SimpleTextAttributes;
4 import com.intellij.util.xml.DomElement;
5 import com.intellij.util.xml.DomUtil;
6 import com.intellij.util.xml.reflect.DomCollectionChildDescription;
7 import com.intellij.javaee.model.ElementPresentationManager;
8 import jetbrains.fabrique.ui.treeStructure.SimpleNode;
10 import javax.swing.*;
11 import java.awt.*;
12 import java.util.List;
13 import java.util.ArrayList;
15 public class DomElementsGroupNode extends AbstractDomElementNode {
16 private DomElement myParentElement;
17 private String myChildrenTagName;
18 private DomCollectionChildDescription myChildDescription;
20 public DomElementsGroupNode(final DomElement modelElement, DomCollectionChildDescription description) {
21 myParentElement = modelElement;
22 myChildDescription = description;
23 myChildrenTagName = description.getXmlElementName();
26 public SimpleNode[] getChildren() {
27 if (!myParentElement.isValid()) return NO_CHILDREN;
29 final List<? extends DomElement> domChildren = myChildDescription.getValues(myParentElement);
30 final List<SimpleNode> simpleNodes = new ArrayList<SimpleNode>();
31 for (DomElement domChild : domChildren) {
32 if (shouldBeShowed(domChild.getDomElementType())) {
33 simpleNodes.add(new BaseDomElementNode(domChild, this));
36 return simpleNodes.toArray(new SimpleNode[simpleNodes.size()]);
39 public Object[] getEqualityObjects() {
40 return new Object[]{myParentElement, myChildrenTagName};
43 protected boolean doUpdate() {
44 setUniformIcon(getNodeIcon());
46 clearColoredText();
47 addColoredFragment(getNodeName(), new SimpleTextAttributes(Font.BOLD, Color.black));
48 final int childrenCount = getChildren().length;
49 addColoredFragment(" (" + childrenCount + ')', new SimpleTextAttributes(Font.ITALIC, Color.gray));
51 return true;
54 public String getNodeName() {
55 return myChildDescription.getCommonPresentableName(myParentElement);
58 public String getTagName() {
59 return myChildrenTagName;
62 public DomElement getDomElement() {
63 return myParentElement;
67 public DomCollectionChildDescription getChildDescription() {
68 return myChildDescription;
71 public Icon getNodeIcon() {
72 return ElementPresentationManager.getPresentationForClass(DomUtil.getRawType(myChildDescription.getType())).getIcon();