logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r943365 - in /logging/chainsaw/trunk/src/main: java/org/apache/log4j/chainsaw/ java/org/apache/log4j/chainsaw/color/ java/org/apache/log4j/chainsaw/messages/ resources/org/apache/log4j/chainsaw/help/
Date Wed, 12 May 2010 03:52:41 GMT
Author: sdeboy
Date: Wed May 12 03:52:40 2010
New Revision: 943365

URL: http://svn.apache.org/viewvc?rev=943365&view=rev
Log:
Added search and alternating row foreground/background color (global) preferences (updated
from color settings window) 
added default alternating row and search background colors to color chooser combobox
Renamed menu items to improve clarity
Added ability to close most windows via escape key

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ExtendedLoggingEvent.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/FileMenu.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferencePanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/color/ColorPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/messages/MessageCenter.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/ApplicationPreferenceModel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModel.java?rev=943365&r1=943364&r2=943365&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModel.java
Wed May 12 03:52:40 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.log4j.chainsaw;
 
+import java.awt.Color;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
 import java.util.Vector;
@@ -40,8 +41,12 @@ public class ApplicationPreferenceModel 
     private int cyclicBufferSize = 50000;
     private String lastUsedVersion = "";
     private int responsiveness = 3;
-    
-    private String identifierExpression = "PROP.hostname - PROP.application"; 
+    private Color searchBackgroundColor = ChainsawConstants.FIND_LOGGER_BACKGROUND;
+    private Color searchForegroundColor = ChainsawConstants.FIND_LOGGER_FOREGROUND;
+    private Color alternatingColorForegroundColor = ChainsawConstants.COLOR_ODD_ROW_FOREGROUND;
+    private Color alternatingColorBackgroundColor = ChainsawConstants.COLOR_ODD_ROW_BACKGROUND;
+
+    private String identifierExpression = "PROP.hostname - PROP.application";
 
     private transient final PropertyChangeSupport propertySupport =
         new PropertyChangeSupport(this);
@@ -195,8 +200,21 @@ public class ApplicationPreferenceModel 
       setConfigurationURL(model.getConfigurationURL());
       setLastUsedVersion(model.getLastUsedVersion());
       setOkToRemoveSecurityManager(model.isOkToRemoveSecurityManager());
+      Color searchForeground = model.getSearchForegroundColor();
+      Color searchBackground = model.getSearchBackgroundColor();
+      if (searchForeground != null && searchBackground != null) {
+        setSearchBackgroundColor(searchBackground);
+        setSearchForegroundColor(searchForeground);
+      }
+
+      Color alternatingForeground = model.getAlternatingColorForegroundColor();
+      Color alternatingBackground = model.getAlternatingColorBackgroundColor();
+      if (alternatingForeground != null && alternatingBackground != null) {
+        setAlternatingBackgroundColor(alternatingBackground);
+        setAlternatingForegroundColor(alternatingForeground);
+      }
     }
-    
+
     /**
      * @return Returns the responsiveness.
      */
@@ -260,6 +278,42 @@ public class ApplicationPreferenceModel 
       firePropertyChange("statusBar", oldValue, this.statusBar);
     }
 
+    public void setAlternatingForegroundColor(Color alternatingColorForegroundColor) {
+        this.alternatingColorForegroundColor = alternatingColorForegroundColor;
+        firePropertyChange("alternatingColor", true, false);
+    }
+
+    public void setAlternatingBackgroundColor(Color alternatingColorBackgroundColor) {
+        this.alternatingColorBackgroundColor = alternatingColorBackgroundColor;
+        firePropertyChange("alternatingColor", true, false);
+    }
+
+    public void setSearchForegroundColor(Color searchForegroundColor) {
+        this.searchForegroundColor = searchForegroundColor;
+        firePropertyChange("searchColor", true, false);
+    }
+
+    public void setSearchBackgroundColor(Color searchBackgroundColor) {
+        this.searchBackgroundColor = searchBackgroundColor;
+        firePropertyChange("searchColor", true, false);
+    }
+
+    public Color getAlternatingColorBackgroundColor() {
+        return alternatingColorBackgroundColor;
+    }
+
+    public Color getAlternatingColorForegroundColor() {
+        return alternatingColorForegroundColor;
+    }
+
+    public Color getSearchBackgroundColor() {
+        return searchBackgroundColor;
+    }
+
+    public Color getSearchForegroundColor() {
+        return searchForegroundColor;
+    }
+
     /**
      * @return Returns the receivers.
      */

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java?rev=943365&r1=943364&r2=943365&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ChainsawConstants.java
Wed May 12 03:52:40 2010
@@ -39,8 +39,11 @@ public class ChainsawConstants {
   public static final Color FIND_LOGGER_BACKGROUND = new Color(213, 226, 235);
   public static final Color FIND_LOGGER_FOREGROUND = Color.BLACK;
 
-  public static final Color COLOR_ODD_ROW = new Color(227, 227, 227);
-  public static final Color COLOR_EVEN_ROW = COLOR_DEFAULT_BACKGROUND;
+  public static final Color COLOR_ODD_ROW_BACKGROUND = new Color(227, 227, 227);
+  public static final Color COLOR_ODD_ROW_FOREGROUND = Color.BLACK;
+
+  public static final Color COLOR_EVEN_ROW_BACKGROUND = COLOR_DEFAULT_BACKGROUND;
+  public static final Color COLOR_EVEN_ROW_FOREGROUND = Color.BLACK;
 
   public static final URL WELCOME_URL = ChainsawConstants.class.getClassLoader().getResource(
   "org/apache/log4j/chainsaw/WelcomePanel.html");

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=943365&r1=943364&r2=943365&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
Wed May 12 03:52:40 2010
@@ -636,7 +636,7 @@ class ChainsawToolBarAndMenus implements
       };
 
     showPreferences.putValue(
-      Action.SHORT_DESCRIPTION, "LogPanel Preferences...");
+      Action.SHORT_DESCRIPTION, "Tab Preferences...");
 
     // TODO think of good mnemonics and HotKey for this action
     return showPreferences;
@@ -656,7 +656,7 @@ class ChainsawToolBarAndMenus implements
       };
 
     createExpressionPanel.putValue(
-      Action.SHORT_DESCRIPTION, "Create custom expression LogPanel...   ");
+      Action.SHORT_DESCRIPTION, "Create tab from expression...   ");
 
     // TODO think of good mnemonics and HotKey for this action
     return createExpressionPanel;
@@ -675,7 +675,7 @@ class ChainsawToolBarAndMenus implements
       };
 
     showColorPanel.putValue(
-      Action.SHORT_DESCRIPTION, "LogPanel Color Filter...");
+      Action.SHORT_DESCRIPTION, "Color settings...");
 
     // TODO think of good mnemonics and HotKey for this action
     return showColorPanel;

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ExtendedLoggingEvent.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ExtendedLoggingEvent.java?rev=943365&r1=943364&r2=943365&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ExtendedLoggingEvent.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ExtendedLoggingEvent.java
Wed May 12 03:52:40 2010
@@ -57,11 +57,11 @@ public class ExtendedLoggingEvent extend
     }
     
     public Color getForeground() {
-        return searchMatch ? ChainsawConstants.FIND_LOGGER_FOREGROUND : colorRuleForeground;
+        return colorRuleForeground;
     }
 
     public Color getBackground() {
-        return searchMatch ? ChainsawConstants.FIND_LOGGER_BACKGROUND : colorRuleBackground;
+        return colorRuleBackground;
     }
 
     public Color getColorRuleBackground() {

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/FileMenu.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/FileMenu.java?rev=943365&r1=943364&r2=943365&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/FileMenu.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/FileMenu.java Wed May 12
03:52:40 2010
@@ -64,28 +64,28 @@ class FileMenu extends JMenu {
 
     loadLog4JAction =
       new FileLoadAction(
-        logUI, new XMLDecoder(logUI), "Load Log4J File...", false);
+        logUI, new XMLDecoder(logUI), "Process events from local log4j XML-formatted file
(.xml or .zip)...", false);
 
       loadLog4JAction.putValue(
         Action.ACCELERATOR_KEY,
         KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));
       loadLog4JAction.putValue(Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_L));
-      loadLog4JAction.putValue(Action.SHORT_DESCRIPTION, "Loads an XML event file");
+      loadLog4JAction.putValue(Action.SHORT_DESCRIPTION, "Loads events from a local XMLLayout-formatted
file ");
       loadLog4JAction.putValue(Action.SMALL_ICON, new ImageIcon(ChainsawIcons.FILE_OPEN));
 
     loadUtilLoggingAction =
       new FileLoadAction(
         logUI, new UtilLoggingXMLDecoder(logUI),
-        "Load Java Util File...", false);
+        "Process events from local java.util.logging XML-formatted file...", false);
 
     remoteLog4JAction =
       new FileLoadAction(
-        logUI, new XMLDecoder(logUI), "Load Remote Log4J File...",
+        logUI, new XMLDecoder(logUI), "Process events from remote log4j XML-formatted file...",
         true);
     remoteUtilLoggingAction =
       new FileLoadAction(
         logUI, new UtilLoggingXMLDecoder(logUI),
-        "Load Remote Java Util File...", true);
+        "Process events from remote java.util.logging XML-formatted file...", true);
 
     saveAction = new FileSaveAction(logUI);
 

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=943365&r1=943364&r2=943365&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 Wed May 12
03:52:40 2010
@@ -206,7 +206,7 @@ public class LogPanel extends DockablePa
   private static final double DEFAULT_LOG_TREE_SPLIT_LOCATION = 0.2d;
   private final String identifier;
   private final ChainsawStatusBar statusBar;
-  private final JFrame preferencesFrame = new JFrame();
+  private final JFrame logPanelPreferencesFrame = new JFrame();
   private ColorPanel colorPanel;
   private final JFrame colorFrame = new JFrame();
   private final JFrame undockedFrame;
@@ -224,7 +224,7 @@ public class LogPanel extends DockablePa
   private final JSplitPane nameTreeAndMainPanelSplit;
   private final LoggerNameTreePanel logTreePanel;
   private final LogPanelPreferenceModel preferenceModel = new LogPanelPreferenceModel();
-  private final LogPanelPreferencePanel preferencesPanel = new LogPanelPreferencePanel(preferenceModel);
+  private final LogPanelPreferencePanel logPanelPreferencesPanel = new LogPanelPreferencePanel(preferenceModel);
   private final FilterModel filterModel = new FilterModel();
   private final RuleColorizer colorizer = new RuleColorizer();
   private final RuleMediator ruleMediator = new RuleMediator();
@@ -251,6 +251,7 @@ public class LogPanel extends DockablePa
   private AutoFilterComboBox filterCombo;
   private JScrollPane eventsPane;
   private int currentSearchMatchCount;
+  private ApplicationPreferenceModel applicationPreferenceModel;
 
     /**
    * Creates a new LogPanel object.  If a LogPanel with this identifier has
@@ -259,9 +260,11 @@ public class LogPanel extends DockablePa
    * @param statusBar shared status bar, provided by main application
    * @param identifier used to load and save settings
    */
-  public LogPanel(final ChainsawStatusBar statusBar, final String identifier, int cyclicBufferSize,
Map allColorizers) {
+  public LogPanel(final ChainsawStatusBar statusBar, final String identifier, int cyclicBufferSize,
+                  Map allColorizers, ApplicationPreferenceModel applicationPreferenceModel)
{
     this.identifier = identifier;
     this.statusBar = statusBar;
+    this.applicationPreferenceModel = applicationPreferenceModel;
     logger.debug("creating logpanel for " + identifier);
 
     setLayout(new BorderLayout());
@@ -284,20 +287,30 @@ public class LogPanel extends DockablePa
     columnNameKeywordMap.put(ChainsawConstants.THROWABLE_COL_NAME, LoggingEventFieldResolver.EXCEPTION_FIELD);
     columnNameKeywordMap.put(ChainsawConstants.TIMESTAMP_COL_NAME, LoggingEventFieldResolver.TIMESTAMP_FIELD);
 
-    preferencesFrame.setTitle("'" + identifier + "' Log Panel Preferences");
-    preferencesFrame.setIconImage(
+    logPanelPreferencesFrame.setTitle("'" + identifier + "' Log Panel Preferences");
+    logPanelPreferencesFrame.setIconImage(
       ((ImageIcon) ChainsawIcons.ICON_PREFERENCES).getImage());
-    preferencesFrame.getContentPane().add(new JScrollPane(preferencesPanel));
+    logPanelPreferencesFrame.getContentPane().add(new JScrollPane(logPanelPreferencesPanel));
 
-    preferencesFrame.setSize(740, 520);
+    logPanelPreferencesFrame.setSize(740, 520);
 
-    preferencesPanel.setOkCancelActionListener(
+    logPanelPreferencesPanel.setOkCancelActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
-          preferencesFrame.setVisible(false);
+          logPanelPreferencesFrame.setVisible(false);
         }
       });
 
+        KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
+            Action closeLogPanelPreferencesFrameAction = new AbstractAction() {
+                public void actionPerformed(ActionEvent e) {
+                  logPanelPreferencesFrame.setVisible(false);
+                }
+            };
+            logPanelPreferencesFrame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape,
"ESCAPE"); logPanelPreferencesFrame.getRootPane().
+                    getActionMap().put("ESCAPE", closeLogPanelPreferencesFrameAction);
+
+
     setDetailPaneConversionPattern(
       DefaultLayoutFactory.getDefaultPatternLayout());
       detailLayout.setConversionPattern(
@@ -370,7 +383,7 @@ public class LogPanel extends DockablePa
     menuItemToggleToolTips.setIcon(new ImageIcon(ChainsawIcons.TOOL_TIP));
 
     final JCheckBoxMenuItem menuItemLoggerTree =
-      new JCheckBoxMenuItem("Show Logger Tree panel");
+      new JCheckBoxMenuItem("Show Logger Tree");
     menuItemLoggerTree.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
@@ -588,6 +601,24 @@ public class LogPanel extends DockablePa
         }
       });
 
+    applicationPreferenceModel.addPropertyChangeListener("searchColor", new PropertyChangeListener()
{
+        public void propertyChange(PropertyChangeEvent evt)
+        {
+            if (table != null) {
+              table.repaint();
+            }
+        }
+    });
+
+    applicationPreferenceModel.addPropertyChangeListener("alternatingColor", new PropertyChangeListener()
{
+        public void propertyChange(PropertyChangeEvent evt)
+        {
+            if (table != null) {
+              table.repaint();
+            }
+        }
+    });
+
     /*
      *End of preferenceModel listeners
      */
@@ -687,15 +718,23 @@ public class LogPanel extends DockablePa
     /*
      * Color rule frame and panel
      */
-    colorFrame.setTitle("'" + identifier + "' Color Filter");
+    colorFrame.setTitle("'" + identifier + "' color settings");
     colorFrame.setIconImage(
       ((ImageIcon) ChainsawIcons.ICON_PREFERENCES).getImage());
 
     allColorizers.put(identifier, colorizer);
-    colorPanel = new ColorPanel(colorizer, filterModel, allColorizers);
+    colorPanel = new ColorPanel(colorizer, filterModel, allColorizers, applicationPreferenceModel);
 
     colorFrame.getContentPane().add(colorPanel);
 
+        Action closeColorPanelAction = new AbstractAction() {
+            public void actionPerformed(ActionEvent e) {
+              colorPanel.hidePanel();
+            }
+        };
+        colorFrame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape,
"ESCAPE"); colorFrame.getRootPane().
+                getActionMap().put("ESCAPE", closeColorPanelAction);
+
     colorPanel.setCloseActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
@@ -824,7 +863,7 @@ public class LogPanel extends DockablePa
         }
       });
 
-    renderer = new TableColorizingRenderer(colorizer);
+    renderer = new TableColorizingRenderer(colorizer, applicationPreferenceModel);
     renderer.setToolTipsVisible(preferenceModel.isToolTips());
 
     table.setDefaultRenderer(Object.class, renderer);
@@ -1297,7 +1336,7 @@ public class LogPanel extends DockablePa
         }
       });
 
-    JMenuItem menuItemColorPanel = new JMenuItem("LogPanel Color Filter...");
+    JMenuItem menuItemColorPanel = new JMenuItem("Color settings...");
     menuItemColorPanel.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
@@ -1307,7 +1346,7 @@ public class LogPanel extends DockablePa
     menuItemColorPanel.setIcon(ChainsawIcons.ICON_PREFERENCES);
 
     JMenuItem menuItemLogPanelPreferences =
-      new JMenuItem("LogPanel Preferences...");
+      new JMenuItem("Tab Preferences...");
     menuItemLogPanelPreferences.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
@@ -1828,7 +1867,7 @@ public class LogPanel extends DockablePa
      * Display the panel preferences frame
      */
   void showPreferences() {
-    preferencesFrame.setVisible(true);
+    logPanelPreferencesFrame.setVisible(true);
   }
 
   /**

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=943365&r1=943364&r2=943365&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
Wed May 12 03:52:40 2010
@@ -579,7 +579,7 @@ public class LogPanelPreferencePanel ext
       new JCheckBox("Show Event Detail panel");
 
     private final JCheckBox loggerTreePanel =
-      new JCheckBox("Show Logger Tree panel");
+      new JCheckBox("Show Logger Tree");
     private final JCheckBox scrollToBottom =
       new JCheckBox("Scroll to bottom (view tracks with new events)");
     private final JCheckBox toolTips =

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=943365&r1=943364&r2=943365&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 Wed May 12 03:52:40
2010
@@ -552,7 +552,15 @@ public class LogUI extends JFrame implem
           preferencesFrame.setVisible(false);
         }
       });
-    
+      KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
+          Action closeAction = new AbstractAction() {
+              public void actionPerformed(ActionEvent e) {
+                preferencesFrame.setVisible(false);
+              }
+          };
+          preferencesFrame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape,
"ESCAPE"); preferencesFrame.getRootPane().
+                  getActionMap().put("ESCAPE", closeAction);
+
     OSXIntegration.init(this);
   
   }
@@ -1928,7 +1936,7 @@ public class LogUI extends JFrame implem
   private void buildLogPanel(
       boolean customExpression, final String ident, final List events)
       throws IllegalArgumentException {
-      final LogPanel thisPanel = new LogPanel(getStatusBar(), ident, cyclicBufferSize, allColorizers);
+      final LogPanel thisPanel = new LogPanel(getStatusBar(), ident, cyclicBufferSize, allColorizers,
applicationPreferenceModel);
 
 
       /**

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=943365&r1=943364&r2=943365&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
Wed May 12 03:52:40 2010
@@ -49,6 +49,9 @@ import javax.swing.UIManager;
 import javax.swing.border.Border;
 import javax.swing.table.DefaultTableCellRenderer;
 import javax.swing.table.TableColumn;
+import javax.swing.text.MutableAttributeSet;
+import javax.swing.text.StyleConstants;
+import javax.swing.text.StyledDocument;
 import javax.swing.text.html.HTMLDocument;
 import javax.swing.text.html.HTMLEditorKit;
 
@@ -100,11 +103,13 @@ public class TableColorizingRenderer ext
   private final JPanel multiLinePanel = new JPanel();
   private final JPanel generalPanel = new JPanel();
   private final JPanel levelPanel = new JPanel();
+  private ApplicationPreferenceModel applicationPreferenceModel;
 
     /**
    * Creates a new TableColorizingRenderer object.
    */
-  public TableColorizingRenderer(RuleColorizer colorizer) {
+  public TableColorizingRenderer(RuleColorizer colorizer, ApplicationPreferenceModel applicationPreferenceModel)
{
+    this.applicationPreferenceModel = applicationPreferenceModel;
     multiLinePanel.setLayout(new BoxLayout(multiLinePanel, BoxLayout.Y_AXIS));
     generalPanel.setLayout(new BoxLayout(generalPanel, BoxLayout.Y_AXIS));
     levelPanel.setLayout(new BoxLayout(levelPanel, BoxLayout.Y_AXIS));
@@ -311,32 +316,34 @@ public class TableColorizingRenderer ext
     Rule loggerRule = colorizer.getLoggerRule();
     //use logger colors in table instead of event colors if event passes logger rule
     if (loggerRule != null && loggerRule.evaluate(loggingEvent, null)) {
-        background = ChainsawConstants.FIND_LOGGER_BACKGROUND;
-        foreground = ChainsawConstants.FIND_LOGGER_FOREGROUND;
+        background = applicationPreferenceModel.getSearchBackgroundColor();
+        foreground = applicationPreferenceModel.getSearchForegroundColor();
     } else {
-        background = loggingEvent.getBackground();
-        foreground = loggingEvent.getForeground();
+        background = loggingEvent.isSearchMatch()?applicationPreferenceModel.getSearchBackgroundColor():loggingEvent.getBackground();
+        foreground = loggingEvent.isSearchMatch()?applicationPreferenceModel.getSearchForegroundColor():loggingEvent.getForeground();
     }
 
     /**
-     * Colourize background based on row striping if the event still has a background color
+     * Colourize background based on row striping if the event still has default foreground
and background color
      */
-    if (background.equals(ChainsawConstants.COLOR_DEFAULT_BACKGROUND)) {
+    if (background.equals(ChainsawConstants.COLOR_DEFAULT_BACKGROUND) && foreground.equals(ChainsawConstants.COLOR_DEFAULT_FOREGROUND))
{
       if ((row % 2) != 0) {
-        background = ChainsawConstants.COLOR_ODD_ROW;
-      } else {
-        background = ChainsawConstants.COLOR_EVEN_ROW;
+        background = applicationPreferenceModel.getAlternatingColorBackgroundColor();
+        foreground = applicationPreferenceModel.getAlternatingColorForegroundColor();
       }
     }
 
     component.setBackground(background);
     component.setForeground(foreground);
 
-    //set the colors of the components inside 'component'
+    //update the background & foreground of the jtextpane using styles
     if (multiLineTextPane != null)
     {
+        StyledDocument styledDocument = multiLineTextPane.getStyledDocument();
+        MutableAttributeSet attributes = multiLineTextPane.getInputAttributes();
+        StyleConstants.setForeground(attributes, foreground);
+        styledDocument.setCharacterAttributes(0, styledDocument.getLength() + 1, attributes,
false);
         multiLineTextPane.setBackground(background);
-        multiLineTextPane.setForeground(foreground);
     }
     levelLabel.setBackground(background);
     levelLabel.setForeground(foreground);

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=943365&r1=943364&r2=943365&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 Wed
May 12 03:52:40 2010
@@ -49,12 +49,10 @@ import javax.swing.JButton;
 import javax.swing.JColorChooser;
 import javax.swing.JComboBox;
 import javax.swing.JDialog;
-import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JList;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
-import javax.swing.JSeparator;
 import javax.swing.JTable;
 import javax.swing.JTextField;
 import javax.swing.ListCellRenderer;
@@ -66,6 +64,7 @@ import javax.swing.event.ListSelectionLi
 import javax.swing.table.DefaultTableModel;
 import javax.swing.table.TableCellRenderer;
 
+import org.apache.log4j.chainsaw.ApplicationPreferenceModel;
 import org.apache.log4j.chainsaw.ChainsawConstants;
 import org.apache.log4j.chainsaw.ExpressionRuleContext;
 import org.apache.log4j.chainsaw.filter.FilterModel;
@@ -83,7 +82,8 @@ import org.apache.log4j.rule.Rule;
  *
  * @author Scott Deboy <sdeboy@apache.org>
  */
-public class ColorPanel extends JPanel {
+public class ColorPanel extends JPanel
+{
   private static final String DEFAULT_STATUS = "<html>Double click a rule field to
edit the rule</html>";
   private final String currentRuleSet = "Default";
 
@@ -100,14 +100,28 @@ public class ColorPanel extends JPanel {
   private DefaultComboBoxModel logPanelColorizersModel;
   private Map allLogPanelColorizers;
   private RuleColorizer currentLogPanelColorizer;
+  private JTable searchTable;
+  private DefaultTableModel searchTableModel;
+  private Vector searchColumns;
+  private Vector searchDataVector;
+  private Vector searchDataVectorEntry;
+
+  private JTable alternatingColorTable;
+  private DefaultTableModel alternatingColorTableModel;
+  private Vector alternatingColorColumns;
+  private Vector alternatingColorDataVector;
+  private Vector alternatingColorDataVectorEntry;
+  private ApplicationPreferenceModel applicationPreferenceModel;
 
-    public ColorPanel(final RuleColorizer currentLogPanelColorizer, final FilterModel filterModel,
final Map allLogPanelColorizers) {
+    public ColorPanel(final RuleColorizer currentLogPanelColorizer, final FilterModel filterModel,
+                      final Map allLogPanelColorizers, final ApplicationPreferenceModel applicationPreferenceModel)
{
     super(new BorderLayout());
 
     this.currentLogPanelColorizer = currentLogPanelColorizer;
     this.colorizer = currentLogPanelColorizer;
     this.filterModel = filterModel;
     this.allLogPanelColorizers = allLogPanelColorizers;
+    this.applicationPreferenceModel = applicationPreferenceModel;
 
     currentLogPanelColorizer.addPropertyChangeListener(
     	      "colorrule",
@@ -120,15 +134,46 @@ public class ColorPanel extends JPanel {
     tableModel = new DefaultTableModel();
     table = new JTable(tableModel);
 
+    searchTableModel = new DefaultTableModel();
+    searchTable = new JTable(searchTableModel);
+    searchTable.setPreferredScrollableViewportSize(new Dimension(30, 30));
+
+    alternatingColorTableModel = new DefaultTableModel();
+    alternatingColorTable = new JTable(alternatingColorTableModel);
+    alternatingColorTable.setPreferredScrollableViewportSize(new Dimension(30, 30));
+
     columns = new Vector();
     columns.add("Expression");
     columns.add("Background");
     columns.add("Foreground");
 
+    searchColumns = new Vector();
+    searchColumns.add("Background");
+    searchColumns.add("Foreground");
+
+    alternatingColorColumns = new Vector();
+    alternatingColorColumns.add("Background");
+    alternatingColorColumns.add("Foreground");
+
+    //searchtable contains only a single-entry vector containing a two-item vector (foreground,
background)
+    searchDataVector = new Vector();
+    searchDataVectorEntry = new Vector();
+    searchDataVectorEntry.add(applicationPreferenceModel.getSearchBackgroundColor());
+    searchDataVectorEntry.add(applicationPreferenceModel.getSearchForegroundColor());
+    searchDataVector.add(searchDataVectorEntry);
+    searchTableModel.setDataVector(searchDataVector, searchColumns);
+
+    alternatingColorDataVector = new Vector();
+    alternatingColorDataVectorEntry = new Vector();
+    alternatingColorDataVectorEntry.add(applicationPreferenceModel.getAlternatingColorBackgroundColor());
+    alternatingColorDataVectorEntry.add(applicationPreferenceModel.getAlternatingColorForegroundColor());
+    alternatingColorDataVector.add(alternatingColorDataVectorEntry);
+    alternatingColorTableModel.setDataVector(alternatingColorDataVector, alternatingColorColumns);
+
     table.setPreferredScrollableViewportSize(new Dimension(525, 200));
     tableScrollPane = new JScrollPane(table);
 
-    Vector data = getColorizerVector();    
+    Vector data = getColorizerVector();
     tableModel.setDataVector(data, columns);
 
     table.sizeColumnsToFit(0);
@@ -137,6 +182,20 @@ public class ColorPanel extends JPanel {
     table.getColumnModel().getColumn(1).setMaxWidth(80);
     table.getColumnModel().getColumn(2).setMaxWidth(80);
 
+    searchTable.sizeColumnsToFit(0);
+    searchTable.getColumnModel().getColumn(0).setPreferredWidth(80);
+    searchTable.getColumnModel().getColumn(1).setPreferredWidth(80);
+    searchTable.getColumnModel().getColumn(0).setMaxWidth(80);
+    searchTable.getColumnModel().getColumn(1).setMaxWidth(80);
+    configureSingleEntryColorTable(searchTable);
+
+    alternatingColorTable.sizeColumnsToFit(0);
+    alternatingColorTable.getColumnModel().getColumn(0).setPreferredWidth(80);
+    alternatingColorTable.getColumnModel().getColumn(1).setPreferredWidth(80);
+    alternatingColorTable.getColumnModel().getColumn(0).setMaxWidth(80);
+    alternatingColorTable.getColumnModel().getColumn(1).setMaxWidth(80);
+    configureSingleEntryColorTable(alternatingColorTable);
+
     configureTable();
 
     statusBar = new JLabel(DEFAULT_STATUS);
@@ -154,7 +213,15 @@ public class ColorPanel extends JPanel {
     JPanel southPanel = new JPanel();
     southPanel.setLayout(new BoxLayout(southPanel, BoxLayout.Y_AXIS));
     southPanel.add(Box.createVerticalStrut(5));
-    southPanel.add(new JSeparator());
+    southPanel.add(Box.createVerticalStrut(5));
+    JPanel searchAndAlternatingColorPanel = buildSearchAndAlternatingColorPanel();
+    JPanel globalLabelPanel = new JPanel();
+    globalLabelPanel.setLayout(new BoxLayout(globalLabelPanel, BoxLayout.X_AXIS));
+    JLabel globalLabel = new JLabel("Global colors:");
+    globalLabelPanel.add(globalLabel);
+    globalLabelPanel.add(Box.createHorizontalGlue());
+    southPanel.add(globalLabelPanel);
+    southPanel.add(searchAndAlternatingColorPanel);
     southPanel.add(Box.createVerticalStrut(5));
     JPanel closePanel = buildClosePanel();
     southPanel.add(closePanel);
@@ -222,47 +289,41 @@ public class ColorPanel extends JPanel {
               }
           }
       }
+      //update search and alternating colors, since they may have changed from another color
panel
+      searchDataVectorEntry.set(0, applicationPreferenceModel.getSearchBackgroundColor());
+      searchDataVectorEntry.set(1, applicationPreferenceModel.getSearchForegroundColor());
+      alternatingColorDataVectorEntry.set(0, applicationPreferenceModel.getAlternatingColorBackgroundColor());
+      alternatingColorDataVectorEntry.set(1, applicationPreferenceModel.getAlternatingColorForegroundColor());
   }
 
-  public static void main(String[] args) {
-    FilterModel filterModel = new FilterModel();
-    RuleColorizer colorizer = new RuleColorizer();
-
-    Map otherColorizers = new HashMap();
-
-    RuleColorizer panel1Colorizer = new RuleColorizer();
-    HashMap entry1 = new HashMap();
-    List list1 = new ArrayList();
-    list1.add(new ColorRule("logger == test1", ExpressionRule.getRule("logger == test1"),
Color.YELLOW, Color.BLACK));
-    entry1.put("Default", list1);
-    panel1Colorizer.setRules(entry1);
-    otherColorizers.put("test1", panel1Colorizer);
-
-    RuleColorizer panel2Colorizer = new RuleColorizer();
-    HashMap entry2 = new HashMap();
-    List list2 = new ArrayList();
-    list2.add(new ColorRule("logger == test2", ExpressionRule.getRule("logger == test2"),
Color.YELLOW, Color.BLACK));
-    entry2.put("Default", list2);
-    panel2Colorizer.setRules(entry2);
-    otherColorizers.put("test2", panel2Colorizer);
-
-    ColorPanel p = new ColorPanel(colorizer, filterModel, otherColorizers);
-    final JFrame f = new JFrame();
-
-    p.setCloseActionListener(
-      new ActionListener() {
-        public void actionPerformed(ActionEvent e) {
-          System.exit(0);
-        }
-      });
+  public JPanel buildSearchAndAlternatingColorPanel() {
+      JPanel panel = new JPanel();
+      panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
+
+      JLabel defineSearchColorsLabel = new JLabel("Search colors");
+
+      panel.add(defineSearchColorsLabel);
+
+      panel.add(Box.createHorizontalStrut(10));
+      JScrollPane searchPane = new JScrollPane(searchTable);
+      searchPane.setBorder(BorderFactory.createEmptyBorder());
+      panel.add(searchPane);
+
+      panel.add(Box.createHorizontalStrut(10));
+      JLabel defineAlternatingColorLabel = new JLabel("Alternating colors");
 
-//    Following does not compile on JDK 1.3.1
-    f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
-    f.getContentPane().add(p);
-    f.pack();
-    f.setVisible(true);
+      panel.add(defineAlternatingColorLabel);
+
+      panel.add(Box.createHorizontalStrut(10));
+      JScrollPane alternatingColorPane = new JScrollPane(alternatingColorTable);
+      alternatingColorPane.setBorder(BorderFactory.createEmptyBorder());
+
+      panel.add(alternatingColorPane);
+      panel.setBorder(BorderFactory.createEtchedBorder());
+      panel.add(Box.createHorizontalGlue());
+      return panel;
   }
-  
+
   public void updateColors() {
     tableModel.getDataVector().clear();
     tableModel.getDataVector().addAll(getColorizerVector());
@@ -297,6 +358,9 @@ public class ColorPanel extends JPanel {
 
     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));
@@ -362,6 +426,39 @@ public class ColorPanel extends JPanel {
       new ColorTableCellRenderer());
   }
 
+  private void configureSingleEntryColorTable(JTable thisTable) {
+      thisTable.setToolTipText("Double click to edit");
+      thisTable.setRowHeight(20);
+      thisTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+      thisTable.setColumnSelectionAllowed(false);
+
+      Vector backgroundColors = getDefaultColors();
+      Vector foregroundColors = getDefaultColors();
+      backgroundColors.add("Browse...");
+      foregroundColors.add("Browse...");
+
+      JComboBox background = new JComboBox(backgroundColors);
+      background.setMaximumRowCount(15);
+      background.setRenderer(new ColorListCellRenderer());
+
+      JComboBox foreground = new JComboBox(foregroundColors);
+      foreground.setMaximumRowCount(15);
+      foreground.setRenderer(new ColorListCellRenderer());
+
+      DefaultCellEditor backgroundEditor = new DefaultCellEditor(background);
+      DefaultCellEditor foregroundEditor = new DefaultCellEditor(foreground);
+      thisTable.getColumnModel().getColumn(0).setCellEditor(backgroundEditor);
+      thisTable.getColumnModel().getColumn(1).setCellEditor(foregroundEditor);
+
+      background.addItemListener(new ColorItemListener(background));
+      foreground.addItemListener(new ColorItemListener(foreground));
+
+      thisTable.getColumnModel().getColumn(0).setCellRenderer(
+        new ColorTableCellRenderer());
+      thisTable.getColumnModel().getColumn(1).setCellRenderer(
+        new ColorTableCellRenderer());
+  }
+
   public void setCloseActionListener(ActionListener listener) {
     closeListener = listener;
   }
@@ -447,6 +544,8 @@ public class ColorPanel extends JPanel {
       new AbstractAction() {
         public void actionPerformed(ActionEvent evt) {
           applyRules(currentRuleSet, colorizer);
+          saveSearchColors();
+          saveAlternatingColors();
         }
       });
 
@@ -467,6 +566,19 @@ public class ColorPanel extends JPanel {
     return panel;
   }
 
+  private void saveSearchColors() {
+      Vector thisVector = (Vector) searchTableModel.getDataVector().get(0);
+      applicationPreferenceModel.setSearchBackgroundColor((Color)thisVector.get(0));
+      applicationPreferenceModel.setSearchForegroundColor((Color)thisVector.get(1));
+  }
+
+  private void saveAlternatingColors() {
+      Vector thisVector = (Vector) alternatingColorTableModel.getDataVector().get(0);
+      applicationPreferenceModel.setAlternatingBackgroundColor((Color)thisVector.get(0));
+      Color alternatingColorForegroundColor = (Color) thisVector.get(1);
+      applicationPreferenceModel.setAlternatingForegroundColor(alternatingColorForegroundColor);
+  }
+
   JPanel buildUpDownPanel() {
     JPanel panel = new JPanel(new BorderLayout());
     JPanel innerPanel = new JPanel();
@@ -640,6 +752,7 @@ public class ColorPanel extends JPanel {
     listPanel.add(panel, BorderLayout.NORTH);
 
     JPanel tablePanel = new JPanel(new BorderLayout());
+    tableScrollPane.setBorder(BorderFactory.createEtchedBorder());
     tablePanel.add(tableScrollPane, BorderLayout.CENTER);
     tablePanel.add(buildUpDownPanel(), BorderLayout.EAST);
     listPanel.add(tablePanel, BorderLayout.CENTER);

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/messages/MessageCenter.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/messages/MessageCenter.java?rev=943365&r1=943364&r2=943365&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/messages/MessageCenter.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/messages/MessageCenter.java
Wed May 12 03:52:40 2010
@@ -248,8 +248,8 @@ public class MessageCenter {
         super.getListCellRendererComponent(
           list, value, index, isSelected, cellHasFocus);
       c.setBackground(
-        ((index % 2) == 0) ? ChainsawConstants.COLOR_EVEN_ROW
-                           : ChainsawConstants.COLOR_ODD_ROW);
+        ((index % 2) == 0) ? ChainsawConstants.COLOR_EVEN_ROW_BACKGROUND
+                           : ChainsawConstants.COLOR_ODD_ROW_BACKGROUND);
 
       return c;
     }

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=943365&r1=943364&r2=943365&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
Wed May 12 03:52:40 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.0</h1>
+<h2>11 May 2010</h2>
+<ul>
+<li>Added search and alternating row color global preferences (updated from color settings
window)</li>
+</ul>
 <h2>9 May 2010</h2>
 <ul>
 <li>Added preference to display matching search text in the table as bold (on by default)</li>



Mime
View raw message