logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r934693 - in /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw: ChainsawAppenderHandler.java ChainsawStatusBar.java LogPanel.java LoggerNameTreePanel.java TableColorizingRenderer.java
Date Fri, 16 Apr 2010 05:32:35 GMT
Author: sdeboy
Date: Fri Apr 16 05:32:34 2010
New Revision: 934693

URL: http://svn.apache.org/viewvc?rev=934693&view=rev
Log:
Chainsaw UI updates (feedback appreciated)
 - instead of the default row selection rendering of changing the row's background color,
the selected row color is preserved but a border around the selected row is displayed
 - removed table row and column margin (border around cells in the selected row had gaps without
making this change)
 - updated widths of fields in status bar
 - performance tweak: tree node selection no longer triggers unnecessary calculations (only
currently displayed rows are recalculated for highlighting)
 - removed bevel border around ID field
 
Fixed xml decoders - an empty throwable node was resulting in a loggingEvent with a non-null
(but blank) throwableInformation ('exception exists' expression in Chainsaw would match all
events)

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawAppenderHandler.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawStatusBar.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawAppenderHandler.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawAppenderHandler.java?rev=934693&r1=934692&r2=934693&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawAppenderHandler.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawAppenderHandler.java
Fri Apr 16 05:32:34 2010
@@ -122,7 +122,7 @@ public class ChainsawAppenderHandler ext
    * Determines an appropriate title for the Tab for the Tab Pane by locating a
    * the hostname property
    * 
-   * @param event
+   * @param e
    * @return identifier
    */
   String getTabIdentifier(LoggingEvent e) {

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawStatusBar.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawStatusBar.java?rev=934693&r1=934692&r2=934693&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawStatusBar.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawStatusBar.java
Fri Apr 16 05:32:34 2010
@@ -52,7 +52,7 @@ public class ChainsawStatusBar extends J
   private final JLabel pausedLabel = new JLabel("", SwingConstants.CENTER);
   private final JLabel lineSelectionLabel = new JLabel("", SwingConstants.CENTER);
   private final JLabel eventCountLabel = new JLabel("", SwingConstants.CENTER);
-  private final JLabel receivedEventLabel = new JLabel("0.0", SwingConstants.CENTER);
+  private final JLabel receivedEventLabel = new JLabel("", SwingConstants.CENTER);
   private final JLabel receivedConnectionlabel = new JLabel("", SwingConstants.CENTER);
   private volatile long lastReceivedConnection = System.currentTimeMillis();
   private final Thread connectionThread;
@@ -66,8 +66,8 @@ public class ChainsawStatusBar extends J
   public ChainsawStatusBar() {
     setLayout(new GridBagLayout());
 
-    nf.setMaximumFractionDigits(1);
-    nf.setMinimumFractionDigits(1);
+    nf.setMaximumFractionDigits(0);
+    nf.setMinimumFractionDigits(0);
     nf.setGroupingUsed(false);
 
     JPanel statusMsgPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 2));
@@ -88,7 +88,7 @@ public class ChainsawStatusBar extends J
     receivedEventLabel.setMinimumSize(
       new Dimension(
         receivedEventLabel.getFontMetrics(receivedEventLabel.getFont())
-                          .stringWidth("9999.9/s") + 5,
+                          .stringWidth("99999999999.9/s") + 5,
         (int) receivedEventLabel.getPreferredSize().getHeight()));
 
 	eventCountLabel.setBorder(statusBarComponentBorder);

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=934693&r1=934692&r2=934693&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 Fri Apr 16
05:32:34 2010
@@ -639,7 +639,7 @@ public class LogPanel extends DockablePa
      *
      */
     LogPanelLoggerTreeModel logTreeModel = new LogPanelLoggerTreeModel();
-    logTreePanel = new LoggerNameTreePanel(logTreeModel, preferenceModel);
+    logTreePanel = new LoggerNameTreePanel(logTreeModel, preferenceModel, this);
     logTreePanel.addPropertyChangeListener("searchExpression", new PropertyChangeListener()
     {
         public void propertyChange(PropertyChangeEvent evt)
@@ -692,6 +692,8 @@ public class LogPanel extends DockablePa
      * Table definition.  Actual construction is above (next to tablemodel)
      */
     table.setRowHeight(20);
+    table.setRowMargin(0);
+    table.getColumnModel().setColumnMargin(0);
     table.setShowGrid(false);
 
     table.getColumnModel().addColumnModelListener(

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java?rev=934693&r1=934692&r2=934693&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
Fri Apr 16 05:32:34 2010
@@ -139,6 +139,7 @@ final class LoggerNameTreePanel extends 
   private Rule colorRuleDelegate; 
   private final JScrollPane scrollTree;
   private final JToolBar toolbar = new JToolBar();
+  private final LogPanel logPanel;
 
     //~ Constructors ============================================================
 
@@ -147,11 +148,12 @@ final class LoggerNameTreePanel extends 
    *
    * @param logTreeModel
    */
-  LoggerNameTreePanel(LogPanelLoggerTreeModel logTreeModel, LogPanelPreferenceModel preferenceModel)
+  LoggerNameTreePanel(LogPanelLoggerTreeModel logTreeModel, LogPanelPreferenceModel preferenceModel,
LogPanel logPanel)
   {
     super();
     this.logTreeModel = logTreeModel;
     this.preferenceModel = preferenceModel;
+    this.logPanel = logPanel;
 
     setLayout(new BorderLayout());
 
@@ -1037,7 +1039,7 @@ final class LoggerNameTreePanel extends 
           {
             node = (TreeNode) path.getLastPathComponent();
           }
-
+          boolean focusOnSelected = isFocusOnSelected();
           //          editLoggerAction.setEnabled(path != null);
           String logger = getCurrentlySelectedLoggerName();
           focusOnAction.setEnabled(
@@ -1069,6 +1071,15 @@ final class LoggerNameTreePanel extends 
           collapseAction.setEnabled(path != null);
 
           reconfigureMenuText();
+          if (isFocusOnSelected()) {
+              fireChangeEvent();
+          }
+          //fire change event if we toggled focus off
+          if (focusOnSelected && !isFocusOnSelected()) {
+              fireChangeEvent();
+          }
+          //trigger a table repaint
+          logPanel.repaint();
         }
       });
 
@@ -1091,8 +1102,6 @@ final class LoggerNameTreePanel extends 
             logTreeModel.nodeChanged(
               (TreeNode) logTree.getSelectionPath().getLastPathComponent());
           }
-
-          fireChangeEvent();
         }
       });
 
@@ -1105,8 +1114,6 @@ final class LoggerNameTreePanel extends 
             logTreeModel.nodeChanged(
               (TreeNode) logTree.getSelectionPath().getLastPathComponent());
           }
-
-          fireChangeEvent();
         }
       });
 
@@ -1182,6 +1189,7 @@ final class LoggerNameTreePanel extends 
   {
     setFocusOnSelected(!isFocusOnSelected());
     hideAction.setEnabled(!isFocusOnSelected());
+    fireChangeEvent();
   }
 
     public Collection getHiddenSet() {
@@ -1420,6 +1428,7 @@ final class LoggerNameTreePanel extends 
       if (logger != null)
       {
         toggleHiddenLogger(logger);
+        fireChangeEvent();
       }
     }
   }

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=934693&r1=934692&r2=934693&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
Fri Apr 16 05:32:34 2010
@@ -5,9 +5,9 @@
  * 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.
@@ -32,6 +32,8 @@ import javax.swing.Icon;
 import javax.swing.JLabel;
 import javax.swing.JTable;
 import javax.swing.SwingConstants;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.TableColumn;
 
@@ -54,7 +56,6 @@ public class TableColorizingRenderer ext
   private static final DateFormat DATE_FORMATTER = new SimpleDateFormat(Constants.SIMPLE_TIME_PATTERN);
   private static final Map iconMap = LevelIconFactory.getInstance().getLevelToIconMap();
   private RuleColorizer colorizer;
-  private final JLabel idComponent = new JLabel();
   private final JLabel levelComponent = new JLabel();
   private boolean levelUseIcons = false;
   private DateFormat dateFormatInUse = DATE_FORMATTER;
@@ -63,23 +64,25 @@ public class TableColorizingRenderer ext
   private String dateFormatTZ;
   private boolean useRelativeTimes = false;
   private long relativeTimestampBase;
+  private static int borderWidth = 2;
+  private static Color borderColor = (Color)UIManager.get("Table.selectionBackground");
+  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);
 
     /**
    * Creates a new TableColorizingRenderer object.
    */
   public TableColorizingRenderer(RuleColorizer colorizer) {
     this.colorizer = colorizer;
-    idComponent.setBorder(BorderFactory.createRaisedBevelBorder());
-    idComponent.setBackground(Color.gray);
-    idComponent.setHorizontalAlignment(SwingConstants.CENTER);
-    idComponent.setOpaque(true);
 
     levelComponent.setOpaque(true);
     levelComponent.setHorizontalAlignment(SwingConstants.CENTER);
 
     levelComponent.setText("");
   }
-  
+
   public void setToolTipsVisible(boolean toolTipsVisible) {
       this.toolTipsVisible = toolTipsVisible;
   }
@@ -89,25 +92,22 @@ public class TableColorizingRenderer ext
     int row, int col) {
     value = formatField(value);
 
-    JLabel c = (JLabel)super.getTableCellRendererComponent(table, value, 
+    JLabel c = (JLabel)super.getTableCellRendererComponent(table, value,
         isSelected, hasFocus, row, col);
 
     TableColumn tableColumn = table.getColumnModel().getColumn(col);
     int colIndex = tableColumn.getModelIndex() + 1;
 
     EventContainer container = (EventContainer) table.getModel();
-    ExtendedLoggingEvent event = container.getRow(row);
+    ExtendedLoggingEvent loggingEvent = container.getRow(row);
     //no event, use default renderer
-    if (event == null) {
+    if (loggingEvent == null) {
         return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row,
col);
     }
 
     switch (colIndex) {
     case ChainsawColumns.INDEX_ID_COL_NAME:
-      idComponent.setText(value.toString());
-      idComponent.setForeground(c.getForeground());
-      idComponent.setBackground(c.getBackground());
-      c = idComponent;
+      c.setText(value.toString());
       break;
 
     case ChainsawColumns.INDEX_THROWABLE_COL_NAME:
@@ -172,7 +172,7 @@ public class TableColorizingRenderer ext
 
     //remaining entries are properties
     default:
-        Set propertySet = event.getPropertyKeySet();
+        Set propertySet = loggingEvent.getPropertyKeySet();
         String headerName = tableColumn.getHeaderValue().toString().toLowerCase();
         String thisProp = null;
         //find the property in the property set...case-sensitive
@@ -184,24 +184,21 @@ public class TableColorizingRenderer ext
             }
         }
         if (thisProp != null) {
-            c.setText(event.getProperty(headerName));
+            c.setText(loggingEvent.getProperty(headerName));
         }
         break;
     }
-    if (isSelected) {
-      return c;
-    }
 
     Color background;
     Color foreground;
     Rule loggerRule = colorizer.getLoggerRule();
     //use logger colors in table instead of event colors if event passes logger rule
-    if (loggerRule != null && loggerRule.evaluate(event)) {
+    if (loggerRule != null && loggerRule.evaluate(loggingEvent)) {
         background = ChainsawConstants.FIND_LOGGER_BACKGROUND;
         foreground = ChainsawConstants.FIND_LOGGER_FOREGROUND;
     } else {
-        background = event.getBackground();
-        foreground = event.getForeground();
+        background = loggingEvent.getBackground();
+        foreground = loggingEvent.getForeground();
     }
 
     /**
@@ -218,6 +215,17 @@ public class TableColorizingRenderer ext
     c.setBackground(background);
     c.setForeground(foreground);
 
+    if (isSelected) {
+      if (col == 0) {
+        c.setBorder(LEFT_BORDER);
+      } else if (col == table.getColumnCount() - 1) {
+        c.setBorder(RIGHT_BORDER);
+      } else {
+        c.setBorder(MIDDLE_BORDER);
+      }
+    } else {
+      c.setBorder(EMPTY_BORDER);
+    }
     return c;
   }
 



Mime
View raw message