Exemple #1
0
 private GroovyTreeNode(GroovyTreeNode parent, GroovyNode node) {
   this.parent = parent;
   this.node = node;
   for (Map.Entry<String, String> entry : node.attributes().entrySet()) {
     children.add(new GroovyTreeNode(this, entry.getKey(), entry.getValue()));
   }
   if (node.getNodeValue() instanceof List) {
     string = node.getNodeName();
     toolTip = String.format("Size: %d", ((List) node.getNodeValue()).size());
   } else {
     String truncated = node.text();
     if (truncated.contains("\n") || truncated.length() >= MAX_LENGTH) {
       int index = truncated.indexOf('\n');
       if (index > 0) truncated = truncated.substring(0, index);
       if (truncated.length() >= MAX_LENGTH) truncated = truncated.substring(0, MAX_LENGTH);
       string = String.format("<html><b>%s</b> = %s ...</html>", node.getNodeName(), truncated);
       toolTip = tameTooltipText(node.text());
     } else {
       string = String.format("<html><b>%s</b> = %s</html>", node.getNodeName(), truncated);
       toolTip = truncated;
     }
   }
   if (this.node.getNodeValue() instanceof List) {
     for (Object sub : ((List) this.node.getNodeValue())) {
       GroovyNode subnode = (GroovyNode) sub;
       children.add(new GroovyTreeNode(this, subnode));
     }
     Collections.sort(children);
   }
 }
Exemple #2
0
 @Override
 public int compareTo(GroovyTreeNode gtn) {
   if (attrKey != null && gtn.attrKey == null) return -1;
   if (attrKey == null && gtn.attrKey != null) return 1;
   if (attrKey != null && gtn.attrKey != null) return attrKey.compareTo(gtn.attrKey);
   return node.getNodeName().compareTo(gtn.node.getNodeName());
 }