logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r1034893 - in /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw: ChainsawCyclicBufferTableModel.java EventContainer.java LogPanel.java LoggingEventWrapper.java
Date Sat, 13 Nov 2010 22:20:46 GMT
Author: sdeboy
Date: Sat Nov 13 22:20:45 2010
New Revision: 1034893

URL: http://svn.apache.org/viewvc?rev=1034893&view=rev
Log:
Update the search result count in the status bar to contain the search matches which are displayed
on screen (was previously showing search match count for all events, including events not
displayed due to a filter rule)

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/EventContainer.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggingEventWrapper.java

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java?rev=1034893&r1=1034892&r2=1034893&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
Sat Nov 13 22:20:45 2010
@@ -440,7 +440,8 @@ class ChainsawCyclicBufferTableModel ext
         for (Iterator iter = unfilteredListCopy.iterator();iter.hasNext();) {
             LoggingEventWrapper loggingEventWrapper = (LoggingEventWrapper) iter.next();
             loggingEventWrapper.evaluateSearchRule(findRule);
-            if (loggingEventWrapper.isSearchMatch()) {
+            //return the count of visible search matches
+            if (loggingEventWrapper.isSearchMatch() && loggingEventWrapper.isDisplayed())
{
                 count++;
             }
         }
@@ -489,7 +490,20 @@ class ChainsawCyclicBufferTableModel ext
       return -1;
     }
 
-    public int getColumnCount() {
+  public int getSearchMatchCount() {
+    int searchMatchCount = 0;
+    synchronized(mutex) {
+      for (Iterator iter = filteredList.iterator();iter.hasNext();) {
+        LoggingEventWrapper wrapper = (LoggingEventWrapper) iter.next();
+        if (wrapper.isSearchMatch() && wrapper.isDisplayed()) {
+          searchMatchCount++;
+        }
+      }
+    }
+    return searchMatchCount;
+  }
+
+  public int getColumnCount() {
     return columnNames.size();
   }
 

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/EventContainer.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/EventContainer.java?rev=1034893&r1=1034892&r2=1034893&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/EventContainer.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/EventContainer.java Sat
Nov 13 22:20:45 2010
@@ -175,4 +175,11 @@ public interface EventContainer extends 
    * @return
    */
   int findColoredRow(int currentRow, boolean forward);
+
+  /**
+   * Return the visible search match count
+   *
+   * @return
+   */
+  int getSearchMatchCount();
 }

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java?rev=1034893&r1=1034892&r2=1034893&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java Sat Nov 13
22:20:45 2010
@@ -2154,7 +2154,7 @@ public class LogPanel extends DockablePa
           //these are actual LoggingEvent instances
           LoggingEvent event = (LoggingEvent)iter.next();
           //create two separate loggingEventWrappers (main table and search table), as they
have different info on display state
-          LoggingEventWrapper loggingEventWrapper1 = new LoggingEventWrapper(event, tableModel);
+          LoggingEventWrapper loggingEventWrapper1 = new LoggingEventWrapper(event);
             //if the clearTableExpressionRule is not null, evaluate & clear the table
if it matches
             if (clearTableExpressionRule != null && clearTableExpressionRule.evaluate(event,
null)) {
                 logger.info("clear table expression matched - clearing table - matching event
msg - " + event.getMessage());
@@ -2169,7 +2169,7 @@ public class LogPanel extends DockablePa
           rowAdded = rowAdded || isCurrentRowAdded;
 
           //create a new loggingEventWrapper via copy constructor to ensure same IDs
-          LoggingEventWrapper loggingEventWrapper2 = new LoggingEventWrapper(loggingEventWrapper1,
searchModel);
+          LoggingEventWrapper loggingEventWrapper2 = new LoggingEventWrapper(loggingEventWrapper1);
           boolean isSearchCurrentRowAdded = searchModel.isAddRow(loggingEventWrapper2);
           if (isSearchCurrentRowAdded) {
               searchAddedRowCount++;
@@ -3453,17 +3453,29 @@ public class LogPanel extends DockablePa
         tableRuleMediator.setFilterRule(null);
         searchRuleMediator.setFilterRule(null);
         textField.setToolTipText(defaultToolTip);
+        if (findRule != null) {
+          currentSearchMatchCount=tableModel.getSearchMatchCount();
+          statusBar.setSearchMatchCount(currentSearchMatchCount, getIdentifier());
+        }
       } else {
         try {
           tableRuleMediator.setFilterRule(ExpressionRule.getRule(textField.getText()));
           searchRuleMediator.setFilterRule(ExpressionRule.getRule(textField.getText()));
           textField.setToolTipText(defaultToolTip);
+          if (findRule != null) {
+            currentSearchMatchCount=tableModel.getSearchMatchCount();
+            statusBar.setSearchMatchCount(currentSearchMatchCount, getIdentifier());
+          }
           //valid expression, reset background color in case we were previously an invalid
expression
           textField.setBackground(UIManager.getColor("TextField.background"));
         } catch (IllegalArgumentException iae) {
           //invalid expression, change background of the field
           textField.setToolTipText(iae.getMessage());
           textField.setBackground(ChainsawConstants.INVALID_EXPRESSION_BACKGROUND);
+          if (findRule != null) {
+            currentSearchMatchCount=tableModel.getSearchMatchCount();
+            statusBar.setSearchMatchCount(currentSearchMatchCount, getIdentifier());
+          }
         }
       }
     }

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggingEventWrapper.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggingEventWrapper.java?rev=1034893&r1=1034892&r2=1034893&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggingEventWrapper.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggingEventWrapper.java
Sat Nov 13 22:20:45 2010
@@ -48,18 +48,16 @@ public class LoggingEventWrapper {
   //a Map of event fields to Sets of string matches (can be used to render matches differently)
   Map eventMatches = new HashMap();
   private LoggingEventWrapper syncWrapper;
-  private EventContainer eventContainer;
+  private boolean displayed;
 
-  public LoggingEventWrapper(LoggingEvent loggingEvent, EventContainer eventContainer) {
+  public LoggingEventWrapper(LoggingEvent loggingEvent) {
     this.loggingEvent = loggingEvent;
-    this.eventContainer = eventContainer;
   }
 
-  public LoggingEventWrapper(LoggingEventWrapper loggingEventWrapper, EventContainer eventContainer)
{
+  public LoggingEventWrapper(LoggingEventWrapper loggingEventWrapper) {
     this.loggingEvent = loggingEventWrapper.getLoggingEvent();
     this.id = loggingEventWrapper.id;
     this.syncWrapper = loggingEventWrapper;
-    this.eventContainer = eventContainer;
     loggingEventWrapper.syncWrapper = this;
   }
 
@@ -157,12 +155,17 @@ public class LoggingEventWrapper {
   public void setDisplayed(boolean b) {
     markerHeight = DEFAULT_HEIGHT;
     msgHeight = DEFAULT_HEIGHT;
+    displayed = b;
   }
 
   public void setPreviousDisplayedEventTimestamp(long previousDisplayedEventTimeStamp) {
     setProperty(ChainsawConstants.MILLIS_DELTA_COL_NAME_LOWERCASE, String.valueOf(loggingEvent.getTimeStamp()
- previousDisplayedEventTimeStamp));
   }
 
+  public boolean isDisplayed() {
+    return displayed;
+  }
+
   public boolean equals(Object o) {
     if (this == o) {
       return true;



Mime
View raw message