Ejemplo n.º 1
0
    @Override
    public void customizeCellRenderer(
        JTree tree,
        Object value,
        boolean selected,
        boolean expanded,
        boolean leaf,
        int row,
        boolean hasFocus) {
      InspectionTreeNode node = (InspectionTreeNode) value;

      append(
          node.toString(),
          patchAttr(
              node,
              appearsBold(node)
                  ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES
                  : getMainForegroundAttributes(node)));

      int problemCount = node.getProblemCount();
      if (!leaf) {
        append(
            " " + InspectionsBundle.message("inspection.problem.descriptor.count", problemCount),
            patchAttr(node, SimpleTextAttributes.GRAYED_ATTRIBUTES));
      }

      if (!node.isValid()) {
        append(
            " " + InspectionsBundle.message("inspection.invalid.node.text"),
            patchAttr(node, SimpleTextAttributes.ERROR_ATTRIBUTES));
      } else {
        setIcon(node.getIcon(expanded));
      }
    }
Ejemplo n.º 2
0
 private static void addElementsInNode(InspectionTreeNode node, List<RefEntity> out) {
   if (!node.isValid()) return;
   if (node instanceof RefElementNode) {
     final RefEntity element = ((RefElementNode) node).getElement();
     if (!out.contains(element)) {
       out.add(0, element);
     }
   }
   if (node instanceof ProblemDescriptionNode) {
     final RefEntity element = ((ProblemDescriptionNode) node).getElement();
     if (!out.contains(element)) {
       out.add(0, element);
     }
   }
   final Enumeration children = node.children();
   while (children.hasMoreElements()) {
     InspectionTreeNode child = (InspectionTreeNode) children.nextElement();
     addElementsInNode(child, out);
   }
 }
Ejemplo n.º 3
0
 @Override
 public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
   final InspectionTreeNode node = (InspectionTreeNode) event.getPath().getLastPathComponent();
   final Object userObject = node.getUserObject();
   // TODO: never re-sort
   if (node.isValid() && !myExpandedUserObjects.contains(userObject)) {
     sortChildren(node);
     nodeStructureChanged(node);
   }
   myExpandedUserObjects.add(userObject);
   // Smart expand
   if (node.getChildCount() == 1) {
     ApplicationManager.getApplication()
         .invokeLater(
             new Runnable() {
               @Override
               public void run() {
                 expandPath(new TreePath(node.getPath()));
               }
             });
   }
 }