logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From psm...@apache.org
Subject cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LogPanelLoggerTreeModel.java
Date Wed, 17 Sep 2003 01:16:27 GMT
psmith      2003/09/16 18:16:27

  Modified:    src/java/org/apache/log4j/chainsaw
                        LogPanelLoggerTreeModel.java
  Log:
  we now track each new FQN logger and it's associated TreeNode
  so that we can look up the TreeNode by full name.
  
  Revision  Changes    Path
  1.6       +36 -5     jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogPanelLoggerTreeModel.java
  
  Index: LogPanelLoggerTreeModel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogPanelLoggerTreeModel.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LogPanelLoggerTreeModel.java	2 Sep 2003 01:07:00 -0000	1.5
  +++ LogPanelLoggerTreeModel.java	17 Sep 2003 01:16:26 -0000	1.6
  @@ -51,9 +51,13 @@
    */
   package org.apache.log4j.chainsaw;
   
  +import org.apache.log4j.helpers.LogLog;
  +
   import java.util.Collections;
   import java.util.Comparator;
   import java.util.Enumeration;
  +import java.util.HashMap;
  +import java.util.Map;
   import java.util.StringTokenizer;
   
   import javax.swing.SwingUtilities;
  @@ -61,6 +65,7 @@
   import javax.swing.tree.DefaultTreeModel;
   import javax.swing.tree.MutableTreeNode;
   
  +
   /**
    *
    * A TreeModel that represents the Loggers for a given LogPanel
  @@ -69,6 +74,8 @@
    */
   class LogPanelLoggerTreeModel extends DefaultTreeModel
     implements LoggerNameListener {
  +  private Map fullPackageMap = new HashMap();
  +
     LogPanelLoggerTreeModel() {
       super(new LogPanelTreeNode("Root Logger"));
     }
  @@ -132,6 +139,19 @@
          */
         final LogPanelTreeNode newChild = new LogPanelTreeNode(packageName);
   
  +      StringBuffer fullPackageBuf = new StringBuffer();
  +
  +      for (int j = 0; j <= i; j++) {
  +        fullPackageBuf.append(packages[i]);
  +
  +        if (j < i) {
  +          fullPackageBuf.append(".");
  +        }
  +      }
  +
  +      LogLog.debug("Adding to Map " + fullPackageBuf.toString());
  +      fullPackageMap.put(fullPackageBuf.toString(), newChild);
  +
         final DefaultMutableTreeNode changedNode = current;
   
         changedNode.add(newChild);
  @@ -142,12 +162,21 @@
           changedIndices[j] = j;
         }
   
  -	  nodesWereInserted(changedNode, new int[]{changedNode.getIndex(newChild)});
  +      nodesWereInserted(
  +        changedNode, new int[] { changedNode.getIndex(newChild) });
         nodesChanged(changedNode, changedIndices);
         current = newChild;
       }
     }
   
  +  LogPanelTreeNode lookupLogger(String logger) {
  +    if (fullPackageMap.containsKey(logger)) {
  +      return (LogPanelTreeNode) fullPackageMap.get(logger);
  +    }
  +
  +    return null;
  +  }
  +
     /**
        * Takes the loggerName and tokenizes it into it's
        * package name lements returning the elements
  @@ -186,12 +215,14 @@
       }
   
       public void insert(MutableTreeNode newChild, int childIndex) {
  -//      LogLog.debug("[" + this.getUserObject() + "] inserting child " + newChild + " @
index " + childIndex);
  -//      LogLog.debug("Children now: " + this.children);
  +      //      LogLog.debug("[" + this.getUserObject() + "] inserting child " + newChild
+ " @ index " + childIndex);
  +      //      LogLog.debug("Children now: " + this.children);
         super.insert(newChild, childIndex);
  -//	  LogLog.debug("Children after insert: " + this.children);
  +
  +      //	  LogLog.debug("Children after insert: " + this.children);
         Collections.sort(this.children, nodeComparator);
  -//	  LogLog.debug("Children after sort: " + this.children);
  +
  +      //	  LogLog.debug("Children after sort: " + this.children);
       }
     }
   }
  
  
  

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


Mime
View raw message