logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r930795 - in /logging/chainsaw/trunk/src/main: java/org/apache/log4j/chainsaw/ java/org/apache/log4j/chainsaw/layout/ resources/org/apache/log4j/chainsaw/zeroconf/
Date Mon, 05 Apr 2010 05:17:31 GMT
Author: sdeboy
Date: Mon Apr  5 05:17:31 2010
New Revision: 930795

URL: http://svn.apache.org/viewvc?rev=930795&view=rev
Log:
Refactor code setting default font & font size for html jeditorpanes (only when content
in jeditorpane is html)
Turn off scroll-to-bottom when goto-line or when clicking in the thumbnail bar

Added:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JEditorPaneFormatter.java
Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawAbout.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/WelcomePanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/layout/LayoutEditorPane.java
    logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.html

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawAbout.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawAbout.java?rev=930795&r1=930794&r2=930795&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawAbout.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawAbout.java Mon
Apr  5 05:17:31 2010
@@ -86,10 +86,7 @@ class ChainsawAbout extends JDialog {
         }
         getContentPane().add(scrollPane, BorderLayout.CENTER);
         getContentPane().add(closeButton, BorderLayout.SOUTH);
-
-        Font font = UIManager.getFont("Label.font");
-        String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: " + (font.getSize()
+ 1) + "pt; }";
-        ((HTMLDocument)editPane.getDocument()).getStyleSheet().addRule(bodyRule);
+        JEditorPaneFormatter.applySystemFontAndSize(editPane);
 
         editPane.setEditable(false);
         editPane.addHyperlinkListener(

Added: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JEditorPaneFormatter.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JEditorPaneFormatter.java?rev=930795&view=auto
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JEditorPaneFormatter.java
(added)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/JEditorPaneFormatter.java
Mon Apr  5 05:17:31 2010
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.log4j.chainsaw;
+
+import java.awt.Font;
+
+import javax.swing.JEditorPane;
+import javax.swing.UIManager;
+import javax.swing.text.Document;
+import javax.swing.text.html.HTMLDocument;
+
+/**
+ * Apply system font and size (normal size + 1) rule if the JEditorPane document contains
html.
+ */
+public class JEditorPaneFormatter {
+    public static void applySystemFontAndSize(JEditorPane editorPane) {
+        Document document = editorPane.getDocument();
+        if (document instanceof HTMLDocument) {
+          Font font = UIManager.getFont("Label.font");
+          String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: " +
(font.getSize() + 1) + "pt; }";
+          ((HTMLDocument)document).getStyleSheet().addRule(bodyRule);
+        }
+    }
+}

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=930795&r1=930794&r2=930795&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 Apr 
5 05:17:31 2010
@@ -124,9 +124,7 @@ import javax.swing.table.TableCellEditor
 import javax.swing.table.TableColumn;
 import javax.swing.table.TableColumnModel;
 import javax.swing.text.Document;
-import javax.swing.text.html.HTMLDocument;
 
-import org.apache.log4j.Level;
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PatternLayout;
@@ -1954,7 +1952,7 @@ public class LogPanel extends DockablePa
   }
 
   /**
-   * Change the selected event on the log panel
+   * Change the selected event on the log panel.  Will cause scrollToBottom to be turned
off.
    *
    * @param eventNumber
    * @return row number or -1 if row with log4jid property with that number was not found
@@ -1962,6 +1960,8 @@ public class LogPanel extends DockablePa
   int setSelectedEvent(int eventNumber) {
       int row = tableModel.find(ExpressionRule.getRule("prop.log4jid == " + eventNumber),
0, true);
       if (row > -1) {
+        preferenceModel.setScrollToBottom(false);
+
         table.scrollTo(row, 0);
       }
       return row;
@@ -2956,9 +2956,7 @@ public class LogPanel extends DockablePa
 				      	SwingHelper.invokeOnEDT(new Runnable() {
 				      		public void run() {
 				      			detail.setDocument(doc);
-                                Font font = UIManager.getFont("Label.font");
-                                String bodyRule = "body { font-family: " + font.getFamily()
+ "; font-size: " + (font.getSize() + 1) + "pt; }";
-                                ((HTMLDocument)detail.getDocument()).getStyleSheet().addRule(bodyRule);
+                                JEditorPaneFormatter.applySystemFontAndSize(detail);
 				      			detail.setCaretPosition(0);
                                 lastRow = selectedRow;
 				      		}
@@ -2975,9 +2973,7 @@ public class LogPanel extends DockablePa
 		      	SwingHelper.invokeOnEDT(new Runnable() {
 		      		public void run() {
 		      			detail.setDocument(doc);
-                        Font font = UIManager.getFont("Label.font");
-                        String bodyRule = "body { font-family: " + font.getFamily() + ";
font-size: " + (font.getSize() + 1) + "pt; }";
-                        ((HTMLDocument)detail.getDocument()).getStyleSheet().addRule(bodyRule);
+                        JEditorPaneFormatter.applySystemFontAndSize(detail);
 		      			detail.setCaretPosition(0);
                         lastRow = selectedRow;
 		      		}

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java?rev=930795&r1=930794&r2=930795&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java Mon Apr  5 05:17:31
2010
@@ -23,7 +23,6 @@ import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.Event;
 import java.awt.EventQueue;
-import java.awt.Font;
 import java.awt.Frame;
 import java.awt.Point;
 import java.awt.Toolkit;
@@ -86,7 +85,6 @@ import javax.swing.event.ChangeListener;
 import javax.swing.event.EventListenerList;
 import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.HyperlinkListener;
-import javax.swing.text.html.HTMLDocument;
 
 import org.apache.log4j.Appender;
 import org.apache.log4j.AppenderSkeleton;
@@ -109,7 +107,6 @@ import org.apache.log4j.chainsaw.prefs.S
 import org.apache.log4j.chainsaw.prefs.SettingsListener;
 import org.apache.log4j.chainsaw.prefs.SettingsManager;
 import org.apache.log4j.chainsaw.receivers.ReceiversPanel;
-import org.apache.log4j.chainsaw.version.VersionManager;
 import org.apache.log4j.net.SocketNodeEventListener;
 import org.apache.log4j.plugins.Plugin;
 import org.apache.log4j.plugins.PluginEvent;
@@ -816,8 +813,6 @@ public class LogUI extends JFrame implem
           String inputLine = JOptionPane.showInputDialog(LogUI.this, "Enter the line number
to go:", "Goto Line", -1);
           try {
         	  int lineNumber = Integer.parseInt(inputLine);
-              List eventList = getCurrentLogPanel().getEvents();
-
               int row = getCurrentLogPanel().setSelectedEvent(lineNumber);
               if (row == -1) {
                   JOptionPane.showMessageDialog(LogUI.this, "You have entered an invalid
line number", "Error", 0);
@@ -1031,9 +1026,7 @@ public class LogUI extends JFrame implem
 
     try {
       tutorialArea.setPage(ChainsawConstants.TUTORIAL_URL);
-      Font font = UIManager.getFont("Label.font");
-      String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: " + (font.getSize()
+ 1) + "pt; }";
-      ((HTMLDocument)tutorialArea.getDocument()).getStyleSheet().addRule(bodyRule);
+      JEditorPaneFormatter.applySystemFontAndSize(tutorialArea);
 
       container.add(new JScrollPane(tutorialArea), BorderLayout.CENTER);
     } catch (Exception e) {

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/WelcomePanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/WelcomePanel.java?rev=930795&r1=930794&r2=930795&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/WelcomePanel.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/WelcomePanel.java Mon Apr
 5 05:17:31 2010
@@ -17,18 +17,13 @@
 
 package org.apache.log4j.chainsaw;
 
-import org.apache.log4j.chainsaw.icons.ChainsawIcons;
-
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.event.ActionEvent;
-
 import java.io.IOException;
-
 import java.net.URL;
-
 import java.util.Stack;
 
 import javax.swing.AbstractAction;
@@ -44,7 +39,8 @@ import javax.swing.SwingUtilities;
 import javax.swing.UIManager;
 import javax.swing.event.HyperlinkEvent;
 import javax.swing.event.HyperlinkListener;
-import javax.swing.text.html.HTMLDocument;
+
+import org.apache.log4j.chainsaw.icons.ChainsawIcons;
 
 
 /**
@@ -75,11 +71,10 @@ public class WelcomePanel extends JPanel
       add(pane, BorderLayout.CENTER);
 
       try {
-        textInfo.setPage(helpURL);
-        String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: " + (font.getSize()
+ 1) + "pt; }";
-        ((HTMLDocument)textInfo.getDocument()).getStyleSheet().addRule(bodyRule);
         textInfo.setEditable(false);
         textInfo.setPreferredSize(new Dimension(320, 240));
+        textInfo.setPage(helpURL);
+        JEditorPaneFormatter.applySystemFontAndSize(textInfo);
         textInfo.addHyperlinkListener(
           new HyperlinkListener() {
             public void hyperlinkUpdate(HyperlinkEvent e) {
@@ -108,9 +103,8 @@ public class WelcomePanel extends JPanel
           try {
             urlStack.push(textInfo.getPage());
             textInfo.setPage(url);
-            Font font = UIManager.getFont("Label.font");
-            String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: "
+ (font.getSize() + 1) + "pt; }";
-            ((HTMLDocument)textInfo.getDocument()).getStyleSheet().addRule(bodyRule);
+            //not all pages displayed in the Welcome Panel are html-based (example receiver
config is an xml file)..
+            JEditorPaneFormatter.applySystemFontAndSize(textInfo);
             urlToolbar.updateToolbar();
           } catch (IOException e) {
             e.printStackTrace();

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/layout/LayoutEditorPane.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/layout/LayoutEditorPane.java?rev=930795&r1=930794&r2=930795&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/layout/LayoutEditorPane.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/layout/LayoutEditorPane.java
Mon Apr  5 05:17:31 2010
@@ -18,7 +18,6 @@
 package org.apache.log4j.chainsaw.layout;
 
 import java.awt.Dimension;
-import java.awt.Font;
 import java.awt.Frame;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -37,20 +36,19 @@ import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JToolBar;
 import javax.swing.ScrollPaneConstants;
-import javax.swing.UIManager;
 import javax.swing.WindowConstants;
 import javax.swing.event.CaretEvent;
 import javax.swing.event.CaretListener;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
-import javax.swing.text.html.HTMLDocument;
 
 import org.apache.log4j.Logger;
 import org.apache.log4j.chainsaw.ChainsawConstants;
+import org.apache.log4j.chainsaw.JEditorPaneFormatter;
 import org.apache.log4j.chainsaw.icons.ChainsawIcons;
+import org.apache.log4j.spi.LocationInfo;
 import org.apache.log4j.spi.LoggingEvent;
 import org.apache.log4j.spi.ThrowableInformation;
-import org.apache.log4j.spi.LocationInfo;
 
 
 /**
@@ -207,9 +205,7 @@ public final class LayoutEditorPane exte
     okButton.setToolTipText("Accepts the current Pattern layout and will apply it to the
Log Panel");
     cancelButton.setToolTipText("Closes this dialog and discards your changes");
 
-    Font font = UIManager.getFont("Label.font");
-    String bodyRule = "body { font-family: " + font.getFamily() + "; font-size: " + (font.getSize()
+ 1) + "pt; }";
-    ((HTMLDocument)previewer.getDocument()).getStyleSheet().addRule(bodyRule);
+    JEditorPaneFormatter.applySystemFontAndSize(previewer);
       
     previewer.setEditable(false);
     patternEditor.setPreferredSize(new Dimension(240, 240));

Modified: logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.html
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.html?rev=930795&r1=930794&r2=930795&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.html
(original)
+++ logging/chainsaw/trunk/src/main/resources/org/apache/log4j/chainsaw/zeroconf/ZeroConfPlugin.html
Mon Apr  5 05:17:31 2010
@@ -6,7 +6,7 @@
 
 <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#800000" ALINK="#FF00FF"
BACKGROUND="?">
 <h2>ZeroConf (Zero Configuration)</h2>
-<p>One of the hardest parts of any network-based application is configuring which bits
connect to what, and how 
+<p>One of the hardest parts of any network-based application is configuring which bits
connect to what, and how
 do they connect to each other.  Each device that can be connected <emphasis>to</emphasis>
already knows
 the configuration details required to connect to it, but every other device that may wish
to connect to it
 will need to be provided with this information so the connection can be established.
@@ -34,7 +34,7 @@ Most of the network-based appenders are 
 download the JmDNS package (at least version 1.0), add the JmDNS jar to your application's
classpath, and set the "advertiseViaMulticastDNS"
 parameter to 'true' for any of the appenders or receivers you want to advertise (most of
the time you will want to advertise appenders, so they can be
 automatically detected by Chainsaw).</p>
-<p>You're log4j.xml configuration file could be as simple as this:</p>
+<p>Your log4j.xml configuration file could be as simple as this:</p>
 <pre>
 &lt;log4j:configuration debug="false" threshold="debug"  xmlns:log4j="http://jakarta.apache.org/log4j/&gt;
     &lt;appender name="zeroconf" class="org.apache.log4j.net.SocketHubAppender"&gt;



Mime
View raw message