logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r996251 - in /logging/chainsaw/trunk/src/main: java/org/apache/log4j/chainsaw/LogPanel.java java/org/apache/log4j/chainsaw/TableColorizingRenderer.java resources/org/apache/log4j/chainsaw/help/release-notes.html
Date Sun, 12 Sep 2010 04:29:45 GMT
Author: sdeboy
Date: Sun Sep 12 04:29:45 2010
New Revision: 996251

URL: http://svn.apache.org/viewvc?rev=996251&view=rev
Log:
Added 'Show times relative to previous rows' feature - displays millis to last displayed event
in the timestamp field

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.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/LogPanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java?rev=996251&r1=996250&r2=996251&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 Sun Sep 12
04:29:45 2010
@@ -890,7 +890,7 @@ public class LogPanel extends DockablePa
         }
       });
 
-    renderer = new TableColorizingRenderer(colorizer, applicationPreferenceModel);
+    renderer = new TableColorizingRenderer(colorizer, applicationPreferenceModel, tableModel);
     renderer.setToolTipsVisible(preferenceModel.isToolTips());
 
     table.setDefaultRenderer(Object.class, renderer);
@@ -1668,8 +1668,22 @@ public class LogPanel extends DockablePa
         }
       });
 
+      final JMenuItem menuItemDisplayRelativeTimesToPreviousRow =
+        new JMenuItem("Show times relative to previous rows");
+      menuItemDisplayRelativeTimesToPreviousRow.addActionListener(
+        new ActionListener() {
+          public void actionPerformed(ActionEvent e) {
+              if (currentPoint != null) {
+                renderer.setUseRelativeTimesToPreviousRow();
+                tableModel.reFilter();
+                 menuItemDisplayNormalTimes.setEnabled(true);
+              }
+          }
+        });
+
     menuItemDisplayNormalTimes.setEnabled(false);
     p.add(menuItemDisplayRelativeTimesToRowUnderCursor);
+    p.add(menuItemDisplayRelativeTimesToPreviousRow);
     p.add(menuItemDisplayNormalTimes);
     p.add(new JSeparator());
 

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java?rev=996251&r1=996250&r2=996251&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
Sun Sep 12 04:29:45 2010
@@ -24,14 +24,12 @@ import java.awt.Insets;
 import java.awt.Toolkit;
 import java.awt.font.FontRenderContext;
 import java.awt.font.LineBreakMeasurer;
-import java.awt.font.TextAttribute;
 import java.awt.font.TextLayout;
 import java.text.AttributedCharacterIterator;
 import java.text.AttributedString;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
@@ -72,6 +70,7 @@ import org.apache.log4j.chainsaw.color.R
 import org.apache.log4j.chainsaw.icons.LevelIconFactory;
 import org.apache.log4j.helpers.Constants;
 import org.apache.log4j.rule.Rule;
+import org.apache.log4j.spi.LoggingEvent;
 import org.apache.log4j.spi.LoggingEventFieldResolver;
 
 
@@ -95,7 +94,7 @@ public class TableColorizingRenderer ext
   private int loggerPrecision = 0;
   private boolean toolTipsVisible;
   private String dateFormatTZ;
-  private boolean useRelativeTimes = false;
+  private boolean useRelativeTimesToFixedTime = false;
   private long relativeTimestampBase;
 
   private static int borderWidth = 2;
@@ -120,12 +119,15 @@ public class TableColorizingRenderer ext
   private MutableAttributeSet boldAttributeSet;
   private TabSet tabs;
   private int maxHeight;
+  private boolean useRelativeTimesToPrevious;
+  private EventContainer eventContainer;
 
     /**
    * Creates a new TableColorizingRenderer object.
    */
-  public TableColorizingRenderer(RuleColorizer colorizer, ApplicationPreferenceModel applicationPreferenceModel)
{
+  public TableColorizingRenderer(RuleColorizer colorizer, ApplicationPreferenceModel applicationPreferenceModel,
EventContainer eventContainer) {
     this.applicationPreferenceModel = applicationPreferenceModel;
+    this.eventContainer = eventContainer;
     multiLinePanel.setLayout(new BoxLayout(multiLinePanel, BoxLayout.Y_AXIS));
     generalPanel.setLayout(new BoxLayout(generalPanel, BoxLayout.Y_AXIS));
     levelPanel.setLayout(new BoxLayout(levelPanel, BoxLayout.Y_AXIS));
@@ -170,7 +172,7 @@ public class TableColorizingRenderer ext
   public Component getTableCellRendererComponent(
     final JTable table, Object value, boolean isSelected, boolean hasFocus,
     int row, int col) {
-    value = formatField(value);
+    value = formatField(value, row);
     TableColumn tableColumn = table.getColumnModel().getColumn(col);
 
     JLabel label = (JLabel)super.getTableCellRendererComponent(table, value,
@@ -457,18 +459,26 @@ public class TableColorizingRenderer ext
    *
    * @param o object
    *
+   * @param renderingRow
    * @return formatted object
    */
-  private Object formatField(Object o) {
+  private Object formatField(Object o, int renderingRow) {
     if (!(o instanceof Date)) {
       return (o == null ? "" : o);
     }
 
     //handle date field
-    if (useRelativeTimes)
-    {
+    if (useRelativeTimesToFixedTime) {
         return "" + (((Date)o).getTime() - relativeTimestampBase);
     }
+    if (useRelativeTimesToPrevious) {
+        if (renderingRow == 0) {
+            return "0";
+        } else {
+            LoggingEvent previous = eventContainer.getRow(renderingRow - 1);
+            return "" + (((Date)o).getTime() - previous.getTimeStamp());
+        }
+    }
 
     return dateFormatInUse.format((Date) o);
   }
@@ -501,12 +511,19 @@ public class TableColorizingRenderer ext
   }
 
   public void setUseRelativeTimes(long timeStamp) {
-    useRelativeTimes = true;
+    useRelativeTimesToFixedTime = true;
+    useRelativeTimesToPrevious = false;
     relativeTimestampBase = timeStamp;
   }
 
+  public void setUseRelativeTimesToPreviousRow() {
+     useRelativeTimesToFixedTime = false;
+     useRelativeTimesToPrevious = true;
+  }
+
   public void setUseNormalTimes() {
-    useRelativeTimes = false;
+    useRelativeTimesToFixedTime = false;
+    useRelativeTimesToPrevious = false;
   }
 
    private int calculateHeight(String string, int width, Map paramMap) {

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=996251&r1=996250&r2=996251&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
Sun Sep 12 04:29:45 2010
@@ -10,6 +10,10 @@
 <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>11 Sep 2010</h2>
+<ul>
+<li>Added 'Show times relative to previous rows' feature - displays millis to last
displayed event in the timestamp field</li>
+</ul>
 <h2>17 Aug 2010</h2>
 <ul>
 <li>Cyclic flag is now persisted & restored on a per-tab basis</li>



Mime
View raw message