logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r943831 - in /logging/chainsaw/trunk/src/main: java/org/apache/log4j/chainsaw/ java/org/apache/log4j/chainsaw/color/ resources/org/apache/log4j/chainsaw/help/
Date Thu, 13 May 2010 07:25:18 GMT
Author: sdeboy
Date: Thu May 13 07:25:18 2010
New Revision: 943831

URL: http://svn.apache.org/viewvc?rev=943831&view=rev
Log:
Added ability to quickly define color rules for field under mouse pointer in the table as
well as for the selected logger in the logger tree (uses default color chooser dialog)
Added support for defining refine focus expressions from the logger tree, and modifying the
expression by appending additional logger expressions to the refine focus expression (via
OR rules).
Fixed issues preventing welcome tab from correctly hiding if it was set as hidden when Chainsaw
was last closed
Added ability to hide zeroconf panel if it was set as hidden when Chainsaw was last closed
Minor UI cleanup - removed drag & drop xml file tab (users can use file-open menu to load
the file)
Added 'exception exists' to default error/fatal color rule
Renamed context menu text in an attempt to better describe the feature


Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawTabbedPane.java
    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/LogUI.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LoggerNameTreePanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/SavableTabSetting.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/color/ColorPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.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/ChainsawTabbedPane.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawTabbedPane.java?rev=943831&r1=943830&r2=943831&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawTabbedPane.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawTabbedPane.java
Thu May 13 07:25:18 2010
@@ -63,7 +63,7 @@ import org.apache.log4j.chainsaw.prefs.S
 class ChainsawTabbedPane extends JTabbedPane implements SettingsListener {
   public SavableTabSetting tabSetting;
   public static final String WELCOME_TAB = "Welcome";
-  public static final String DRAG_DROP_TAB = "Drag & Drop XML log files here";
+  public static final String ZEROCONF = "Zeroconf";
   /**
    *
    * Create the tabbed pane.  
@@ -145,12 +145,12 @@ class ChainsawTabbedPane extends JTabbed
      SavableTabSetting setting = new SavableTabSetting();
      for(int i = 0 ; i < count ; i++){
        title = super.getTitleAt(i);
-       if(title.equals("Welcome")){
+       if(title.equals(WELCOME_TAB)){
          setting.setWelcome(true);
-       } else if (title.equals("Drag & Drop XML log files here")){
-         setting.setDragdrop(true);
        } else if (title.equals("chainsaw-log")){
          setting.setChainsawLog(true);
+       } else if (title.equals(ZEROCONF)){
+         setting.setZeroconf(true);
        }
      }
 
@@ -158,6 +158,7 @@ class ChainsawTabbedPane extends JTabbed
      writer.close();
 
    } catch (Exception e) {
+     file.delete();
      e.printStackTrace();
    }
   }
@@ -179,11 +180,12 @@ class ChainsawTabbedPane extends JTabbed
       } else {
         tabSetting = new SavableTabSetting();
         tabSetting.setWelcome(true);
-        tabSetting.setDragdrop(true);
         tabSetting.setChainsawLog(true);
+        tabSetting.setZeroconf(true);
       }
     } catch (Exception e) {
       e.printStackTrace();
+      file.delete();
     }
   }
 }

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=943831&r1=943830&r2=943831&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
Thu May 13 07:25:18 2010
@@ -74,7 +74,7 @@ class ChainsawToolBarAndMenus implements
   private final JTextField findField;
   private final Action changeModelAction;
   private final Action clearAction;
-  private final Action closeAction;
+  private final Action toggleWelcomeVisibleAction;
   private final Action findNextAction;
   private final Action findPreviousAction;
   private final Action findPreviousColorizedEventAction;
@@ -110,7 +110,7 @@ class ChainsawToolBarAndMenus implements
     new JCheckBoxMenuItem();
   private final JMenu viewMenu = new JMenu("View");
   private final JMenuBar menuBar;
-  private final JCheckBoxMenuItem menuItemClose = new JCheckBoxMenuItem();
+  private final JCheckBoxMenuItem menuShowWelcome = new JCheckBoxMenuItem();
   private final JToolBar toolbar;
   private final LogUI logui;
   private final SmallButton clearButton = new SmallButton();
@@ -128,7 +128,7 @@ class ChainsawToolBarAndMenus implements
     toolbar = new JToolBar(SwingConstants.HORIZONTAL);
     menuBar = new JMenuBar();
     fileMenu = new FileMenu(logui);
-    closeAction = createCloseHelpAction();
+    toggleWelcomeVisibleAction = toggleWelcomeVisibleAction();
     changeModelAction = createChangeModelAction();
     findField = new JTextField();
     findNextAction = getFindNextAction();
@@ -409,16 +409,15 @@ class ChainsawToolBarAndMenus implements
     return action;
   }
 
-  private Action createCloseHelpAction() {
+  private Action toggleWelcomeVisibleAction() {
     final Action action =
       new AbstractAction() {
         public void actionPerformed(ActionEvent e) {
-          closeAction.putValue(Action.NAME, "Welcome tab");
-          logui.removeWelcomePanel();
-
-          if (menuItemClose.isSelected()) {
+          toggleWelcomeVisibleAction.putValue(Action.NAME, "Welcome tab");
+          if (menuShowWelcome.isSelected()) {
             logui.addWelcomePanel();
           } else {
+            logui.removeWelcomePanel();
           }
         }
       };
@@ -455,7 +454,7 @@ class ChainsawToolBarAndMenus implements
         }
       });
 
-    menuItemClose.setAction(closeAction);
+    menuShowWelcome.setAction(toggleWelcomeVisibleAction);
 
     JCheckBoxMenuItem pause = new JCheckBoxMenuItem(pauseAction);
     JMenuItem menuPrefs = new JMenuItem(showPreferencesAction);
@@ -540,7 +539,7 @@ class ChainsawToolBarAndMenus implements
     viewMenu.add(showToolbarCheck);
     viewMenu.add(toggleStatusBarCheck);
     viewMenu.add(toggleShowReceiversCheck);
-    viewMenu.add(menuItemClose);
+    viewMenu.add(menuShowWelcome);
     viewMenu.addSeparator();
     viewMenu.add(menuCustomExpressionPanel);
 
@@ -893,7 +892,7 @@ class ChainsawToolBarAndMenus implements
     }
     showReceiversButton.setSelected(
       logui.getApplicationPreferenceModel().isReceivers());
-    menuItemClose.setSelected(logui.getTabbedPane().containsWelcomePanel());
+    menuShowWelcome.setSelected(logui.getTabbedPane().containsWelcomePanel());
 
     /**
      * We get the currently selected LogPanel, and if null, deactivate some
@@ -917,7 +916,7 @@ class ChainsawToolBarAndMenus implements
       findPanel.add(Box.createRigidArea(new Dimension(5, 0)));
       searchLabel.setLabelFor(findField);
       activeTabMenu.setEnabled(false);
-      closeAction.setEnabled(true);
+      toggleWelcomeVisibleAction.setEnabled(true);
       detailPaneButton.setSelected(false);
       toggleCyclicButton.setSelected(false);
     } else {

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=943831&r1=943830&r2=943831&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 Thu May 13
07:25:18 2010
@@ -80,6 +80,7 @@ import javax.swing.ComboBoxEditor;
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
 import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JColorChooser;
 import javax.swing.JComboBox;
 import javax.swing.JComponent;
 import javax.swing.JDialog;
@@ -141,6 +142,7 @@ import org.apache.log4j.chainsaw.prefs.S
 import org.apache.log4j.chainsaw.prefs.SettingsManager;
 import org.apache.log4j.chainsaw.xstream.TableColumnConverter;
 import org.apache.log4j.helpers.Constants;
+import org.apache.log4j.rule.ColorRule;
 import org.apache.log4j.rule.ExpressionRule;
 import org.apache.log4j.rule.Rule;
 import org.apache.log4j.spi.LoggingEvent;
@@ -695,7 +697,7 @@ public class LogPanel extends DockablePa
      *
      */
     LogPanelLoggerTreeModel logTreeModel = new LogPanelLoggerTreeModel();
-    logTreePanel = new LoggerNameTreePanel(logTreeModel, preferenceModel, this);
+    logTreePanel = new LoggerNameTreePanel(logTreeModel, preferenceModel, this, colorizer);
     logTreePanel.addPropertyChangeListener("searchExpression", new PropertyChangeListener()
     {
         public void propertyChange(PropertyChangeEvent evt)
@@ -1356,7 +1358,7 @@ public class LogPanel extends DockablePa
     menuItemLogPanelPreferences.setIcon(ChainsawIcons.ICON_PREFERENCES);
 
     final JMenuItem menuItemFocusOn =
-      new JMenuItem("Set 'refine focus' field");
+      new JMenuItem("Set 'refine focus' field to value under pointer");
     menuItemFocusOn.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
@@ -1392,7 +1394,7 @@ public class LogPanel extends DockablePa
       });
 
     final JMenuItem menuDefineAddCustomFilter =
-      new JMenuItem("Add to 'refine focus' field");
+      new JMenuItem("Add value under pointer to 'refine focus' field");
     menuDefineAddCustomFilter.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
@@ -1431,6 +1433,51 @@ public class LogPanel extends DockablePa
         }
       });
 
+    final JMenuItem menuBuildColorRule =
+      new JMenuItem("Define color rule for value under pointer");
+    menuBuildColorRule.addActionListener(
+      new ActionListener() {
+        public void actionPerformed(ActionEvent evt) {
+          if (currentPoint != null) {
+            String operator = "==";
+            int column = table.columnAtPoint(currentPoint);
+            int row = table.rowAtPoint(currentPoint);
+            String colName = table.getColumnName(column).toUpperCase();
+            String value = "";
+
+            if (colName.equalsIgnoreCase(ChainsawConstants.TIMESTAMP_COL_NAME)) {
+              JComponent comp =
+                (JComponent) table.getCellRenderer(row, column);
+
+              if (comp instanceof JLabel) {
+                value = ((JLabel) comp).getText();
+              }
+            } else if (colName.equalsIgnoreCase(ChainsawConstants.LOGGER_COL_NAME)) {
+                operator = "like";
+                value = "^" + table.getValueAt(row, column).toString() + ".*";
+            } else {
+              Object o = table.getValueAt(row, column).toString();
+
+              if (o instanceof String[] && ((String[])o).length > 0) {
+                value = ((String[]) o)[0];
+                operator = "~=";
+              } else {
+                value = o.toString();
+              }
+            }
+
+            if (columnNameKeywordMap.containsKey(colName)) {
+                Color c = JColorChooser.showDialog(getRootPane(), "Choose a color", Color.red);
+                if (c != null) {
+                    String expression = columnNameKeywordMap.get(colName).toString() + "
" + operator + " '" + value + "'";
+                    colorizer.addRule(ChainsawConstants.DEFAULT_COLOR_RULE_NAME, new ColorRule(expression,
+                            ExpressionRule.getRule(expression), c, ChainsawConstants.COLOR_DEFAULT_FOREGROUND));
+                }
+            }
+          }
+        }
+      });
+
     final JPopupMenu p = new JPopupMenu();
 
     final Action clearFocusAction =
@@ -1467,7 +1514,7 @@ public class LogPanel extends DockablePa
     p.add(new JSeparator());
 
         final JMenuItem menuItemSearch =
-      new JMenuItem("Find next");
+      new JMenuItem("Search for value under pointer");
     menuItemSearch.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
@@ -1480,6 +1527,9 @@ public class LogPanel extends DockablePa
 
             if (colName.equalsIgnoreCase(ChainsawConstants.TIMESTAMP_COL_NAME)) {
             	value = timestampExpressionFormat.format(new Date(table.getValueAt(row, column).toString()));
+            } else if (colName.equalsIgnoreCase(ChainsawConstants.LOGGER_COL_NAME)) {
+                operator = "like";
+                value = "^" + table.getValueAt(row, column).toString() + ".*";
             } else {
               Object o = table.getValueAt(row, column);
 
@@ -1504,7 +1554,7 @@ public class LogPanel extends DockablePa
       });
 
       final Action clearSearchAction =
-        new AbstractAction("Clear find next") {
+        new AbstractAction("Clear search field") {
           public void actionPerformed(ActionEvent e) {
             findField.setText(null);
             updateFindRule(null);
@@ -1534,7 +1584,7 @@ public class LogPanel extends DockablePa
     });
 
     final JMenuItem menuItemDisplayRelativeTimesToRowUnderCursor =
-      new JMenuItem("Show times relative to this row");
+      new JMenuItem("Show times relative to this event");
     menuItemDisplayRelativeTimesToRowUnderCursor.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
@@ -1556,6 +1606,9 @@ public class LogPanel extends DockablePa
     p.add(menuItemDisplayNormalTimes);
     p.add(new JSeparator());
 
+    p.add(menuBuildColorRule);
+    p.add(new JSeparator());
+        
     p.add(menuItemToggleDetails);
     p.add(menuItemLoggerTree);
     p.add(menuItemToggleToolTips);
@@ -1589,6 +1642,15 @@ public class LogPanel extends DockablePa
   	return preferenceModel.isScrollToBottom();
   }
 
+  public void setRefineFocusText(String refineFocusText) {
+      final JTextField filterText =(JTextField) filterCombo.getEditor().getEditorComponent();
+      filterText.setText(refineFocusText);
+  }
+
+  public String getRefineFocusText() {
+      final JTextField filterText =(JTextField) filterCombo.getEditor().getEditorComponent();
+      return filterText.getText();
+  }
   /**
    * Mutator
    *
@@ -2309,7 +2371,7 @@ public class LogPanel extends DockablePa
     undockedFindNextAction.putValue(Action.NAME, "Find next");
     undockedFindNextAction.putValue(
       Action.SHORT_DESCRIPTION,
-      "Find the next occurrence of the rule from the current row");
+      "Find the next search occurrence");
     undockedFindNextAction.putValue(
       Action.SMALL_ICON, new ImageIcon(ChainsawIcons.DOWN));
 
@@ -2334,7 +2396,7 @@ public class LogPanel extends DockablePa
     undockedFindPreviousAction.putValue(Action.NAME, "Find previous");
     undockedFindPreviousAction.putValue(
       Action.SHORT_DESCRIPTION,
-      "Find the previous occurrence of the rule from the current row");
+      "Find the previous search occurrence");
     undockedFindPreviousAction.putValue(
       Action.SMALL_ICON, new ImageIcon(ChainsawIcons.UP));
 

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=943831&r1=943830&r2=943831&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 Thu May 13 07:25:18
2010
@@ -543,7 +543,6 @@ public class LogUI extends JFrame implem
             
         }});
 
-	addDragDropPanel();
     applicationPreferenceModelPanel = new ApplicationPreferenceModelPanel(applicationPreferenceModel);
 
     applicationPreferenceModelPanel.setOkCancelActionListener(
@@ -565,23 +564,6 @@ public class LogUI extends JFrame implem
   
   }
 
-  private void addDragDropPanel(){
-    final JLabel lbl  = new JLabel();
-    lbl.setEnabled(false);
-    final String dndTitle = ChainsawTabbedPane.DRAG_DROP_TAB;
-    SwingUtilities.invokeLater(new Runnable() {
-    	public void run() {
-    	    ensureWelcomePanelVisible();
-    	    getTabbedPane().addANewTab(dndTitle,lbl,null, "You can Drag & Drop XML log files
onto the Tabbed Pane and they will be loaded into Chainsaw" );
-    	    getTabbedPane().setEnabledAt(getTabbedPane().indexOfTab(dndTitle), false);
-            if (!getPanelMap().containsKey(dndTitle)) {
-              getPanelMap().put(dndTitle, lbl);
-            }
-        }
-    });
-  }
-
-
   private void initPlugins(PluginRegistry pluginRegistry) {
     pluginRegistry.addPluginListener(
       new PluginListener() {
@@ -589,6 +571,7 @@ public class LogUI extends JFrame implem
           if (e.getPlugin() instanceof JComponent) {
             JComponent plugin = (JComponent) e.getPlugin();
             getTabbedPane().addANewTab(plugin.getName(), plugin, null, null);
+            getPanelMap().put(plugin.getName(), plugin);
           }
         }
 
@@ -688,7 +671,7 @@ public class LogUI extends JFrame implem
       }
       getTabbedPane().setSelectedComponent(welcomePanel);
   }
-  
+
   /**
    * Given the load event, configures the size/location of the main window etc
    * etc.
@@ -944,7 +927,7 @@ public class LogUI extends JFrame implem
           } else if (selectedComp instanceof WelcomePanel) {
             currentName = ChainsawTabbedPane.WELCOME_TAB;
           } else {
-            currentName = ChainsawTabbedPane.DRAG_DROP_TAB;
+            currentName = ChainsawTabbedPane.ZEROCONF;
           }
 
           int count = getTabbedPane().getTabCount();
@@ -1179,8 +1162,8 @@ public class LogUI extends JFrame implem
     if (!getTabbedPane().tabSetting.isWelcome()){
       displayPanel(ChainsawTabbedPane.WELCOME_TAB, false);
     }
-    if (!getTabbedPane().tabSetting.isDragdrop()){
-      displayPanel(ChainsawTabbedPane.DRAG_DROP_TAB, false);
+    if (!getTabbedPane().tabSetting.isZeroconf()){
+      displayPanel(ChainsawTabbedPane.ZEROCONF, false);
     }
     tbms.stateChange();
 
@@ -1527,10 +1510,16 @@ public class LogUI extends JFrame implem
   }
 
   void removeWelcomePanel() {
-    if (getTabbedPane().containsWelcomePanel()) {
-      getTabbedPane().remove(
-        getTabbedPane().getComponentAt(getTabbedPane().indexOfTab(ChainsawTabbedPane.WELCOME_TAB)));
-    }
+    EventQueue.invokeLater(new Runnable()
+    {
+        public void run()
+        {
+            if (getTabbedPane().containsWelcomePanel()) {
+              getTabbedPane().remove(
+                getTabbedPane().getComponentAt(getTabbedPane().indexOfTab(ChainsawTabbedPane.WELCOME_TAB)));
+            }
+        }
+    });
   }
 
   ChainsawStatusBar getStatusBar() {
@@ -1571,31 +1560,18 @@ public class LogUI extends JFrame implem
   }
 
   void displayPanel(String panelName, boolean display) {
-    Object o = getPanelMap().get(panelName);
-    Component p = null;
+    Component p = (Component)getPanelMap().get(panelName);
 
-    if (o instanceof LogPanel) {
-      p = (LogPanel) o;
-    } else if (o instanceof WelcomePanel) {
-      p = (WelcomePanel) o;
-    } else if (o instanceof JLabel) {
-      p = (JLabel) o;
-    }
-
-      int index = getTabbedPane().indexOfTab(panelName);
-
-      if ((index == -1) && display) {
-        if (panelName.equals(ChainsawTabbedPane.DRAG_DROP_TAB)){
-          addDragDropPanel();
-        } else {
-          getTabbedPane().addTab(panelName, p);
-        }
-      }
+    int index = getTabbedPane().indexOfTab(panelName);
 
-      if ((index > -1) && !display) {
-        getTabbedPane().removeTabAt(index);
-      }
-   }
+    if ((index == -1) && display) {
+      getTabbedPane().addTab(panelName, p);
+    }
+
+    if ((index > -1) && !display) {
+      getTabbedPane().removeTabAt(index);
+    }
+  }
   
 
   /**

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=943831&r1=943830&r2=943831&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
Thu May 13 07:25:18 2010
@@ -19,6 +19,7 @@
 package org.apache.log4j.chainsaw;
 
 import java.awt.BorderLayout;
+import java.awt.Color;
 import java.awt.Component;
 import java.awt.Cursor;
 import java.awt.FlowLayout;
@@ -52,6 +53,7 @@ import javax.swing.DefaultListModel;
 import javax.swing.ImageIcon;
 import javax.swing.JButton;
 import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JColorChooser;
 import javax.swing.JDialog;
 import javax.swing.JLabel;
 import javax.swing.JList;
@@ -78,9 +80,12 @@ import javax.swing.tree.TreeSelectionMod
 
 import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
+import org.apache.log4j.chainsaw.color.RuleColorizer;
 import org.apache.log4j.chainsaw.icons.ChainsawIcons;
 import org.apache.log4j.chainsaw.icons.LineIconFactory;
 import org.apache.log4j.rule.AbstractRule;
+import org.apache.log4j.rule.ColorRule;
+import org.apache.log4j.rule.ExpressionRule;
 import org.apache.log4j.rule.Rule;
 import org.apache.log4j.spi.LoggingEvent;
 
@@ -112,10 +117,12 @@ final class LoggerNameTreePanel extends 
   private final Action expandAction;
   private final Action findNextAction;
   private final Action clearFindNextAction;
+  private final Action defineColorRuleForLoggerAction;
+  private final Action setRefineFocusAction;
+  private final Action updateRefineFocusAction;
   private final JButton expandButton = new SmallButton();
-  private final JButton findNextButton = new SmallButton();
-  private final JButton clearFindNextButton = new SmallButton();
   private final Action focusOnAction;
+  private final Action clearRefineFocusAction;
   private final SmallToggleButton focusOnLoggerButton =
     new SmallToggleButton();
   private final Set hiddenSet = new HashSet();
@@ -141,6 +148,7 @@ final class LoggerNameTreePanel extends 
   private final JScrollPane scrollTree;
   private final JToolBar toolbar = new JToolBar();
   private final LogPanel logPanel;
+  private final RuleColorizer colorizer;
 
     //~ Constructors ============================================================
 
@@ -149,12 +157,13 @@ final class LoggerNameTreePanel extends 
    *
    * @param logTreeModel
    */
-  LoggerNameTreePanel(LogPanelLoggerTreeModel logTreeModel, LogPanelPreferenceModel preferenceModel,
LogPanel logPanel)
+  LoggerNameTreePanel(LogPanelLoggerTreeModel logTreeModel, LogPanelPreferenceModel preferenceModel,
LogPanel logPanel, RuleColorizer colorizer)
   {
     super();
     this.logTreeModel = logTreeModel;
     this.preferenceModel = preferenceModel;
     this.logPanel = logPanel;
+    this.colorizer = colorizer;
 
     setLayout(new BorderLayout());
 
@@ -261,6 +270,10 @@ final class LoggerNameTreePanel extends 
     expandAction = createExpandAction();
     findNextAction = createFindNextAction();
     clearFindNextAction = createClearFindNextAction();
+    defineColorRuleForLoggerAction = createDefineColorRuleForLoggerAction();
+    clearRefineFocusAction = createClearRefineFocusAction();
+    setRefineFocusAction = createSetRefineFocusAction();
+    updateRefineFocusAction = createUpdateRefineFocusAction();
     editLoggerAction = createEditLoggerAction();
     closeAction = createCloseAction();
     collapseAction = createCollapseAction();
@@ -604,12 +617,6 @@ final class LoggerNameTreePanel extends 
     ignoreLoggerButton.setAction(hideAction);
     ignoreLoggerButton.setText(null);
 
-    findNextButton.setAction(findNextAction);
-    findNextButton.setText(null);
-
-    clearFindNextButton.setAction(clearFindNextAction);
-    clearFindNextButton.setText(null);
-
     expandButton.setFont(expandButton.getFont().deriveFont(Font.BOLD));
     collapseButton.setFont(collapseButton.getFont().deriveFont(Font.BOLD));
 
@@ -776,6 +783,97 @@ final class LoggerNameTreePanel extends 
       return action;
     }
 
+    private Action createSetRefineFocusAction()
+    {
+      Action action = new AbstractAction()
+        {
+          public void actionPerformed(ActionEvent e)
+          {
+            setRefineFocusUsingCurrentlySelectedNode();
+          }
+        };
+
+      action.putValue(Action.NAME, "Set 'refine focus' to selected logger");
+      action.putValue(
+        Action.SHORT_DESCRIPTION,
+        "Refine focus on the selected node");
+      action.setEnabled(false);
+
+      return action;
+    }
+
+    private Action createUpdateRefineFocusAction()
+    {
+      Action action = new AbstractAction()
+        {
+          public void actionPerformed(ActionEvent e)
+          {
+            updateRefineFocusUsingCurrentlySelectedNode();
+          }
+        };
+
+      action.putValue(Action.NAME, "Update 'refine focus' to include selected logger");
+      action.putValue(
+        Action.SHORT_DESCRIPTION,
+        "Add selected node to 'refine focus' field");
+      action.setEnabled(false);
+
+      return action;
+    }
+
+    private void updateRefineFocusUsingCurrentlySelectedNode()
+    {
+        String selectedLogger = getCurrentlySelectedLoggerName();
+        TreePath[] paths = logTree.getSelectionPaths();
+
+        if (paths == null)
+        {
+          return;
+        }
+        String currentFilterText = logPanel.getRefineFocusText();
+        logPanel.setRefineFocusText(currentFilterText + " || logger like '^" + selectedLogger
+ ".*'");
+    }
+
+    private void setRefineFocusUsingCurrentlySelectedNode()
+    {
+        String selectedLogger = getCurrentlySelectedLoggerName();
+        TreePath[] paths = logTree.getSelectionPaths();
+
+        if (paths == null)
+        {
+          return;
+        }
+        logPanel.setRefineFocusText("logger like '^" + selectedLogger + ".*'");
+    }
+
+    private Action createDefineColorRuleForLoggerAction() {
+        Action action = new AbstractAction()
+          {
+            public void actionPerformed(ActionEvent e)
+            {
+                String selectedLogger = getCurrentlySelectedLoggerName();
+                TreePath[] paths = logTree.getSelectionPaths();
+
+                if (paths == null)
+                {
+                  return;
+                }
+            Color c = JColorChooser.showDialog(getRootPane(), "Choose a color", Color.red);
+            if (c != null) {
+                String expression = "logger like '^" + selectedLogger + ".*'";
+                colorizer.addRule(ChainsawConstants.DEFAULT_COLOR_RULE_NAME, new ColorRule(expression,
+                        ExpressionRule.getRule(expression), c, ChainsawConstants.COLOR_DEFAULT_FOREGROUND));
+            }
+        }};
+
+        action.putValue(Action.NAME, "Define color rule for selected logger");
+        action.putValue(
+          Action.SHORT_DESCRIPTION,
+          "Define color rule for logger");
+        action.setEnabled(false);
+        return action;
+    }
+
     /**
      * Creates an action that is used to find the next match of the selected node (similar
to default selection behavior
      * except the search field is populated and the next match is selected.
@@ -791,15 +889,33 @@ final class LoggerNameTreePanel extends 
           }
         };
 
-      action.putValue(Action.NAME, "Clear find next");
+      action.putValue(Action.NAME, "Clear search field");
       action.putValue(
         Action.SHORT_DESCRIPTION,
-        "Search using the selected node");
+        "Clear the search field");
       action.setEnabled(false);
 
       return action;
     }
 
+    private Action createClearRefineFocusAction()
+    {
+      Action action = new AbstractAction()
+        {
+          public void actionPerformed(ActionEvent e)
+          {
+            clearRefineFocus();
+          }
+        };
+
+      action.putValue(Action.NAME, "Clear 'refine focus' field");
+      action.putValue(
+        Action.SHORT_DESCRIPTION,
+        "Clear the refine focus field");
+      action.setEnabled(false);
+
+      return action;
+    }
 
   /**
    * DOCUMENT ME!
@@ -888,7 +1004,7 @@ final class LoggerNameTreePanel extends 
       {
         return;
       }
-      firePropertyChange("searchExpression", null, "logger ~= " + selectedLogger);
+      firePropertyChange("searchExpression", null, "logger like '^" + selectedLogger + ".*'");
   }
 
   private void clearFindNext()
@@ -896,6 +1012,11 @@ final class LoggerNameTreePanel extends 
       firePropertyChange("searchExpression", null, "");
   }
 
+  private void clearRefineFocus()
+  {
+      logPanel.setRefineFocusText("");
+  }
+
   /**
    * Expands the currently selected node (if any)
    * including all the children.
@@ -1005,19 +1126,24 @@ final class LoggerNameTreePanel extends 
     {
       focusOnAction.putValue(Action.NAME, "Focus On...");
       hideAction.putValue(Action.NAME, "Ignore...");
-      findNextAction.putValue(Action.NAME, "Find next...");
+      findNextAction.putValue(Action.NAME, "Search for...");
+      setRefineFocusAction.putValue(Action.NAME, "Set refine focus field");
+      updateRefineFocusAction.putValue(Action.NAME, "Add to refine focus field");
+      defineColorRuleForLoggerAction.putValue(Action.NAME, "Define color rule");
     }
     else
     {
       focusOnAction.putValue(Action.NAME, "Focus On '" + logger + "'");
       hideAction.putValue(Action.NAME, "Ignore '" + logger + "'");
-      findNextAction.putValue(Action.NAME, "Find next '" + logger + "'");
+      findNextAction.putValue(Action.NAME, "Search for '" + logger + "'");
+      setRefineFocusAction.putValue(Action.NAME, "Set refine focus field to '" + logger +
"'");
+      updateRefineFocusAction.putValue(Action.NAME, "Add '" + logger + "' to 'refine focus'
field");
+      defineColorRuleForLoggerAction.putValue(Action.NAME, "Define color rule for '" + logger
+ "'");
     }
 
     // need to ensure the button doens't update itself with the text, looks stupid otherwise
     focusOnLoggerButton.setText(null);
     ignoreLoggerButton.setText(null);
-    findNextButton.setText(null);
   }
 
   /**
@@ -1063,6 +1189,10 @@ final class LoggerNameTreePanel extends 
           expandAction.setEnabled(path != null);
           findNextAction.setEnabled(path != null);
           clearFindNextAction.setEnabled(true);
+          defineColorRuleForLoggerAction.setEnabled(path != null);
+          setRefineFocusAction.setEnabled(path != null);
+          updateRefineFocusAction.setEnabled(path != null);
+          clearRefineFocusAction.setEnabled(true);
 
           if (logger != null)
           {
@@ -1341,14 +1471,20 @@ final class LoggerNameTreePanel extends 
       add(expandAction);
       add(collapseAction);
       addSeparator();
-      add(findNextAction);
-      add(clearFindNextAction);
-      addSeparator();
       add(focusOnCheck);
       add(hideCheck);
+      addSeparator();
+      add(setRefineFocusAction);
+      add(updateRefineFocusAction);
+      add(clearRefineFocusAction);
+      addSeparator();
+      add(findNextAction);
+      add(clearFindNextAction);
 
-      //      add(editLoggerAction);
       addSeparator();
+      add(defineColorRuleForLoggerAction);
+      addSeparator();
+
       add(clearIgnoreListAction);
     }
   }

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/SavableTabSetting.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/SavableTabSetting.java?rev=943831&r1=943830&r2=943831&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/SavableTabSetting.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/SavableTabSetting.java
Thu May 13 07:25:18 2010
@@ -7,12 +7,10 @@ package org.apache.log4j.chainsaw;
 
 public class SavableTabSetting {
     private boolean welcome = false;
-    private boolean dragdrop = false;
     private boolean chainsawLog = false;
-
-    public void setDragdrop(boolean dragdrop) {
-        this.dragdrop = dragdrop;
-    }
+    private boolean zeroConf = false;
+    //not used currently, but leaving it here to prevent xstream exception for older clients
+    private boolean dragdrop = false;
 
     public void setWelcome(boolean welcome) {
         this.welcome = welcome;
@@ -22,15 +20,20 @@ public class SavableTabSetting {
         this.chainsawLog = chainsawLog;
     }
 
-    public boolean isWelcome() {
-        return welcome;
+    public void setZeroconf(boolean zeroConf)
+    {
+        this.zeroConf = zeroConf;
     }
 
-    public boolean isDragdrop() {
-        return dragdrop;
+    public boolean isWelcome() {
+        return welcome;
     }
 
     public boolean isChainsawLog() {
         return chainsawLog;
     }
+
+    public boolean isZeroconf() {
+        return zeroConf;
+    }
 }

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/color/ColorPanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/color/ColorPanel.java?rev=943831&r1=943830&r2=943831&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/color/ColorPanel.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/color/ColorPanel.java Thu
May 13 07:25:18 2010
@@ -353,47 +353,14 @@ public class ColorPanel extends JPanel
       return data;
   }
 
-  private Vector getDefaultColors() {
-    Vector vec = new Vector();
-
-    vec.add(Color.white);
-    vec.add(Color.black);
-    //add default alternating color & search backgrounds (both foreground are black)
-    vec.add(ChainsawConstants.COLOR_ODD_ROW_BACKGROUND);
-    vec.add(ChainsawConstants.FIND_LOGGER_BACKGROUND);
-
-    vec.add(new Color(255, 255, 225));
-    vec.add(new Color(255, 225, 255));
-    vec.add(new Color(225, 255, 255));
-    vec.add(new Color(255, 225, 225));
-    vec.add(new Color(225, 255, 225));
-    vec.add(new Color(225, 225, 255));
-    vec.add(new Color(225, 225, 183));
-    vec.add(new Color(225, 183, 225));
-    vec.add(new Color(183, 225, 225));
-    vec.add(new Color(183, 225, 183));
-    vec.add(new Color(183, 183, 225));
-    vec.add(new Color(232, 201, 169));
-    vec.add(new Color(255, 255, 153));
-    vec.add(new Color(255, 153, 153));
-    vec.add(new Color(189, 156, 89));
-    vec.add(new Color(255, 102, 102));
-    vec.add(new Color(255, 177, 61));
-    vec.add(new Color(61, 255, 61));
-    vec.add(new Color(153, 153, 255));
-    vec.add(new Color(255, 153, 255));
-      
-    return vec;
-  }
-
   private void configureTable() {
     table.setToolTipText("Double click to edit");
     table.setRowHeight(20);
     table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     table.setColumnSelectionAllowed(false);
 
-    Vector backgroundColors = getDefaultColors();
-    Vector foregroundColors = getDefaultColors();
+    Vector backgroundColors = colorizer.getDefaultColors();
+    Vector foregroundColors = colorizer.getDefaultColors();
     backgroundColors.add("Browse...");
     foregroundColors.add("Browse...");
 
@@ -432,8 +399,8 @@ public class ColorPanel extends JPanel
       thisTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
       thisTable.setColumnSelectionAllowed(false);
 
-      Vector backgroundColors = getDefaultColors();
-      Vector foregroundColors = getDefaultColors();
+      Vector backgroundColors = colorizer.getDefaultColors();
+      Vector foregroundColors = colorizer.getDefaultColors();
       backgroundColors.add("Browse...");
       foregroundColors.add("Browse...");
 

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.java?rev=943831&r1=943830&r2=943831&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.java
Thu May 13 07:25:18 2010
@@ -36,6 +36,7 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Vector;
 
 import org.apache.log4j.chainsaw.ChainsawConstants;
 import org.apache.log4j.chainsaw.prefs.SettingsManager;
@@ -52,32 +53,31 @@ import org.apache.log4j.spi.LoggingEvent
  * @author Scott Deboy <sdeboy@apache.org>
  */
 public class RuleColorizer implements Colorizer {
-  public static final String DEFAULT_NAME = "Default";
   private Map rules;
   private final PropertyChangeSupport colorChangeSupport =
     new PropertyChangeSupport(this);
   private Map defaultRules = new HashMap();
-  private String currentRuleSet = DEFAULT_NAME;
+  private String currentRuleSet = ChainsawConstants.DEFAULT_COLOR_RULE_NAME;
   private Rule findRule;
   private Rule loggerRule;
 
   private static final String COLORS_EXTENSION = ".colors";
 
   private final Color WARN_DEFAULT_COLOR = new Color(255, 255, 153);
-  private final Color ERROR_OR_FATAL_DEFAULT_COLOR = new Color(255, 153, 153);
+  private final Color FATAL_OR_ERROR_DEFAULT_COLOR = new Color(255, 153, 153);
   private final Color MARKER_DEFAULT_COLOR = new Color(153, 255, 153);
 
   private final String DEFAULT_WARN_EXPRESSION = "level == WARN";
-  private final String DEFAULT_ERROR_FATAL_EXPRESSION = "level == FATAL || level == ERROR";
+  private final String DEFAULT_FATAL_ERROR_EXCEPTION_EXPRESSION = "level == FATAL || level
== ERROR || exception exists";
   private final String DEFAULT_MARKER_EXPRESSION = "prop.log4j.marker exists";
 
   public RuleColorizer() {
     List rulesList = new ArrayList();
 
-      String expression = DEFAULT_ERROR_FATAL_EXPRESSION;
+      String expression = DEFAULT_FATAL_ERROR_EXCEPTION_EXPRESSION;
       rulesList.add(
       new ColorRule(
-        expression, ExpressionRule.getRule(expression), ERROR_OR_FATAL_DEFAULT_COLOR,
+        expression, ExpressionRule.getRule(expression), FATAL_OR_ERROR_DEFAULT_COLOR,
         Color.black));
       expression = DEFAULT_WARN_EXPRESSION;
       rulesList.add(
@@ -91,7 +91,7 @@ public class RuleColorizer implements Co
           expression, ExpressionRule.getRule(expression), MARKER_DEFAULT_COLOR,
           Color.black));
 
-    defaultRules.put(DEFAULT_NAME, rulesList);
+    defaultRules.put(currentRuleSet, rulesList);
     setRules(defaultRules);
   }
 
@@ -294,4 +294,38 @@ public class RuleColorizer implements Co
     }
     return f.exists();
   }
+
+    public Vector getDefaultColors() {
+      Vector vec = new Vector();
+
+      vec.add(Color.white);
+      vec.add(Color.black);
+      //add default alternating color & search backgrounds (both foreground are black)
+      vec.add(ChainsawConstants.COLOR_ODD_ROW_BACKGROUND);
+      vec.add(ChainsawConstants.FIND_LOGGER_BACKGROUND);
+
+      vec.add(new Color(255, 255, 225));
+      vec.add(new Color(255, 225, 255));
+      vec.add(new Color(225, 255, 255));
+      vec.add(new Color(255, 225, 225));
+      vec.add(new Color(225, 255, 225));
+      vec.add(new Color(225, 225, 255));
+      vec.add(new Color(225, 225, 183));
+      vec.add(new Color(225, 183, 225));
+      vec.add(new Color(183, 225, 225));
+      vec.add(new Color(183, 225, 183));
+      vec.add(new Color(183, 183, 225));
+      vec.add(new Color(232, 201, 169));
+      vec.add(new Color(255, 255, 153));
+      vec.add(new Color(255, 153, 153));
+      vec.add(new Color(189, 156, 89));
+      vec.add(new Color(255, 102, 102));
+      vec.add(new Color(255, 177, 61));
+      vec.add(new Color(61, 255, 61));
+      vec.add(new Color(153, 153, 255));
+      vec.add(new Color(255, 153, 255));
+
+      return vec;
+    }
+
 }

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=943831&r1=943830&r2=943831&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
Thu May 13 07:25:18 2010
@@ -10,6 +10,15 @@
 <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.0</h1>
+<h2>13 May 2010</h2>
+<ul>
+<li>Added ability to quickly define color rules for field under mouse pointer in the
table as well as for the selected logger in the logger tree (uses default color chooser dialog).</li>
+<li>Added support for defining refine focus expressions from the logger tree, and modifying
the expression by appending additional logger expressions to the refine focus expression (via
OR rules).</li>
+<li>Fixed issues preventing welcome tab from correctly hiding if it was set as hidden
when Chainsaw was last closed.</li>
+<li>Added ability to hide zeroconf panel if it was set as hidden when Chainsaw was
last closed.</li>
+<li>Added 'exception exists' to default error/fatal color rule.</li>
+<li>Renamed context menu text in an attempt to better describe the feature.</li>
+</ul>
 <h2>11 May 2010</h2>
 <ul>
 <li>Added search and alternating row color global preferences (updated from color settings
window)</li>



Mime
View raw message