logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r986570 - in /logging/chainsaw/trunk/src/main: java/org/apache/log4j/chainsaw/ resources/org/apache/log4j/chainsaw/help/
Date Wed, 18 Aug 2010 05:52:10 GMT
Author: sdeboy
Date: Wed Aug 18 05:52:10 2010
New Revision: 986570

URL: http://svn.apache.org/viewvc?rev=986570&view=rev
Log:
Cyclic flag is now persisted & restored on a per-tab basis

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/LogPanelPreferenceModel.java
    logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/help/release-notes.html

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=986570&r1=986569&r2=986570&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
Wed Aug 18 05:52:10 2010
@@ -63,6 +63,7 @@ class ChainsawCyclicBufferTableModel ext
   implements EventContainer, PropertyChangeListener {
 
   private static final int DEFAULT_CAPACITY = 5000;
+  //cyclic field used internally in this class, but not exposed via the eventcontainer
   private boolean cyclic = true;
   private int cyclicBufferSize = DEFAULT_CAPACITY;
   List unfilteredList;
@@ -475,7 +476,7 @@ class ChainsawCyclicBufferTableModel ext
 
   public ExtendedLoggingEvent getRow(int row) {
     synchronized (mutex) {
-      if (row < filteredList.size()) {
+      if (row < filteredList.size() && row > -1) {
         return (ExtendedLoggingEvent) filteredList.get(row);
       }
     }
@@ -613,7 +614,7 @@ class ChainsawCyclicBufferTableModel ext
          * memory...)
          */
     synchronized(mutex) {
-        if (isCyclic()) {
+        if (cyclic) {
             CyclicBufferList bufferList = (CyclicBufferList) unfilteredList;
             if (bufferList.size() == bufferList.getMaxSize()) {
                 reachedCapacity = true;
@@ -717,14 +718,6 @@ class ChainsawCyclicBufferTableModel ext
   }
 
   /**
-     * Returns true if this model is Cyclic (bounded) or not
-     * @return true/false
-     */
-  public boolean isCyclic() {
-    return cyclic;
-  }
-
-  /**
    * @return
    */
   public int getMaxSize() {
@@ -825,12 +818,12 @@ class ChainsawCyclicBufferTableModel ext
                   monitor.setMillisToDecideToPopup(250);
                   monitor.setMillisToPopup(100);
                   logger.debug(
-                    "Changing Model, isCyclic is now " + isCyclic());
+                    "Changing Model, isCyclic is now " + cyclic);
 
                   List newUnfilteredList = null;
                   List newFilteredList = null;
 
-                  if (isCyclic()) {
+                  if (cyclic) {
                     newUnfilteredList = new CyclicBufferList(cyclicBufferSize);
                     newFilteredList = new CyclicBufferList(cyclicBufferSize);
                   } else {

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=986570&r1=986569&r2=986570&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 Wed
Aug 18 05:52:10 2010
@@ -68,12 +68,6 @@ public interface EventContainer extends 
   List getMatchingEvents(Rule rule);
 
   /**
-   * Returns true if this model is Cyclic (bounded) or not.
-   * @return true/false
-   */
-  boolean isCyclic();
-
-  /**
    * Configures this model to use Cyclic or non-cyclic models.
    * This method should fire a property Change event if
    * it involves an actual change in the underlying model.

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=986570&r1=986569&r2=986570&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 Wed Aug 18
05:52:10 2010
@@ -683,7 +683,7 @@ public class LogPanel extends DockablePa
         boolean warning100 = false;
 
         public void eventCountChanged(int currentCount, int totalCount) {
-          if (tableModel.isCyclic()) {
+          if (preferenceModel.isCyclic()) {
             double percent =
               ((double) totalCount) / ((ChainsawCyclicBufferTableModel) tableModel)
               .getMaxSize();
@@ -972,21 +972,6 @@ public class LogPanel extends DockablePa
         }
       });
 
-    tableModel.addPropertyChangeListener(
-      "cyclic",
-      new PropertyChangeListener() {
-        public void propertyChange(PropertyChangeEvent arg0) {
-          if (tableModel.isCyclic()) {
-            MessageCenter.getInstance().getLogger().warn(
-              "Changed to Cyclic Mode. Maximum # events kept: "
-              + tableModel.getMaxSize());
-          } else {
-            MessageCenter.getInstance().getLogger().warn(
-              "Changed to Unlimited Mode. Warning, you may run out of memory.");
-          }
-        }
-      });
-
     //if the table is refiltered, try to reselect the last selected row
     //refilter with a newValue of TRUE means refiltering is about to begin
     //refilter with a newValue of FALSE means refiltering is complete
@@ -997,7 +982,10 @@ public class LogPanel extends DockablePa
             //if new value is true, filtering is about to begin
             //if new value is false, filtering is complete
             if (evt.getNewValue().equals(Boolean.TRUE)) {
-                currentEvent = tableModel.getRow(table.getSelectedRow());
+                int currentRow = table.getSelectedRow();
+                if (currentRow > -1) {
+                    currentEvent = tableModel.getRow(currentRow);
+                }
             } else {
                 if (currentEvent != null) {
                     table.scrollToRow(tableModel.getRowIndex(currentEvent));
@@ -1918,6 +1906,8 @@ public class LogPanel extends DockablePa
                 } else {
                     loadDefaultColumnSettings(event);
                 }
+                //ensure tablemodel cyclic flag is updated
+                tableModel.setCyclic(preferenceModel.isCyclic());
                 //may be panel configs that don't have these values
                 lowerPanel.setDividerLocation(lowerPanelDividerLocation);
                 nameTreeAndMainPanelSplit.setDividerLocation(treeDividerLocation);
@@ -2211,7 +2201,10 @@ public class LogPanel extends DockablePa
    * events or an ArrayList of events
    */
   void toggleCyclic() {
-    tableModel.setCyclic(!tableModel.isCyclic());
+    boolean toggledCyclic = !preferenceModel.isCyclic();
+
+    preferenceModel.setCyclic(toggledCyclic);
+    tableModel.setCyclic(toggledCyclic);
   }
 
   /**
@@ -2220,7 +2213,7 @@ public class LogPanel extends DockablePa
    * @return flag answering if LoggingEvent container is a cyclic buffer
    */
   boolean isCyclic() {
-    return tableModel.isCyclic();
+    return preferenceModel.isCyclic();
   }
 
   public void updateFindRule(String ruleText) {

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java?rev=986570&r1=986569&r2=986570&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
Wed Aug 18 05:52:10 2010
@@ -86,6 +86,8 @@ public class LogPanelPreferenceModel imp
   private boolean highlightSearchMatchText;
   private String hiddenExpression;
   private String clearTableExpression;
+  //default to cyclic mode
+  private boolean cyclic = true;
 
     /**
    * Returns an <b>unmodifiable</b> list of the columns.
@@ -99,6 +101,14 @@ public class LogPanelPreferenceModel imp
   public List getColumns() {
       return Collections.unmodifiableList(allColumns);
   }
+
+  public void setCyclic(boolean cyclic) {
+    this.cyclic = cyclic;
+  }
+
+  public boolean isCyclic() {
+      return cyclic;
+  }
   
   /**
    * Returns an <b>unmodifiable</b> list of the visible columns.
@@ -222,6 +232,7 @@ public class LogPanelPreferenceModel imp
    * all the properties from
    */
   public void apply(LogPanelPreferenceModel model) {
+    setCyclic(model.isCyclic());
     setLoggerPrecision(model.getLoggerPrecision());
     setDateFormatPattern(model.getDateFormatPattern());
     setLevelIcons(model.isLevelIcons());

Modified: logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/help/release-notes.html
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/help/release-notes.html?rev=986570&r1=986569&r2=986570&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/help/release-notes.html
(original)
+++ logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/help/release-notes.html
Wed Aug 18 05:52:10 2010
@@ -10,9 +10,13 @@
 <b>NOTE:</b> The mechanism and format used to persist settings in Chainsaw is
subject to change.  If you are experiencing problems displaying events in Chainsaw, please
delete everything in the $user.dir/.chainsaw directory and restart Chainsaw.
 <br>
 <h1>2.1</h1>
+<h2>17 Aug 2010</h2>
+<ul>
+<li>Cyclic flag is now persisted & restored on a per-tab basis</li>
+</ul>
 <h2>3 Aug 2010</h2>
 <ul>
-<li>Now clearing the logger name tree when the table is cleared.</li>
+<li>Now clearing the logger name tree when the table is cleared</li>
 </ul>
 <h2>21 Jul 2010</h2>
 <ul>



Mime
View raw message