logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r958185 - in /logging/chainsaw/trunk/src/main: java/org/apache/log4j/chainsaw/ resources/org/apache/log4j/chainsaw/ resources/org/apache/log4j/chainsaw/help/
Date Sat, 26 Jun 2010 05:58:40 GMT
Author: sdeboy
Date: Sat Jun 26 05:58:39 2010
New Revision: 958185

URL: http://svn.apache.org/viewvc?rev=958185&view=rev
Log:
Added new log panel feature: 'clear table expression' (define an expression that will automatically
clear the table)
Fixed find next/previous selection logic so the selected row is always visible
Fixed table cell rendering bug (foreground wasn't being applied to all fields)
The ASL header added to the example receiver config caused the config to no longer display
correctly - changed the header to not be in a comment (we don't process this file, it's an
example for users to copy & modify)

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JSortTable.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/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.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
    logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/log4j-receiver-sample.xml

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java?rev=958185&r1=958184&r2=958185&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java
Sat Jun 26 05:58:39 2010
@@ -49,17 +49,14 @@ public class ChainsawConstants {
 
   public static final URL WELCOME_URL = ChainsawConstants.class.getClassLoader().getResource(
   "org/apache/log4j/chainsaw/WelcomePanel.html");
-  
-  public static final URL EXAMLE_CONFIG_URL =
-  ChainsawConstants.class.getClassLoader().getResource(
-	  "org/apache/log4j/chainsaw/log4j-receiver-sample.xml");
+
+  public static final URL EXAMPLE_CONFIG_URL = 
+          ChainsawConstants.class.getClassLoader().getResource("org/apache/log4j/chainsaw/log4j-receiver-sample.xml");
 
   public static final URL TUTORIAL_URL =
-  ChainsawConstants.class.getClassLoader().getResource(
-	  "org/apache/log4j/chainsaw/help/tutorial.html");
+          ChainsawConstants.class.getClassLoader().getResource("org/apache/log4j/chainsaw/help/tutorial.html");
   public static final URL RELEASE_NOTES_URL =
-      ChainsawConstants.class.getClassLoader().getResource(
-          "org/apache/log4j/chainsaw/help/release-notes.html");
+          ChainsawConstants.class.getClassLoader().getResource("org/apache/log4j/chainsaw/help/release-notes.html");
         
   static final String MAIN_PANEL = "panel";
   static final String LOWER_PANEL = "lower";

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JSortTable.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JSortTable.java?rev=958185&r1=958184&r2=958185&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JSortTable.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JSortTable.java Sat Jun
26 05:58:39 2010
@@ -98,11 +98,17 @@ public class JSortTable extends JTable i
       public void run() {
         if ((row > -1) && (row < getRowCount())) {
           try {
-            setRowSelectionInterval(row, row);
             //get the requested row off of the bottom and top of the screen by making the
5 rows around the requested row visible
-            scrollRectToVisible(getCellRect(row + 5, col, true));
-            scrollRectToVisible(getCellRect(row - 5, col, true));
+            int currentRow = getSelectedRow();
+            //if new past current row, scroll to display the 5th row past new selected row
+            if (row > currentRow) {
+                scrollRectToVisible(getCellRect(row + 5, col, true));
+            }
+            if (row < currentRow) {
+                scrollRectToVisible(getCellRect(row - 5, col, true));
+            }
             scrollRectToVisible(getCellRect(row, col, true));
+            setRowSelectionInterval(row, row);
           } catch (IllegalArgumentException iae) {
             //ignore..out of bounds
           }

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=958185&r1=958184&r2=958185&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 Jun 26
05:58:39 2010
@@ -255,6 +255,7 @@ public class LogPanel extends DockablePa
   private JScrollPane eventsPane;
   private int currentSearchMatchCount;
   private ApplicationPreferenceModel applicationPreferenceModel;
+  private Rule clearTableExpressionRule;
 
     /**
    * Creates a new LogPanel object.  If a LogPanel with this identifier has
@@ -553,6 +554,20 @@ public class LogPanel extends DockablePa
       "dateFormatPattern", datePrefsChangeListener);
     preferenceModel.addPropertyChangeListener("dateFormatTimeZone", datePrefsChangeListener);
 
+    preferenceModel.addPropertyChangeListener("clearTableExpression", new PropertyChangeListener()
{
+        public void propertyChange(PropertyChangeEvent evt) {
+            LogPanelPreferenceModel model = (LogPanelPreferenceModel)evt.getSource();
+            String expression = model.getClearTableExpression();
+            try {
+                clearTableExpressionRule = ExpressionRule.getRule(expression);
+                logger.info("clearTableExpressionRule set to: " + expression);
+            } catch (Exception e) {
+                logger.info("clearTableExpressionRule invalid - ignoring: " + expression);
+                clearTableExpressionRule = null;
+            }
+        }
+    });
+
     preferenceModel.addPropertyChangeListener(
       "loggerPrecision",
       new PropertyChangeListener() {
@@ -1775,6 +1790,11 @@ public class LogPanel extends DockablePa
         int addedRowCount = 0;
         for (Iterator iter = events.iterator(); iter.hasNext();) {
           ExtendedLoggingEvent event = new ExtendedLoggingEvent((LoggingEvent) iter.next());
+            //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());
+                clearEvents();
+            }
 
           updateOtherModels(event);
 
@@ -1910,6 +1930,13 @@ public class LogPanel extends DockablePa
 
     logTreePanel.ignore(preferenceModel.getHiddenLoggers());
     logTreePanel.setHiddenExpression(preferenceModel.getHiddenExpression());
+    if (preferenceModel.getClearTableExpression() != null) {
+        try {
+            clearTableExpressionRule = ExpressionRule.getRule(preferenceModel.getClearTableExpression());
+        } catch (Exception e) {
+            clearTableExpressionRule = null;
+        }
+    }
 
     //attempt to load color settings - no need to URL encode the identifier
     colorizer.loadColorSettings(identifier);

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=958185&r1=958184&r2=958185&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
Sat Jun 26 05:58:39 2010
@@ -85,6 +85,7 @@ public class LogPanelPreferenceModel imp
   private boolean wrapMsg;
   private boolean highlightSearchMatchText;
   private String hiddenExpression;
+  private String clearTableExpression;
 
     /**
    * Returns an <b>unmodifiable</b> list of the columns.
@@ -239,6 +240,7 @@ public class LogPanelPreferenceModel imp
     setVisibleColumns(model.getVisibleColumns());
     setHiddenLoggers(model.getHiddenLoggers());
     setHiddenExpression(model.getHiddenExpression());
+    setClearTableExpression(model.getClearTableExpression());
   }
 
   /**
@@ -464,4 +466,18 @@ public class LogPanelPreferenceModel imp
   public String getHiddenExpression() {
     return hiddenExpression;
   }
+
+  public void setClearTableExpression(String clearTableExpression) {
+    Object oldValue = this.clearTableExpression;
+    this.clearTableExpression = clearTableExpression;
+    //no propertychange if both null
+    if (oldValue == null && this.clearTableExpression == null) {
+        return;
+    }
+    propertySupport.firePropertyChange("clearTableExpression", oldValue, this.clearTableExpression);
+  }
+
+  public String getClearTableExpression() {
+    return clearTableExpression;
+  }
 }

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java?rev=958185&r1=958184&r2=958185&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java
Sat Jun 26 05:58:39 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.log4j.chainsaw;
 
+import java.awt.BorderLayout;
 import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
@@ -34,6 +35,7 @@ import javax.swing.Box;
 import javax.swing.BoxLayout;
 import javax.swing.ButtonGroup;
 import javax.swing.JCheckBox;
+import javax.swing.JEditorPane;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JList;
@@ -169,7 +171,7 @@ public class LogPanelPreferencePanel ext
 
       //		columnBox.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
"Displayed Columns"));
       final JList columnList = new JList();
-      columnList.setVisibleRowCount(10);
+      columnList.setVisibleRowCount(17);
 
       for (
         Iterator iter = preferenceModel.getColumns().iterator();
@@ -585,6 +587,7 @@ public class LogPanelPreferencePanel ext
       new JCheckBox("Show Event Detail Tooltips");
     private final JCheckBox thumbnailBarToolTips =
       new JCheckBox("Show Thumbnail Bar Tooltips");
+    private final JEditorPane clearTableExpression = new JEditorPane();
 
     //~ Constructors ==========================================================
 
@@ -605,13 +608,27 @@ public class LogPanelPreferencePanel ext
     */
     private void initPanelComponents()
     {
+      JTextComponentFormatter.applySystemFontAndSize(clearTableExpression);
       setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
-
+      toolTips.setAlignmentX(Component.LEFT_ALIGNMENT);
+      thumbnailBarToolTips.setAlignmentX(Component.LEFT_ALIGNMENT);
+      detailPanelVisible.setAlignmentX(Component.LEFT_ALIGNMENT);
+      loggerTreePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
+      scrollToBottom.setAlignmentX(Component.LEFT_ALIGNMENT);
       add(toolTips);
       add(thumbnailBarToolTips);
       add(detailPanelVisible);
       add(loggerTreePanel);
       add(scrollToBottom);
+      JPanel clearPanel = new JPanel(new BorderLayout());
+      clearPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
+      clearPanel.add(new JLabel("Clear all events if expression matches"), BorderLayout.NORTH);
+      clearTableExpression.setText(preferenceModel.getClearTableExpression());
+      clearTableExpression.setPreferredSize(new Dimension(300, 50));
+      JPanel clearTableScrollPanel = new JPanel(new BorderLayout());
+      clearTableScrollPanel.add(new JScrollPane(clearTableExpression), BorderLayout.NORTH);
+      clearPanel.add(clearTableScrollPanel, BorderLayout.CENTER);
+      add(clearPanel);
 
       toolTips.setSelected(preferenceModel.isToolTips());
       thumbnailBarToolTips.setSelected(preferenceModel.isThumbnailBarToolTips());
@@ -638,6 +655,12 @@ public class LogPanelPreferencePanel ext
           }
       });
 
+      getOkButton().addActionListener(new ActionListener() {
+          public void actionPerformed(ActionEvent e) {
+              preferenceModel.setClearTableExpression(clearTableExpression.getText().trim());
+          }
+      });
+
       preferenceModel.addPropertyChangeListener(
         "toolTips", new PropertyChangeListener()
         {
@@ -743,6 +766,13 @@ public class LogPanelPreferencePanel ext
                     columnListModel.fireContentsChanged();
                   }
                 });
+
+        preferenceModel.addPropertyChangeListener("clearTableExpression", new PropertyChangeListener()
+        {
+            public void propertyChange(PropertyChangeEvent evt) {
+                clearTableExpression.setText(((LogPanelPreferenceModel)evt.getSource()).getClearTableExpression());
+            }
+        });
     }
   }
 }

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java?rev=958185&r1=958184&r2=958185&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java Sat Jun 26 05:58:39
2010
@@ -645,7 +645,7 @@ public class LogUI extends JFrame implem
       new AbstractAction("View example Receiver configuration") {
         public void actionPerformed(ActionEvent e) {
           HelpManager.getInstance().setHelpURL(
-            ChainsawConstants.EXAMLE_CONFIG_URL);
+            ChainsawConstants.EXAMPLE_CONFIG_URL);
         }
       };
 
@@ -1939,6 +1939,9 @@ public class LogUI extends JFrame implem
       throws IllegalArgumentException {
       final LogPanel thisPanel = new LogPanel(getStatusBar(), ident, cyclicBufferSize, allColorizers,
applicationPreferenceModel);
 
+      getSettingsManager().addSettingsListener(thisPanel);
+      getSettingsManager().configure(thisPanel);
+
 
       /**
                * Now add the panel as a batch listener so it can handle it's own
@@ -1993,9 +1996,6 @@ public class LogUI extends JFrame implem
       getTabbedPane().add(ident, thisPanel);
       getPanelMap().put(ident, thisPanel);
 
-      getSettingsManager().addSettingsListener(thisPanel);
-      getSettingsManager().configure(thisPanel);
-
       /**
                * Let the new LogPanel receive this batch
                */

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=958185&r1=958184&r2=958185&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
Sat Jun 26 05:58:39 2010
@@ -370,16 +370,10 @@ public class TableColorizingRenderer ext
     //update the background & foreground of the jtextpane using styles
     if (multiLineTextPane != null)
     {
-        StyledDocument styledDocument = multiLineTextPane.getStyledDocument();
-        MutableAttributeSet attributes = multiLineTextPane.getInputAttributes();
-        StyleConstants.setForeground(attributes, foreground);
-        styledDocument.setCharacterAttributes(0, styledDocument.getLength() + 1, attributes,
false);
-        multiLineTextPane.setBackground(background);
+        updateColors(multiLineTextPane, background, foreground);
     }
-    levelTextPane.setBackground(background);
-    levelTextPane.setForeground(foreground);
-    singleLineTextPane.setBackground(background);
-    singleLineTextPane.setForeground(foreground);
+    updateColors(levelTextPane, background, foreground);
+    updateColors(singleLineTextPane, background, foreground);
 
     if (isSelected) {
       if (col == 0) {
@@ -401,7 +395,16 @@ public class TableColorizingRenderer ext
     return component;
   }
 
-  /**
+    private void updateColors(JTextPane textPane, Color background, Color foreground)
+    {
+        StyledDocument styledDocument = textPane.getStyledDocument();
+        MutableAttributeSet attributes = textPane.getInputAttributes();
+        StyleConstants.setForeground(attributes, foreground);
+        styledDocument.setCharacterAttributes(0, styledDocument.getLength() + 1, attributes,
false);
+        textPane.setBackground(background);
+    }
+
+    /**
    * Changes the Date Formatting object to be used for rendering dates.
    * @param formatter
    */

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=958185&r1=958184&r2=958185&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
Sat Jun 26 05:58:39 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>25 Jun 2010</h2>
+<ul>
+<li>Added new log panel feature: 'clear table expression' (define an expression that
will automatically clear the table)</li>
+</ul>
 <h2>24 Jun 2010</h2>
 <ul>
 <li>Added 'Load Chainsaw configuration' menu item to file menu, reworded file-open
menu items (file-open currently supports only log4j or util.logging XML-formatted log files).</li>

Modified: logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/log4j-receiver-sample.xml
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/log4j-receiver-sample.xml?rev=958185&r1=958184&r2=958185&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/log4j-receiver-sample.xml
(original)
+++ logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/log4j-receiver-sample.xml
Sat Jun 26 05:58:39 2010
@@ -1,20 +1,20 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements.  See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License.  You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+## copy and modify xml contents below to create a Chainsaw configuration ##
 
--->
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE log4j:configuration >
 <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">



Mime
View raw message