logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r982464 - in /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw: LogPanelLoggerTreeModel.java LoggerNameTreePanel.java
Date Thu, 05 Aug 2010 04:35:53 GMT
Author: sdeboy
Date: Thu Aug  5 04:35:53 2010
New Revision: 982464

URL: http://svn.apache.org/viewvc?rev=982464&view=rev
Log:
If focus-on in the logger tree is selected and the event table is cleared, ensure the previously
focused-on logger is added to the logger tree & focus-on is re-enabled for that logger

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelLoggerTreeModel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelLoggerTreeModel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelLoggerTreeModel.java?rev=982464&r1=982463&r2=982464&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelLoggerTreeModel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelLoggerTreeModel.java
Thu Aug  5 04:35:53 2010
@@ -33,6 +33,7 @@ import javax.swing.tree.MutableTreeNode;
 
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
+import org.apache.log4j.chainsaw.helper.SwingHelper;
 
 
 /**
@@ -54,6 +55,7 @@ class LogPanelLoggerTreeModel extends De
    * @see org.apache.log4j.chainsaw.LoggerNameListener#loggerNameAdded(java.lang.String)
    */
   public void loggerNameAdded(final String loggerName) {
+    //invoke later, not on current EDT
     SwingUtilities.invokeLater(
       new Runnable() {
         public void run() {

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java?rev=982464&r1=982463&r2=982464&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
Thu Aug  5 04:35:53 2010
@@ -23,6 +23,7 @@ import java.awt.Color;
 import java.awt.Component;
 import java.awt.Cursor;
 import java.awt.Dimension;
+import java.awt.EventQueue;
 import java.awt.FlowLayout;
 import java.awt.Font;
 import java.awt.Point;
@@ -160,6 +161,7 @@ final class LoggerNameTreePanel extends 
   private Rule ignoreExpressionRule;
   private FilterModel filterModel;
   private boolean expandRootLatch = false;
+  private String currentlySelectedLoggerName;
 
     //~ Constructors ============================================================
 
@@ -1191,7 +1193,7 @@ final class LoggerNameTreePanel extends 
         DefaultMutableTreeNode node =
           (DefaultMutableTreeNode) depthEnum.nextElement();
 
-        if (node.isLeaf())
+        if (node.isLeaf() && node.getParent() != null)
         {
           TreeNode[] nodes =
             ((DefaultMutableTreeNode) node.getParent()).getPath();
@@ -1275,10 +1277,10 @@ final class LoggerNameTreePanel extends 
           }
           boolean focusOnSelected = isFocusOnSelected();
           //          editLoggerAction.setEnabled(path != null);
-          String logger = getCurrentlySelectedLoggerName();
+          currentlySelectedLoggerName = getCurrentlySelectedLoggerName();
           focusOnAction.setEnabled(
             (path != null) && (node != null) && (node.getParent() != null)
-            && !hiddenSet.contains(logger));
+            && !hiddenSet.contains(currentlySelectedLoggerName));
           hideAction.setEnabled(
             (path != null) && (node != null) && (node.getParent() != null));
           if (!focusOnAction.isEnabled())
@@ -1297,9 +1299,9 @@ final class LoggerNameTreePanel extends 
           updateRefineFocusAction.setEnabled(path != null);
           clearRefineFocusAction.setEnabled(true);
 
-          if (logger != null)
+          if (currentlySelectedLoggerName != null)
           {
-            boolean isHidden = hiddenSet.contains(logger);
+            boolean isHidden = hiddenSet.contains(currentlySelectedLoggerName);
             popupMenu.hideCheck.setSelected(isHidden);
             ignoreLoggerButton.setSelected(isHidden);
           }
@@ -1459,6 +1461,20 @@ final class LoggerNameTreePanel extends 
     public void reset()
     {
         expandRootLatch = false;
+        //keep track if focuson was active when we were reset
+        final String logger = currentlySelectedLoggerName;
+        final boolean focusOnSelected = isFocusOnSelected();
+        if (logger == null || !focusOnSelected) {
+            return;
+        }
+
+        //loggernameAdded runs on EDT
+        logTreeModel.loggerNameAdded(logger);
+        EventQueue.invokeLater(new Runnable() {
+            public void run() {
+                setFocusOn(logger);
+            }
+        });
     }
 
     //~ Inner Classes ===========================================================



Mime
View raw message