logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r954366 - in /logging/chainsaw/trunk/src/main: java/org/apache/log4j/chainsaw/ resources/org/apache/log4j/chainsaw/help/
Date Mon, 14 Jun 2010 05:22:50 GMT
Author: sdeboy
Date: Mon Jun 14 05:22:50 2010
New Revision: 954366

URL: http://svn.apache.org/viewvc?rev=954366&view=rev
Log:
New feature:
When mouse is moved into the thumbnail bar, event details for the closest event is displayed
as a tooltip (enabled by default, configurable via Tab Preferences dialog, Visuals section).

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/resources/org/apache/log4j/chainsaw/help/release-notes.html

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=954366&r1=954365&r2=954366&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 Jun 14
05:22:50 2010
@@ -1321,8 +1321,6 @@ public class LogPanel extends DockablePa
      * Logger tree splitpane definition
      */
     nameTreeAndMainPanelSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, logTreePanel,
lowerPanel);
-    
-    nameTreeAndMainPanelSplit.setToolTipText("Still under development....");
     nameTreeAndMainPanelSplit.setDividerLocation(-1);
 
     add(nameTreeAndMainPanelSplit, BorderLayout.CENTER);
@@ -2699,6 +2697,12 @@ public class LogPanel extends DockablePa
     return longestWidth + 5;
   }
 
+  private String getToolTipTextForEvent(ExtendedLoggingEvent event) {
+    StringBuffer buf = new StringBuffer();
+    buf.append(detailLayout.getHeader()).append(detailLayout.format(event)).append(detailLayout.getFooter());
+    return buf.toString();
+  }
+
   /**
    * ensures the Entry map of all the unque logger names etc, that is used for
    * the Filter panel is updated with any new information from the event
@@ -2936,11 +2940,8 @@ public class LogPanel extends DockablePa
         ExtendedLoggingEvent event = tableModel.getRow(currentRow);
 
         if (event != null) {
-          StringBuffer buf = new StringBuffer();
-          buf.append(detailLayout.getHeader())
-             .append(detailLayout.format(event)).append(
-            detailLayout.getFooter());
-          table.setToolTipText(buf.toString());
+          String toolTipText = getToolTipTextForEvent(event);
+          table.setToolTipText(toolTipText);
         }
       } else {
         table.setToolTipText(null);
@@ -3191,33 +3192,24 @@ public class LogPanel extends DockablePa
                     configureColors();
                 }
             });
+            
+            addMouseMotionListener(new MouseAdapter() {
+              public void mouseMoved(MouseEvent e) {
+                if (preferenceModel.isThumbnailBarToolTips()) {
+                    int yPosition = e.getPoint().y;
+                    EventWrapper event = getEventWrapperAtPosition(yPosition);
+                    setToolTipText(getToolTipTextForEvent(event.loggingEvent));
+                } else {
+                    setToolTipText(null);
+                }
+              }
+            });
+
             addMouseListener(new MouseAdapter(){
                 public void mouseClicked(MouseEvent e)
                 {
-                    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;
-
-                    int clickLocation = e.getPoint().y;
-
-                    //remove top offset from click location but avoid going negative
-                    clickLocation = Math.max(clickLocation - topOffset, 0);
-
-                    //don't let clicklocation exceed height
-                    if (clickLocation >= height) {
-                        clickLocation = height;
-                    }
-
-//                    System.out.println("clicked y pos: " + e.getPoint().y + ", relative:
" + clickLocation);
-                    float ratio = (float)clickLocation / height;
-                    int rowToSelect = Math.round(rowCount * ratio);
-//                    System.out.println("rowCount: " + rowCount + ", height: " + height
+ ", clickLocation: " + clickLocation + ", ratio: " + ratio + ", rowToSelect: " + rowToSelect);
-                    EventWrapper event = getClosestRow(rowToSelect);
+                    int yPosition = e.getPoint().y;
+                    EventWrapper event = getEventWrapperAtPosition(yPosition);
 //                    System.out.println("rowToSelect: " + rowToSelect + ", closestRow: "
+ event.loggingEvent.getProperty("log4jid"));
                     if (event != null) {
                         int id = new Integer(event.loggingEvent.getProperty("log4jid")).intValue();
@@ -3322,6 +3314,33 @@ public class LogPanel extends DockablePa
             });
         }
 
+        private EventWrapper 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;
+
+            //remove top offset from click location but avoid going negative
+            yPosition = Math.max(yPosition - topOffset, 0);
+
+            //don't let clicklocation exceed height
+            if (yPosition >= height) {
+                yPosition = height;
+            }
+
+//                    System.out.println("clicked y pos: " + e.getPoint().y + ", relative:
" + clickLocation);
+            float ratio = (float) yPosition / height;
+            int rowToSelect = Math.round(rowCount * ratio);
+//                    System.out.println("rowCount: " + rowCount + ", height: " + height
+ ", clickLocation: " + clickLocation + ", ratio: " + ratio + ", rowToSelect: " + rowToSelect);
+            EventWrapper event = getClosestRow(rowToSelect);
+            return event;
+        }
+
         private EventWrapper getClosestRow(int rowToSelect) {
             EventWrapper closestRow = null;
             int rowDelta = Integer.MAX_VALUE;

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=954366&r1=954365&r2=954366&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
Mon Jun 14 05:22:50 2010
@@ -74,6 +74,8 @@ public class LogPanelPreferenceModel imp
   private List visibleColumnOrder = new ArrayList();
   private boolean detailPaneVisible;
   private boolean toolTips;
+  //default thumbnail bar tooltips to true
+  private boolean thumbnailBarToolTips = true;
   private boolean scrollToBottom;
   private boolean logTreePanelVisible;
   private String loggerPrecision = "";
@@ -224,6 +226,7 @@ public class LogPanelPreferenceModel imp
     setHighlightSearchMatchText(model.isHighlightSearchMatchText());
     setTimeZone(model.getTimeZone());
     setToolTips(model.isToolTips());
+    setThumbnailBarToolTips((model.isThumbnailBarToolTips()));
     setScrollToBottom(model.isScrollToBottom());
     setDetailPaneVisible(model.isDetailPaneVisible());
     setLogTreePanelVisible(model.isLogTreePanelVisible());
@@ -379,6 +382,16 @@ public class LogPanelPreferenceModel imp
       "scrollToBottom", oldValue, this.scrollToBottom);
   }
 
+  public final void setThumbnailBarToolTips(boolean thumbnailBarToolTips) {
+      boolean oldValue = this.thumbnailBarToolTips;
+      this.thumbnailBarToolTips = thumbnailBarToolTips;
+      propertySupport.firePropertyChange("thumbnailBarToolTips", oldValue, this.thumbnailBarToolTips);
+  }
+
+  public final boolean isThumbnailBarToolTips() {
+      return thumbnailBarToolTips;
+  }
+
   /**
    * @return tool tips enabled flag
    */

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=954366&r1=954365&r2=954366&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 Jun 14 05:22:50 2010
@@ -584,6 +584,8 @@ public class LogPanelPreferencePanel ext
       new JCheckBox("Scroll to bottom (view tracks with new events)");
     private final JCheckBox toolTips =
       new JCheckBox("Show Event Detail Tooltips");
+    private final JCheckBox thumbnailBarToolTips =
+      new JCheckBox("Show Thumbnail Bar Tooltips");
 
     //~ Constructors ==========================================================
 
@@ -607,11 +609,13 @@ public class LogPanelPreferencePanel ext
       setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
 
       add(toolTips);
+      add(thumbnailBarToolTips);
       add(detailPanelVisible);
       add(loggerTreePanel);
       add(scrollToBottom);
 
       toolTips.setSelected(preferenceModel.isToolTips());
+      thumbnailBarToolTips.setSelected(preferenceModel.isThumbnailBarToolTips());
       detailPanelVisible.setSelected(preferenceModel.isDetailPaneVisible());
       loggerTreePanel.setSelected(preferenceModel.isLogTreePanelVisible());
     }
@@ -628,6 +632,13 @@ public class LogPanelPreferencePanel ext
             preferenceModel.setToolTips(toolTips.isSelected());
           }
         });
+
+      thumbnailBarToolTips.addActionListener(new ActionListener() {
+          public void actionPerformed(ActionEvent e) {
+              preferenceModel.setThumbnailBarToolTips(thumbnailBarToolTips.isSelected());
+          }
+      });
+
       preferenceModel.addPropertyChangeListener(
         "toolTips", new PropertyChangeListener()
         {
@@ -638,6 +649,16 @@ public class LogPanelPreferencePanel ext
           }
         });
 
+    preferenceModel.addPropertyChangeListener(
+      "thumbnailBarToolTips", new PropertyChangeListener()
+      {
+        public void propertyChange(PropertyChangeEvent evt)
+        {
+          boolean value = ((Boolean) evt.getNewValue()).booleanValue();
+          thumbnailBarToolTips.setSelected(value);
+        }
+      });
+
       detailPanelVisible.addActionListener(new ActionListener()
         {
           public void actionPerformed(ActionEvent e)

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=954366&r1=954365&r2=954366&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 Jun 14 05:22:50 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>13 Jun 2010</h2>
+<ul>
+<li>When mouse is moved into the thumbnail bar, event details for the closest event
is displayed as a tooltip (enabled by default, configurable via Tab Preferences dialog, Visuals
section).</li>
+</ul>
 <h2>11 Jun 2010</h2>
 <ul>
 <li>Updated Chainsaw Maven version to 2.1.</li>



Mime
View raw message