You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@logging.apache.org by sd...@apache.org on 2010/10/16 07:29:58 UTC

svn commit: r1023184 - in /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw: ChainsawCyclicBufferTableModel.java LogPanel.java ReceiverConfigurationPanel.java

Author: sdeboy
Date: Sat Oct 16 05:29:57 2010
New Revision: 1023184

URL: http://svn.apache.org/viewvc?rev=1023184&view=rev
Log:
Minor layout fixes
 - Added space around search table so it is the same width as the primary table
 - added 'MESSAGE' entry to receiver config default format drop down (a defaul that can be used no matter what the file format is)
 - Updated the left and right thumbnail drawing logic so that it stays within the bounds of the table
 - Fixed a bug where the color rules were being evaluated before the log4jid property was set (was preventing color rules that used prop.log4jid from taking effect)

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/ReceiverConfigurationPanel.java

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=1023184&r1=1023183&r2=1023184&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 Sat Oct 16 05:29:57 2010
@@ -606,14 +606,6 @@ class ChainsawCyclicBufferTableModel ext
   }
 
   public boolean isAddRow(LoggingEventWrapper loggingEventWrapper) {
-    loggingEventWrapper.updateColorRuleColors(colorizer.getBackgroundColor(loggingEventWrapper.getLoggingEvent()), colorizer.getForegroundColor(loggingEventWrapper.getLoggingEvent()));
-    Rule findRule = colorizer.getFindRule();
-    if (findRule != null) {
-      loggingEventWrapper.evaluateSearchRule(colorizer.getFindRule());
-    }
-
-    boolean rowAdded = false;
-
     Object id = loggingEventWrapper.getLoggingEvent().getProperty(Constants.LOG4J_ID_KEY);
 
     //only set the property if it doesn't already exist
@@ -622,6 +614,14 @@ class ChainsawCyclicBufferTableModel ext
       loggingEventWrapper.setProperty(Constants.LOG4J_ID_KEY, id.toString());
     }
 
+    loggingEventWrapper.updateColorRuleColors(colorizer.getBackgroundColor(loggingEventWrapper.getLoggingEvent()), colorizer.getForegroundColor(loggingEventWrapper.getLoggingEvent()));
+    Rule findRule = colorizer.getFindRule();
+    if (findRule != null) {
+      loggingEventWrapper.evaluateSearchRule(colorizer.getFindRule());
+    }
+
+    boolean rowAdded = false;
+
     /**
          * If we're in cyclic mode and over budget on the size, the addition of a new event will
          * cause the oldest event to fall off the cliff. We need to remove that events ID from the

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=1023184&r1=1023183&r2=1023184&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 Oct 16 05:29:57 2010
@@ -1216,7 +1216,12 @@ public class LogPanel extends DockablePa
 
     JPanel rightPanel = new JPanel();
     rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS));
-    JPanel rightThumbNailPanel = new ColorizedEventAndSearchMatchThumbnail();
+
+    JPanel rightThumbNailPanel = new JPanel();
+    rightThumbNailPanel.setLayout(new BoxLayout(rightThumbNailPanel, BoxLayout.Y_AXIS));
+    rightThumbNailPanel.add(Box.createVerticalStrut(scrollBarWidth.intValue()));
+    rightThumbNailPanel.add(new ColorizedEventAndSearchMatchThumbnail());
+    rightThumbNailPanel.add(Box.createVerticalStrut(scrollBarWidth.intValue()));
     rightPanel.add(rightThumbNailPanel);
     //set thumbnail width to be a bit narrower than scrollbar width
     if (scrollBarWidth != null) {
@@ -1226,8 +1231,14 @@ public class LogPanel extends DockablePa
 
     JPanel leftPanel = new JPanel();
     leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.Y_AXIS));
-    JPanel leftThumbNailPanel = new EventTimeDeltaMatchThumbnail();
+
+    JPanel leftThumbNailPanel = new JPanel();
+    leftThumbNailPanel.setLayout(new BoxLayout(leftThumbNailPanel, BoxLayout.Y_AXIS));
+    leftThumbNailPanel.add(Box.createVerticalStrut(scrollBarWidth.intValue()));
+    leftThumbNailPanel.add(new EventTimeDeltaMatchThumbnail());
+    leftThumbNailPanel.add(Box.createVerticalStrut(scrollBarWidth.intValue()));
     leftPanel.add(leftThumbNailPanel);
+
     //set thumbnail width to be a bit narrower than scrollbar width
     if (scrollBarWidth != null) {
         leftThumbNailPanel.setPreferredSize(new Dimension(scrollBarWidth.intValue() -4, -1));
@@ -2486,6 +2497,13 @@ public class LogPanel extends DockablePa
       //if pref is set, always update detail panel to contain search results
       detailPanel.removeAll();
       detailPanel.add(searchPane, BorderLayout.CENTER);
+      Integer scrollBarWidth = (Integer) UIManager.get("ScrollBar.width");
+      JPanel leftSpacePanel = new JPanel();
+      leftSpacePanel.setPreferredSize(new Dimension(scrollBarWidth.intValue() -4, -1));
+      JPanel rightSpacePanel = new JPanel();
+      rightSpacePanel.setPreferredSize(new Dimension(scrollBarWidth.intValue() -4, -1));
+      detailPanel.add(leftSpacePanel, BorderLayout.WEST);
+      detailPanel.add(rightSpacePanel, BorderLayout.EAST);
       detailPanel.invalidate();
       detailPanel.revalidate();
       detailPanel.repaint();
@@ -3701,17 +3719,13 @@ public class LogPanel extends DockablePa
         public void paintComponent(Graphics g) {
             super.paintComponent(g);
 
-            Point topAndBottomOffset = getScrollBarOffsets();
-            int topOffset = topAndBottomOffset.x;
-            int bottomOffset = topAndBottomOffset.y;
-
             int rowCount = table.getRowCount();
             if (rowCount == 0) {
                 return;
             }
             //use event pane height as reference height - max component height will be extended by event height if
             // last row is rendered, so subtract here
-            int height = eventsPane.getHeight() - topOffset - bottomOffset;
+            int height = eventsPane.getHeight();
             int maxHeight = Math.min(maxEventHeight, (height / rowCount));
             int minHeight = Math.max(1, maxHeight);
             int componentHeight = height - minHeight;
@@ -3723,7 +3737,7 @@ public class LogPanel extends DockablePa
                     if (primaryMatches(wrapper)) {
                         float ratio = (wrapper.rowNum / (float)rowCount);
         //                System.out.println("error - ratio: " + ratio + ", component height: " + componentHeight);
-                        int verticalLocation = (int) (componentHeight * ratio) + topOffset;
+                        int verticalLocation = (int) (componentHeight * ratio);
 
                         int startX = 1;
                         int width = getWidth() - (startX * 2);
@@ -3786,17 +3800,13 @@ public class LogPanel extends DockablePa
         public void paintComponent(Graphics g) {
             super.paintComponent(g);
 
-            Point topAndBottomOffset = getScrollBarOffsets();
-            int topOffset = topAndBottomOffset.x;
-            int bottomOffset = topAndBottomOffset.y;
-
             int rowCount = table.getRowCount();
             if (rowCount == 0) {
                 return;
             }
             //use event pane height as reference height - max component height will be extended by event height if
             // last row is rendered, so subtract here
-            int height = eventsPane.getHeight() - topOffset - bottomOffset;
+            int height = eventsPane.getHeight();
             int maxHeight = Math.min(maxEventHeight, (height / rowCount));
             int minHeight = Math.max(1, maxHeight);
             int componentHeight = height - minHeight;
@@ -3809,7 +3819,7 @@ public class LogPanel extends DockablePa
                     if (wrapper.loggingEventWrapper.getLoggingEvent().getLevel().toInt() < Level.WARN.toInt() && wrapper.loggingEventWrapper.getLoggingEvent().getProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE) == null) {
                         float ratio = (wrapper.rowNum / (float)rowCount);
         //                System.out.println("error - ratio: " + ratio + ", component height: " + componentHeight);
-                        int verticalLocation = (int) (componentHeight * ratio) + topOffset;
+                        int verticalLocation = (int) (componentHeight * ratio);
 
                         int startX = 1;
                         int width = getWidth() - (startX * 2);
@@ -3827,7 +3837,7 @@ public class LogPanel extends DockablePa
                     if (wrapper.loggingEventWrapper.getLoggingEvent().getLevel().toInt() >= Level.WARN.toInt() || wrapper.loggingEventWrapper.getLoggingEvent().getProperty(ChainsawConstants.LOG4J_MARKER_COL_NAME_LOWERCASE) != null) {
                         float ratio = (wrapper.rowNum / (float)rowCount);
         //                System.out.println("error - ratio: " + ratio + ", component height: " + componentHeight);
-                        int verticalLocation = (int) (componentHeight * ratio) + topOffset;
+                        int verticalLocation = (int) (componentHeight * ratio);
 
                         int startX = 1;
                         int width = getWidth() - (startX * 2);
@@ -3847,7 +3857,7 @@ public class LogPanel extends DockablePa
                 ThumbnailLoggingEventWrapper wrapper = (ThumbnailLoggingEventWrapper)iter.next();
                 float ratio = (wrapper.rowNum / (float)rowCount);
 //                System.out.println("warning - ratio: " + ratio + ", component height: " + componentHeight);
-                int verticalLocation = (int) (componentHeight * ratio) + topOffset;
+                int verticalLocation = (int) (componentHeight * ratio);
 
                 int startX = 1;
                 int width = getWidth() - (startX * 2);
@@ -4007,15 +4017,10 @@ public class LogPanel extends DockablePa
         protected ThumbnailLoggingEventWrapper getEventWrapperAtPosition(int yPosition) {
             int rowCount = table.getRowCount();
 
-            Point offsets = getScrollBarOffsets();
-            int topOffset = offsets.x;
-            int bottomOffset = offsets.y;
-
-            //'effective' height of this component is scrollpane height - top/bottom offsets
-            int height = eventsPane.getHeight() - topOffset - bottomOffset;
+            //'effective' height of this component is scrollpane height
+            int height = eventsPane.getHeight();
 
-            //remove top offset from click location but avoid going negative
-            yPosition = Math.max(yPosition - topOffset, 0);
+            yPosition = Math.max(yPosition, 0);
 
             //don't let clicklocation exceed height
             if (yPosition >= height) {
@@ -4052,29 +4057,6 @@ public class LogPanel extends DockablePa
             return closestRow;
         }
 
-        /**
-         * Return a point representing top and bottom offsets
-         * Top offset is held by Point.x, bottom offset is held by Point.y
-         *
-         * @return point representing top and bottom offsets (x and y values of Point)
-         */
-        public Point getScrollBarOffsets() {
-            Integer scrollBarWidth = (Integer) UIManager.get("ScrollBar.width");
-            int scrollBarOffset = scrollBarWidth == null ? 0 : scrollBarWidth.intValue();
-            //calculate topOffset and bottomOffset (topOffset is tableheader size + optional vertical scrollbar thumb height
-            //bottom offset is optional vertical scrollbar thumb height + optional horizontal scrollbar thumb height
-            int topOffset = table.getTableHeader().getMinimumSize().height;
-            int bottomOffset = 0;
-            if (eventsPane.getVerticalScrollBar().isVisible()) {
-                topOffset += scrollBarOffset;
-                bottomOffset += scrollBarOffset;
-            }
-            if (eventsPane.getHorizontalScrollBar().isVisible()) {
-                bottomOffset += scrollBarOffset;
-            }
-            return new Point(topOffset, bottomOffset);
-        }
-
         public Point getToolTipLocation(MouseEvent event) {
             //shift tooltip down so the the pointer doesn't cover up events below the current mouse location
             return new Point(event.getX(), event.getY() + 30);

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java?rev=1023184&r1=1023183&r2=1023184&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java Sat Oct 16 05:29:57 2010
@@ -424,6 +424,7 @@ class ReceiverConfigurationPanel extends
 
     private void seedLogFileFormatComboBoxModel()
     {
+        logFileFormatComboBoxModel.addElement("MESSAGE");
         logFileFormatComboBoxModel.addElement("%p %t %c - %m%n");
         logFileFormatComboBoxModel.addElement("LEVEL THREAD LOGGER - MESSAGE");
         logFileFormatComboBoxModel.addElement("%d{ABSOLUTE} %-5p [%c{1}] %m%n");