logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r935135 - in /logging/chainsaw/trunk/src: main/java/org/apache/log4j/chainsaw/ main/resources/org/apache/log4j/chainsaw/help/ test/java/org/apache/log4j/chainsaw/
Date Sat, 17 Apr 2010 06:05:23 GMT
Author: sdeboy
Date: Sat Apr 17 06:05:22 2010
New Revision: 935135

URL: http://svn.apache.org/viewvc?rev=935135&view=rev
Log:
Added preference to line wrap the message field in the table (multi-line rows) (setting is
persisted)
Adjusted non-selected border to fix alignment issues between selected & non-selected rows

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

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=935135&r1=935134&r2=935135&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 Apr 17
06:05:22 2010
@@ -424,6 +424,19 @@ public class LogPanel extends DockablePa
         }
       });
 
+    /*
+     * add preferencemodel listeners
+     */
+    preferenceModel.addPropertyChangeListener(
+      "wrapMessage",
+      new PropertyChangeListener() {
+        public void propertyChange(PropertyChangeEvent evt) {
+          renderer.setWrapMessage(
+            ((Boolean) evt.getNewValue()).booleanValue());
+          table.tableChanged(new TableModelEvent(tableModel));
+        }
+      });
+
     preferenceModel.addPropertyChangeListener(
       "detailPaneVisible",
       new PropertyChangeListener() {

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=935135&r1=935134&r2=935135&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 Apr 17 06:05:22 2010
@@ -80,8 +80,9 @@ public class LogPanelPreferenceModel imp
 
   private Collection hiddenLoggers = new HashSet();
   private String timeZone;
-  
-  /**
+  private boolean wrapMsg;
+
+    /**
    * Returns an <b>unmodifiable</b> list of the columns.
    * 
    * The reason it is unmodifiable is to enforce the requirement that
@@ -218,6 +219,7 @@ public class LogPanelPreferenceModel imp
     setLoggerPrecision(model.getLoggerPrecision());
     setDateFormatPattern(model.getDateFormatPattern());
     setLevelIcons(model.isLevelIcons());
+    setWrapMessage(model.isWrapMessage());
     setTimeZone(model.getTimeZone());
     setToolTips(model.isToolTips());
     setScrollToBottom(model.isScrollToBottom());
@@ -248,6 +250,10 @@ public class LogPanelPreferenceModel imp
     return levelIcons;
   }
 
+  public boolean isWrapMessage() {
+    return wrapMsg;
+  }
+
   /**
    * @param levelIcons
    */
@@ -257,6 +263,13 @@ public class LogPanelPreferenceModel imp
   }
 
   /**
+   * @param wrapMsg
+   */
+  public void setWrapMessage(boolean wrapMsg) {
+    this.wrapMsg = wrapMsg;
+    propertySupport.firePropertyChange("wrapMessage", !wrapMsg, wrapMsg);
+  }
+  /**
    * @param loggerPrecision - an integer representing the number of packages to display,

    * or an empty string representing 'display all packages' 
    */

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=935135&r1=935134&r2=935135&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 Apr 17 06:05:22 2010
@@ -243,6 +243,7 @@ public class LogPanelPreferencePanel ext
     private final JTextField timeZone = new JTextField(10);
     private final JRadioButton rdLevelIcons = new JRadioButton("Icons");
     private final JRadioButton rdLevelText = new JRadioButton("Text");
+    private final JCheckBox wrapMessage = new JCheckBox("Display entire message field in
the table (multi-line rows)");
     private JRadioButton rdLast;
 
     //~ Constructors ==========================================================
@@ -362,6 +363,7 @@ public class LogPanelPreferencePanel ext
       levelFormatPanel.add(rdLevelText);
 
       add(levelFormatPanel);
+      add(wrapMessage);
 
       JPanel loggerFormatPanel = new JPanel();
       loggerFormatPanel.setLayout(
@@ -501,6 +503,15 @@ public class LogPanelPreferencePanel ext
           }
         };
 
+      ActionListener wrapMessageListener = new ActionListener()
+      {
+          public void actionPerformed(ActionEvent e)
+          {
+              preferenceModel.setWrapMessage(wrapMessage.isSelected());
+          }
+      };
+
+      wrapMessage.addActionListener(wrapMessageListener);
       rdLevelIcons.addActionListener(levelIconListener);
       rdLevelText.addActionListener(levelIconListener);
 
@@ -514,6 +525,16 @@ public class LogPanelPreferencePanel ext
             rdLevelText.setSelected(!value);
           }
         });
+        
+        preferenceModel.addPropertyChangeListener(
+          "wrapMessage", new PropertyChangeListener()
+          {
+            public void propertyChange(PropertyChangeEvent evt)
+            {
+              boolean value = ((Boolean) evt.getNewValue()).booleanValue();
+              wrapMessage.setSelected(value);
+            }
+          });
     }
   }
 

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=935135&r1=935134&r2=935135&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 Apr 17 06:05:22 2010
@@ -29,8 +29,10 @@ import java.util.TimeZone;
 
 import javax.swing.BorderFactory;
 import javax.swing.Icon;
+import javax.swing.JComponent;
 import javax.swing.JLabel;
 import javax.swing.JTable;
+import javax.swing.JTextArea;
 import javax.swing.SwingConstants;
 import javax.swing.UIManager;
 import javax.swing.border.Border;
@@ -58,6 +60,7 @@ public class TableColorizingRenderer ext
   private RuleColorizer colorizer;
   private final JLabel levelComponent = new JLabel();
   private boolean levelUseIcons = false;
+  private boolean wrapMsg = false;
   private DateFormat dateFormatInUse = DATE_FORMATTER;
   private int loggerPrecision = 0;
   private boolean toolTipsVisible;
@@ -69,7 +72,11 @@ public class TableColorizingRenderer ext
   private static final Border LEFT_BORDER = BorderFactory.createMatteBorder(borderWidth,
borderWidth, borderWidth, 0, borderColor);
   private static final Border MIDDLE_BORDER = BorderFactory.createMatteBorder(borderWidth,
0, borderWidth, 0, borderColor);
   private static final Border RIGHT_BORDER = BorderFactory.createMatteBorder(borderWidth,
0, borderWidth, borderWidth, borderColor);
-  private static final Border EMPTY_BORDER = BorderFactory.createEmptyBorder(borderWidth,
borderWidth, borderWidth, borderWidth);
+
+  private static final Border LEFT_EMPTY_BORDER = BorderFactory.createEmptyBorder(borderWidth,
borderWidth, borderWidth, 0);
+  private static final Border MIDDLE_EMPTY_BORDER = BorderFactory.createEmptyBorder(borderWidth,
0, borderWidth, 0);
+  private static final Border RIGHT_EMPTY_BORDER = BorderFactory.createEmptyBorder(borderWidth,
0, borderWidth, borderWidth);
+  private JTextArea msgRenderer = new JTextArea();
 
     /**
    * Creates a new TableColorizingRenderer object.
@@ -78,9 +85,11 @@ public class TableColorizingRenderer ext
     this.colorizer = colorizer;
 
     levelComponent.setOpaque(true);
-    levelComponent.setHorizontalAlignment(SwingConstants.CENTER);
+    levelComponent.setVerticalAlignment(SwingConstants.TOP);
 
     levelComponent.setText("");
+    levelComponent.setVerticalAlignment(SwingConstants.TOP);
+    msgRenderer.setSize(1000, 2);
   }
 
   public void setToolTipsVisible(boolean toolTipsVisible) {
@@ -92,12 +101,22 @@ public class TableColorizingRenderer ext
     int row, int col) {
     value = formatField(value);
 
-    JLabel c = (JLabel)super.getTableCellRendererComponent(table, value,
+    JLabel labelRenderer = (JLabel)super.getTableCellRendererComponent(table, value,
         isSelected, hasFocus, row, col);
-
+    labelRenderer.setVerticalAlignment(SwingConstants.TOP);
+    JComponent component;
     TableColumn tableColumn = table.getColumnModel().getColumn(col);
     int colIndex = tableColumn.getModelIndex() + 1;
 
+    if(colIndex == ChainsawColumns.INDEX_MESSAGE_COL_NAME) {
+        component = msgRenderer;
+        msgRenderer.setFont(labelRenderer.getFont());
+    } else if (colIndex == ChainsawColumns.INDEX_LEVEL_COL_NAME) {
+        component = levelComponent;
+    } else {
+        component = labelRenderer;
+    }
+
     EventContainer container = (EventContainer) table.getModel();
     ExtendedLoggingEvent loggingEvent = container.getRow(row);
     //no event, use default renderer
@@ -107,12 +126,12 @@ public class TableColorizingRenderer ext
 
     switch (colIndex) {
     case ChainsawColumns.INDEX_ID_COL_NAME:
-      c.setText(value.toString());
+      labelRenderer.setText(value.toString());
       break;
 
     case ChainsawColumns.INDEX_THROWABLE_COL_NAME:
       if (value instanceof String[] && ((String[])value).length > 0){
-        c.setText(((String[]) value)[0]);
+        labelRenderer.setText(((String[]) value)[0]);
       }
       break;
 
@@ -130,20 +149,37 @@ public class TableColorizingRenderer ext
         }
       }
 
-    c.setText(logger.substring(startPos + 1));
+    labelRenderer.setText(logger.substring(startPos + 1));
       break;
     case ChainsawColumns.INDEX_LOG4J_MARKER_COL_NAME:
     case ChainsawColumns.INDEX_CLASS_COL_NAME:
     case ChainsawColumns.INDEX_FILE_COL_NAME:
     case ChainsawColumns.INDEX_LINE_COL_NAME:
-    case ChainsawColumns.INDEX_MESSAGE_COL_NAME:
     case ChainsawColumns.INDEX_NDC_COL_NAME:
     case ChainsawColumns.INDEX_THREAD_COL_NAME:
     case ChainsawColumns.INDEX_TIMESTAMP_COL_NAME:
     case ChainsawColumns.INDEX_METHOD_COL_NAME:
-      c.setText(value.toString());
+      labelRenderer.setText(value.toString());
       break;
 
+    case ChainsawColumns.INDEX_MESSAGE_COL_NAME:
+        msgRenderer.setLineWrap(wrapMsg);
+        msgRenderer.setWrapStyleWord(wrapMsg);
+
+        if (wrapMsg) {
+            int width = table.getColumnModel().getColumn(ChainsawColumns.INDEX_MESSAGE_COL_NAME).getWidth();
+            msgRenderer.setSize(width, 2);
+        }
+        msgRenderer.setText(value.toString());
+        if (wrapMsg) {
+            int preferredHeight = (int) msgRenderer.getPreferredSize().getHeight();
+            int tableRowHeight = table.getRowHeight();
+            if(preferredHeight != tableRowHeight) {
+                int rowHeight = Math.max(preferredHeight, tableRowHeight);
+                table.setRowHeight(row, rowHeight);
+            }
+        }
+    break;
     case ChainsawColumns.INDEX_LEVEL_COL_NAME:
       if (levelUseIcons) {
         levelComponent.setIcon((Icon) iconMap.get(value.toString()));
@@ -162,12 +198,10 @@ public class TableColorizingRenderer ext
         }
       }
       if (toolTipsVisible) {
-          levelComponent.setToolTipText(c.getToolTipText());
+          levelComponent.setToolTipText(labelRenderer.getToolTipText());
       }
-      levelComponent.setForeground(c.getForeground());
-      levelComponent.setBackground(c.getBackground());
-
-      c = levelComponent;
+      levelComponent.setForeground(labelRenderer.getForeground());
+      levelComponent.setBackground(labelRenderer.getBackground());
       break;
 
     //remaining entries are properties
@@ -184,7 +218,7 @@ public class TableColorizingRenderer ext
             }
         }
         if (thisProp != null) {
-            c.setText(loggingEvent.getProperty(headerName));
+            labelRenderer.setText(loggingEvent.getProperty(headerName));
         }
         break;
     }
@@ -212,21 +246,28 @@ public class TableColorizingRenderer ext
       }
     }
 
-    c.setBackground(background);
-    c.setForeground(foreground);
+    component.setBackground(background);
+    component.setForeground(foreground);
 
     if (isSelected) {
       if (col == 0) {
-        c.setBorder(LEFT_BORDER);
+        component.setBorder(LEFT_BORDER);
       } else if (col == table.getColumnCount() - 1) {
-        c.setBorder(RIGHT_BORDER);
+        component.setBorder(RIGHT_BORDER);
       } else {
-        c.setBorder(MIDDLE_BORDER);
+        component.setBorder(MIDDLE_BORDER);
       }
     } else {
-      c.setBorder(EMPTY_BORDER);
+      if (col == 0) {
+        component.setBorder(LEFT_EMPTY_BORDER);
+      } else if (col == table.getColumnCount() - 1) {
+        component.setBorder(RIGHT_EMPTY_BORDER);
+      } else {
+        component.setBorder(MIDDLE_EMPTY_BORDER);
+      }
     }
-    return c;
+
+    return component;
   }
 
   /**
@@ -275,6 +316,14 @@ public class TableColorizingRenderer ext
     return dateFormatInUse.format((Date) o);
   }
 
+    /**
+    * Sets the property which determines whether to wrap the message
+    * @param wrapMsg
+    */
+   public void setWrapMessage(boolean wrapMsg) {
+     this.wrapMsg = wrapMsg;
+   }
+
    /**
    * Sets the property which determines whether to use Icons or text
    * for the Level column

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=935135&r1=935134&r2=935135&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 Apr 17 06:05:22 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>1.99.99</h1>
+<h2>16 Apr 2010</h2>
+<ul>
+<li>Added preference to line wrap the message field in the table (multi-line rows)</li>
+</ul>
 <h2>7 Apr 2010</h2>
 <ul>
 <li>Forward and backward search, as well as forward and backward next-color search
now wrap.</li>

Modified: logging/chainsaw/trunk/src/test/java/org/apache/log4j/chainsaw/LogPanelPreferenceModelTest.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/test/java/org/apache/log4j/chainsaw/LogPanelPreferenceModelTest.java?rev=935135&r1=935134&r2=935135&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/test/java/org/apache/log4j/chainsaw/LogPanelPreferenceModelTest.java
(original)
+++ logging/chainsaw/trunk/src/test/java/org/apache/log4j/chainsaw/LogPanelPreferenceModelTest.java
Sat Apr 17 06:05:22 2010
@@ -17,6 +17,7 @@ public class LogPanelPreferenceModelTest
          */
         
         model.setLevelIcons(!model.isLevelIcons());
+        model.setWrapMessage(!model.isWrapMessage());
         model.setDateFormatPattern("yyyyDDmm");
         model.setLoggerPrecision("FATAL");
         model.setLogTreePanelVisible(!model.isLogTreePanelVisible());



Mime
View raw message