logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r940375 - in /logging/chainsaw/trunk/src/main: java/org/apache/log4j/chainsaw/ resources/org/apache/log4j/chainsaw/help/
Date Mon, 03 May 2010 06:05:42 GMT
Author: sdeboy
Date: Mon May  3 06:05:42 2010
New Revision: 940375

URL: http://svn.apache.org/viewvc?rev=940375&view=rev
Log:
Marker field now wraps if multi-line is enabled
Fixed a number of visual glitches
 - variable-height rows will cause Swing to throw a number of exceptions if fireTableRowsDeleted
is called (calling fireTableDataChanged in that case instead)
 - updated scrollToBottom logic to work better if variable height rows are enabled
 - don't reuse the textarea in the renderer (prevents the textarea from causing other rows
to have the incorrect height)

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.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

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=940375&r1=940374&r2=940375&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
Mon May  3 06:05:42 2010
@@ -145,7 +145,8 @@ class ChainsawCyclicBufferTableModel ext
 	      			} else if (previousSize > filteredList.size()) {
 	      				//less now..update and delete difference
 	      				fireTableRowsUpdated(0, filteredList.size() - 1);
-	      				fireTableRowsDeleted(filteredList.size(), previousSize);
+                        //swing bug exposed by variable height rows when calling fireTableRowsDeleted..use
tabledatacchanged
+                        fireTableDataChanged();
 	      			} else if (previousSize < filteredList.size()) {
 	      				//more now..update and insert difference
                         if (previousSize > 0) {

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=940375&r1=940374&r2=940375&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 Mon May 
3 06:05:42 2010
@@ -22,6 +22,7 @@ import java.awt.Color;
 import java.awt.Component;
 import java.awt.Container;
 import java.awt.Dimension;
+import java.awt.EventQueue;
 import java.awt.FlowLayout;
 import java.awt.Font;
 import java.awt.FontMetrics;
@@ -1547,7 +1548,14 @@ public class LogPanel extends DockablePa
   }
   
   private void scrollToBottom() {
-    table.scrollToRow(tableModel.getRowCount() - 1);
+    final int scrollRow = tableModel.getRowCount() - 1;
+    EventQueue.invokeLater(new Runnable()
+    {
+        public void run()
+        {
+            table.scrollToRow(scrollRow);
+        }
+    });
   }
 
   public void scrollToTop()
@@ -1636,9 +1644,7 @@ public class LogPanel extends DockablePa
           detailPaneUpdater.setSelectedRow(table.getSelectedRow());
         }
 
-        if (isScrollToBottom()) {
-          scrollToBottom();
-        } else if (selectedEvent != null) {
+        if (!isScrollToBottom() && selectedEvent != null) {
           final int newIndex = tableModel.getRowIndex(selectedEvent);
           if (newIndex >= 0) {
             // Don't scroll, just maintain selection...
@@ -3164,6 +3170,9 @@ public class LogPanel extends DockablePa
                     }
                     invalidate();
                     repaint();
+                    if (isScrollToBottom()) {
+                        scrollToBottom();
+                    }
                 }
             });
         }

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=940375&r1=940374&r2=940375&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
Mon May  3 06:05:42 2010
@@ -243,7 +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 final JCheckBox wrapMessage = new JCheckBox("Display entire message and marker
text in the table (multi-line rows)");
     private JRadioButton rdLast;
 
     //~ Constructors ==========================================================

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=940375&r1=940374&r2=940375&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
Mon May  3 06:05:42 2010
@@ -69,7 +69,7 @@ public class TableColorizingRenderer ext
   private static final Map iconMap = LevelIconFactory.getInstance().getLevelToIconMap();
   private RuleColorizer colorizer;
   private boolean levelUseIcons = false;
-  private boolean wrapMsg = false;
+  private boolean wrap = false;
   private DateFormat dateFormatInUse = DATE_FORMATTER;
   private int loggerPrecision = 0;
   private boolean toolTipsVisible;
@@ -88,22 +88,21 @@ public class TableColorizingRenderer ext
   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 final JTextArea msgTextArea = new JTextArea();
   private final JLabel levelLabel = new JLabel();
   private final JLabel generalLabel = new JLabel();
 
-  private final JPanel msgPanel = new JPanel();
+  private final JPanel multiLinePanel = new JPanel();
   private final JPanel generalPanel = new JPanel();
   private final JPanel levelPanel = new JPanel();
     /**
    * Creates a new TableColorizingRenderer object.
    */
   public TableColorizingRenderer(RuleColorizer colorizer) {
-    msgPanel.setLayout(new BoxLayout(msgPanel, BoxLayout.Y_AXIS));
+    multiLinePanel.setLayout(new BoxLayout(multiLinePanel, BoxLayout.Y_AXIS));
     generalPanel.setLayout(new BoxLayout(generalPanel, BoxLayout.Y_AXIS));
     levelPanel.setLayout(new BoxLayout(levelPanel, BoxLayout.Y_AXIS));
 
-    msgPanel.setAlignmentX(TOP_ALIGNMENT);
+    multiLinePanel.setAlignmentX(TOP_ALIGNMENT);
     generalPanel.setAlignmentX(TOP_ALIGNMENT);
     levelPanel.setAlignmentX(TOP_ALIGNMENT);
 
@@ -112,10 +111,6 @@ public class TableColorizingRenderer ext
     levelLabel.setOpaque(true);
     levelLabel.setText("");
 
-    msgTextArea.setMargin(null);
-    msgTextArea.setEditable(false);
-
-    msgPanel.add(msgTextArea);
     generalPanel.add(generalLabel);
     levelPanel.add(levelLabel);
 
@@ -130,10 +125,12 @@ public class TableColorizingRenderer ext
     final JTable table, Object value, boolean isSelected, boolean hasFocus,
     int row, int col) {
     value = formatField(value);
+    TableColumn tableColumn = table.getColumnModel().getColumn(col);
 
+    //null unless needed
+    JTextArea multiLineTextArea = null;
     JLabel label = (JLabel)super.getTableCellRendererComponent(table, value,
         isSelected, hasFocus, row, col);
-    TableColumn tableColumn = table.getColumnModel().getColumn(col);
     //chainsawcolumns uses one-based indexing
     int colIndex = tableColumn.getModelIndex() + 1;
 
@@ -168,7 +165,6 @@ public class TableColorizingRenderer ext
       component = generalPanel;
       break;
     case ChainsawColumns.INDEX_ID_COL_NAME:
-    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:
@@ -180,25 +176,35 @@ public class TableColorizingRenderer ext
       component = generalPanel;
       break;
 
+    case ChainsawColumns.INDEX_LOG4J_MARKER_COL_NAME:
     case ChainsawColumns.INDEX_MESSAGE_COL_NAME:
-        String string = value.toString().trim();
         int width = tableColumn.getWidth();
-        msgTextArea.setLineWrap(wrapMsg);
-        msgTextArea.setWrapStyleWord(wrapMsg);
-        msgTextArea.setFont(label.getFont());
-        msgTextArea.setText(string);
+
+        String thisString = value.toString().trim();
         int tableRowHeight = table.getRowHeight(row);
-        if (wrapMsg) {
+        multiLineTextArea = new JTextArea();
+        multiLineTextArea.setMargin(null);
+        multiLineTextArea.setEditable(false);
+        multiLineTextArea.setLineWrap(wrap);
+        multiLineTextArea.setWrapStyleWord(wrap);
+        multiLineTextArea.setFont(label.getFont());
+        multiLineTextArea.setText(thisString);
+        multiLinePanel.removeAll();
+        multiLinePanel.add(multiLineTextArea);
+        if (wrap) {
             Map paramMap = new HashMap();
-            paramMap.put(TextAttribute.FONT, msgTextArea.getFont());
-            int calculatedHeight = calculateHeight(string, width, paramMap);
-            msgTextArea.setSize(new Dimension(width, calculatedHeight));
-            int msgPanelPrefHeight = msgPanel.getPreferredSize().height;
-            if(tableRowHeight < msgPanelPrefHeight/* && calculatedHeight >
tableRowHeight*/) {
-                table.setRowHeight(row, Math.max(ChainsawConstants.DEFAULT_ROW_HEIGHT, msgPanelPrefHeight));
+            paramMap.put(TextAttribute.FONT, multiLineTextArea.getFont());
+
+            int calculatedHeight = calculateHeight(thisString, width, paramMap);
+            //set preferred size to default height
+            multiLineTextArea.setSize(new Dimension(width, calculatedHeight));
+
+            int multiLinePanelPrefHeight = multiLinePanel.getPreferredSize().height;
+            if(tableRowHeight < multiLinePanelPrefHeight) {
+                table.setRowHeight(row, Math.max(ChainsawConstants.DEFAULT_ROW_HEIGHT, multiLinePanelPrefHeight));
             }
         }
-        component = msgPanel;
+        component = multiLinePanel;
         break;
     case ChainsawColumns.INDEX_LEVEL_COL_NAME:
       if (levelUseIcons) {
@@ -274,8 +280,11 @@ public class TableColorizingRenderer ext
     component.setForeground(foreground);
 
     //set the colors of the components inside 'component'
-    msgTextArea.setBackground(background);
-    msgTextArea.setForeground(foreground);
+    if (multiLineTextArea != null)
+    {
+        multiLineTextArea.setBackground(background);
+        multiLineTextArea.setForeground(foreground);
+    }
     levelLabel.setBackground(background);
     levelLabel.setForeground(foreground);
     generalLabel.setBackground(background);
@@ -352,7 +361,7 @@ public class TableColorizingRenderer ext
     * @param wrapMsg
     */
    public void setWrapMessage(boolean wrapMsg) {
-     this.wrapMsg = wrapMsg;
+     this.wrap = wrapMsg;
    }
 
    /**

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=940375&r1=940374&r2=940375&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
Mon May  3 06:05:42 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>2 May 2010</h2>
+<ul>
+<li>Added preference to line wrap the marker field in the table (multi-line rows)</li>
+</ul>
 <h2>16 Apr 2010</h2>
 <ul>
 <li>Added preference to line wrap the message field in the table (multi-line rows)</li>



Mime
View raw message