logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r954949 - in /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw: ChainsawToolBarAndMenus.java LogPanel.java LoggerNameTreePanel.java
Date Tue, 15 Jun 2010 16:20:52 GMT
Author: sdeboy
Date: Tue Jun 15 16:20:51 2010
New Revision: 954949

URL: http://svn.apache.org/viewvc?rev=954949&view=rev
Log:
replace jtextarea refs with editor, so we can apply the system font to entry fields
Updated throwable popup rendering to show message + stack trace, centering on screen

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

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java?rev=954949&r1=954948&r2=954949&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
Tue Jun 15 16:20:51 2010
@@ -42,13 +42,13 @@ import javax.swing.JButton;
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JComponent;
 import javax.swing.JDialog;
+import javax.swing.JEditorPane;
 import javax.swing.JLabel;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
 import javax.swing.JPanel;
 import javax.swing.JRadioButtonMenuItem;
-import javax.swing.JTextArea;
 import javax.swing.JTextField;
 import javax.swing.JToolBar;
 import javax.swing.KeyStroke;
@@ -1052,11 +1052,12 @@ class ChainsawToolBarAndMenus implements
     panel.add(
       new JLabel("Enter expression for new tab:  "), BorderLayout.NORTH);
 
-    final JTextArea textArea = new JTextArea(4, 75);
-    JTextComponentFormatter.applySystemFontAndSize(textArea);
-    textArea.addKeyListener(
-      new ExpressionRuleContext(new FilterModel(), textArea));
-    panel.add(textArea, BorderLayout.CENTER);
+    final JEditorPane entryField = new JEditorPane();
+    entryField.setPreferredSize(new Dimension(350, 75));
+    JTextComponentFormatter.applySystemFontAndSize(entryField);
+    entryField.addKeyListener(
+      new ExpressionRuleContext(new FilterModel(), entryField));
+    panel.add(entryField, BorderLayout.CENTER);
 
     JButton ok = new JButton("OK");
     JButton close = new JButton("Close");
@@ -1069,7 +1070,7 @@ class ChainsawToolBarAndMenus implements
     ok.addActionListener(
       new AbstractAction() {
         public void actionPerformed(ActionEvent evt) {
-          logui.createCustomExpressionLogPanel(textArea.getText());
+          logui.createCustomExpressionLogPanel(entryField.getText());
           SwingUtilities.getAncestorOfClass(JDialog.class, panel).setVisible(
             false);
         }

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=954949&r1=954948&r2=954949&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 Tue Jun 15
16:20:51 2010
@@ -889,9 +889,11 @@ public class LogPanel extends DockablePa
 
     final JDialog detailDialog = new JDialog((JFrame) null, true);
     Container container = detailDialog.getContentPane();
-    final JTextArea detailArea = new JTextArea(10, 40);
+    final JEditorPane detailArea = new JEditorPane();
     JTextComponentFormatter.applySystemFontAndSize(detailArea);
     detailArea.setEditable(false);
+    Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
+    detailArea.setPreferredSize(new Dimension(screenDimension.width / 2, screenDimension.height
/ 2));
     container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
     container.add(new JScrollPane(detailArea));
 
@@ -900,19 +902,16 @@ public class LogPanel extends DockablePa
     throwableRenderPanel.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
-          Object o = table.getValueAt(
-            table.getSelectedRow(), table.getSelectedColumn());
-          if (o == null) {
-            //no row selected - ignore
-          	logger.debug("no row selected - unable to display throwable popup");
-            return;
-          }
+          ExtendedLoggingEvent event = tableModel.getRow(table.getSelectedRow());
           detailDialog.setTitle(
             table.getColumnName(table.getSelectedColumn()) + " detail...");
-
-          if (o instanceof String[]) {
+          if (event == null) {
+              detailArea.setText("");
+          } else if (event.getThrowableStrRep() instanceof String[]) {
             StringBuffer buf = new StringBuffer();
-            String[] ti = (String[]) o;
+            buf.append(event.getMessage());
+            buf.append("\n");
+            String[] ti = (String[]) event.getThrowableStrRep();
             buf.append(ti[0]).append("\n");
 
             for (int i = 1; i < ti.length; i++) {
@@ -921,13 +920,13 @@ public class LogPanel extends DockablePa
 
             detailArea.setText(buf.toString());
           } else {
-            detailArea.setText(o.toString());
+            //no exception
+            detailArea.setText("");
           }
 
-          detailDialog.setLocation(lowerPanel.getLocationOnScreen());
           SwingHelper.invokeOnEDT(new Runnable() {
               public void run() {
-                detailDialog.setVisible(true);
+                centerAndSetVisible(detailDialog);
               }
             });
         }

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=954949&r1=954948&r2=954949&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
Tue Jun 15 16:20:51 2010
@@ -22,6 +22,7 @@ import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Cursor;
+import java.awt.Dimension;
 import java.awt.FlowLayout;
 import java.awt.Font;
 import java.awt.Point;
@@ -55,12 +56,12 @@ import javax.swing.JButton;
 import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JColorChooser;
 import javax.swing.JDialog;
+import javax.swing.JEditorPane;
 import javax.swing.JLabel;
 import javax.swing.JList;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
-import javax.swing.JTextArea;
 import javax.swing.JToolBar;
 import javax.swing.JTree;
 import javax.swing.SwingUtilities;
@@ -134,7 +135,7 @@ final class LoggerNameTreePanel extends 
   private final LogPanelPreferenceModel preferenceModel;
 
   private final JList ignoreList = new JList();
-  private final JTextArea ignoreExpressionTextArea = new JTextArea(4, 75);
+  private final JEditorPane ignoreExpressionEntryField = new JEditorPane();
   private final JScrollPane ignoreListScroll = new JScrollPane(ignoreList);
   private final JDialog ignoreDialog = new JDialog();
   private final JDialog ignoreExpressionDialog = new JDialog();
@@ -176,9 +177,8 @@ final class LoggerNameTreePanel extends 
     this.filterModel = filterModel;
 
     setLayout(new BorderLayout());
-    ignoreExpressionTextArea.setLineWrap(true);
-    ignoreExpressionTextArea.setWrapStyleWord(true);
-    JTextComponentFormatter.applySystemFontAndSize(ignoreExpressionTextArea);
+    ignoreExpressionEntryField.setPreferredSize(new Dimension(300, 150));
+    JTextComponentFormatter.applySystemFontAndSize(ignoreExpressionEntryField);
 
     ruleDelegate = new AbstractRule() {
     	public boolean evaluate(LoggingEvent e, Map matches)
@@ -378,13 +378,13 @@ final class LoggerNameTreePanel extends 
     ignoreListPanel.add(ignoreListScroll, BorderLayout.CENTER);
 
     JPanel ignoreExpressionDialogPanel = new JPanel(new BorderLayout());
-    ignoreExpressionTextArea.addKeyListener(new ExpressionRuleContext(filterModel, ignoreExpressionTextArea));
+    ignoreExpressionEntryField.addKeyListener(new ExpressionRuleContext(filterModel, ignoreExpressionEntryField));
 
-    ignoreExpressionDialogPanel.add(new JScrollPane(ignoreExpressionTextArea), BorderLayout.CENTER);
+    ignoreExpressionDialogPanel.add(new JScrollPane(ignoreExpressionEntryField), BorderLayout.CENTER);
     JButton ignoreExpressionCloseButton = new JButton(new AbstractAction("Close") {
           public void actionPerformed(ActionEvent e)
           {
-              String ignoreText = ignoreExpressionTextArea.getText();
+              String ignoreText = ignoreExpressionEntryField.getText();
 
               if (updateIgnoreExpression(ignoreText)) {
                 ignoreExpressionDialog.setVisible(false);
@@ -442,11 +442,11 @@ final class LoggerNameTreePanel extends 
             firePropertyChange("hiddenSet", null, null);
 
             updateAllIgnoreStuff();
-            ignoreExpressionTextArea.setBackground(UIManager.getColor("TextField.background"));
+            ignoreExpressionEntryField.setBackground(UIManager.getColor("TextField.background"));
             return true;
         } catch (IllegalArgumentException iae) {
-            ignoreExpressionTextArea.setToolTipText(iae.getMessage());
-            ignoreExpressionTextArea.setBackground(ChainsawConstants.INVALID_EXPRESSION_BACKGROUND);
+            ignoreExpressionEntryField.setToolTipText(iae.getMessage());
+            ignoreExpressionEntryField.setBackground(ChainsawConstants.INVALID_EXPRESSION_BACKGROUND);
             return false;
         }
     }
@@ -1455,7 +1455,7 @@ final class LoggerNameTreePanel extends 
     }
 
     public String getHiddenExpression() {
-        String text = ignoreExpressionTextArea.getText();
+        String text = ignoreExpressionEntryField.getText();
         if (text == null || text.trim().equals("")) {
             return null;
         }
@@ -1463,7 +1463,7 @@ final class LoggerNameTreePanel extends 
     }
 
     public void setHiddenExpression(String hiddenExpression) {
-        ignoreExpressionTextArea.setText(hiddenExpression);
+        ignoreExpressionEntryField.setText(hiddenExpression);
         updateIgnoreExpression(hiddenExpression);
     }
 



Mime
View raw message