logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Enrico Spinielli" <Enrico.Spinie...@marconi.com>
Subject how to traverse Category tree in order to build a JTree
Date Tue, 07 Aug 2001 08:23:54 GMT


Hi all,
I would like to know how you can traverse the log4j category tree.
My goal is to build (at runtime) a JTree that represents the available
Categories
and allow the user to change Priority, Appender ...

I thoght I could use something like the following:

   Category cr = Category.getRoot();

   // build a JTree representing the current Log4J category tree
   // and start from root category
   // for any other category ask for its parent and add the new node
   // to the parent node
   DefaultMutableTreeNode r = new DefaultMutableTreeNode(cr);
   DefaultMutableTreeNode n;
   Category c;
   for (Enumeration en = c.getCurrentCategories(); cs.hasMoreElements(); )
   {
      c = (Category)cs.nextElement();

      // create a (DefaultMutable)TreeNode
      n = new DefaultMutableTreeNode(c);

      // find parent Category
      c.getParent(); //!!!!!!!!!!!!!!!!!!!!!!!!!!  HOW  ?????

      // find (DefaultMutable)TreeNode of parent Category
      // ??? my find here

      // and add the corresponding (DefaultMutable)TreeNode
      parentNode.add(n);
   }

   JTree tree = new JTree(r);
   //...

But I cannot find how to retrieve the parent Category...
Any suggestions is welcome
Enrico



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message