logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r1031448 - in /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw: LogUI.java ReceiverConfigurationPanel.java receivers/ReceiversPanel.java
Date Fri, 05 Nov 2010 06:20:00 GMT
Author: sdeboy
Date: Fri Nov  5 06:19:59 2010
New Revision: 1031448

URL: http://svn.apache.org/viewvc?rev=1031448&view=rev
Log:
Removed 'use auto-saved config' from initial receiver config screen, added 'save' button to
receiver definition panel
Updates to use of receiver configuration (using custom-saved option if available)

Modified:
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java

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=1031448&r1=1031447&r2=1031448&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 Fri Nov  5 06:19:59
2010
@@ -1453,23 +1453,14 @@ public class LogUI extends JFrame implem
                 pluginRegistry.addPlugin(networkReceiver);
                 networkReceiver.activateOptions();
                 receiversPanel.updateReceiverTreeInDispatchThread();
-                //setting config URL here ensures we have the receiver panel auto-saved config
loaded
-                if (receiverConfigurationPanel.isDontWarnMeAgain()) {
-                    configURL = receiverConfigurationPanel.getModel().getSavedConfigToLoad();
-                }
               } catch (Exception e3) {
                 MessageCenter.getInstance().getLogger().error(
                   "Error creating Receiver", e3);
                 MessageCenter.getInstance().getLogger().info(
                   "An error occurred creating your Receiver");
               }
-            } else if (receiverConfigurationPanel.getModel().isLoadConfig() ||
-                    receiverConfigurationPanel.getModel().isLoadSavedConfigs()) {
-              if (receiverConfigurationPanel.getModel().isLoadSavedConfigs()) {
-                  configURL = receiverConfigurationPanel.getModel().getSavedConfigToLoad();
-              } else {
+            } else if (receiverConfigurationPanel.getModel().isLoadConfig()) {
                   configURL = receiverConfigurationPanel.getModel().getConfigToLoad();
-              }
             } else if (receiverConfigurationPanel.getModel().isLogFileReceiverConfig()) {
               try {
                   URL fileURL = receiverConfigurationPanel.getModel().getLogFileURL();
@@ -1492,9 +1483,6 @@ public class LogUI extends JFrame implem
                       pluginRegistry.addPlugin(fileReceiver);
                       fileReceiver.activateOptions();
                       receiversPanel.updateReceiverTreeInDispatchThread();
-                      if (receiverConfigurationPanel.isDontWarnMeAgain()) {
-                          configURL = receiverConfigurationPanel.getModel().getSavedConfigToLoad();
-                      }
                   }
               } catch (Exception e2) {
                   MessageCenter.getInstance().getLogger().error(
@@ -1503,6 +1491,19 @@ public class LogUI extends JFrame implem
                     "An error occurred creating your Receiver");
               }
             }
+              if (configURL == null && receiverConfigurationPanel.isDontWarnMeAgain())
{
+                //use the saved config file as the config URL if defined
+                if (receiverConfigurationPanel.getModel().getSaveConfigFile() != null) {
+                  try {
+                    configURL = receiverConfigurationPanel.getModel().getSaveConfigFile().toURI().toURL();
+                  } catch (MalformedURLException e1) {
+                    e1.printStackTrace();
+                  }
+                } else {
+                  //no saved config defined but don't warn me is checked - use default config
+                  configURL = receiverConfigurationPanel.getModel().getDefaultConfigFileURL();
+                }
+              }
               if (configURL != null) {
                 MessageCenter.getInstance().getLogger().debug(
                   "Initialiazing Log4j with " + configURL.toExternalForm());

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java?rev=1031448&r1=1031447&r2=1031448&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/ReceiverConfigurationPanel.java
Fri Nov  5 06:19:59 2010
@@ -100,7 +100,6 @@ class ReceiverConfigurationPanel extends
     private JRadioButton logFileReceiverRadioButton;
     private JRadioButton networkReceiverRadioButton;
     private JRadioButton useExistingConfigurationRadioButton;
-    private JRadioButton useAutoSavedConfigRadioButton;
     private ButtonGroup buttonGroup;
 
     private JPanel lowerPanel;
@@ -157,15 +156,6 @@ class ReceiverConfigurationPanel extends
         c.gridx = 0;
         c.gridy = yPos++;
         c.fill = GridBagConstraints.HORIZONTAL;
-        c.insets = new Insets(0, 0, 0, 0);
-        useAutoSavedConfigRadioButton = new JRadioButton(" Use auto-saved configuration from
$HOME/.chainsaw/receiver-config.xml ");
-        buttonGroup.add(useAutoSavedConfigRadioButton);
-        add(useAutoSavedConfigRadioButton, c);
-
-        c = new GridBagConstraints();
-        c.gridx = 0;
-        c.gridy = yPos++;
-        c.fill = GridBagConstraints.HORIZONTAL;
         c.insets = new Insets(10, 10, 10, 0);
         add(lowerPanel, c);
         
@@ -197,7 +187,6 @@ class ReceiverConfigurationPanel extends
         logFileReceiverRadioButton.addActionListener(al);
         networkReceiverRadioButton.addActionListener(al);
         useExistingConfigurationRadioButton.addActionListener(al);
-        useAutoSavedConfigRadioButton.addActionListener(al);
 
         buttonGroup.setSelected(logFileReceiverRadioButton.getModel(), true);
         updateEnabledState(logFileReceiverRadioButton);
@@ -690,10 +679,6 @@ class ReceiverConfigurationPanel extends
             return !cancelled && useExistingConfigurationRadioButton.isSelected();
         }
 
-        boolean isLoadSavedConfigs() {
-            return !cancelled && useAutoSavedConfigRadioButton.isSelected();
-        }
-
         boolean isLogFileReceiverConfig() {
             return !cancelled && logFileReceiverRadioButton.isSelected();
         }
@@ -710,7 +695,7 @@ class ReceiverConfigurationPanel extends
             }
         }
 
-        URL getSavedConfigToLoad() {
+        URL getDefaultConfigFileURL() {
             try {
                 return file.toURI().toURL();
             } catch (MalformedURLException e) {

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java?rev=1031448&r1=1031447&r2=1031448&view=diff
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java
(original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/receivers/ReceiversPanel.java
Fri Nov  5 06:19:59 2010
@@ -97,6 +97,7 @@ public class ReceiversPanel extends JPan
   final Action pauseReceiverButtonAction;
   final Action playReceiverButtonAction;
   final Action shutdownReceiverButtonAction;
+  final Action saveReceiversButtonAction;
   final Action restartReceiverButtonAction;
   private final Action showReceiverHelpAction;
   private final Action startAllAction;
@@ -279,6 +280,25 @@ public class ReceiversPanel extends JPan
       Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_S));
 
     shutdownReceiverButtonAction.setEnabled(false);
+
+    saveReceiversButtonAction =
+      new AbstractAction() {
+          public void actionPerformed(ActionEvent e) {
+            saveReceivers();
+          }
+        };
+
+    saveReceiversButtonAction.putValue(
+      Action.SHORT_DESCRIPTION,
+      "Save the current receiver configuration");
+    saveReceiversButtonAction.putValue(Action.NAME, "Save receivers");
+
+    saveReceiversButtonAction.putValue(
+      Action.SMALL_ICON, new ImageIcon(ChainsawIcons.FILE_SAVE_AS));
+    saveReceiversButtonAction.putValue(
+      Action.MNEMONIC_KEY, new Integer(KeyEvent.VK_V));
+
+
     restartReceiverButtonAction =
         new AbstractAction() {
             public void actionPerformed(ActionEvent e) {
@@ -410,6 +430,13 @@ public class ReceiversPanel extends JPan
      }
   }
 
+  private void saveReceivers() {
+    File saveConfigFile = SwingHelper.promptForFile(this, null, "Save receiver configuration
XML file", false);
+    if (saveConfigFile != null) {
+      ReceiversHelper.getInstance().saveReceiverConfiguration(saveConfigFile);
+    }
+  }
+
   protected ReceiversTreeModel getReceiverTreeModel() {
     return ((ReceiversTreeModel) receiversTree.getModel());
   }
@@ -774,6 +801,8 @@ public class ReceiversPanel extends JPan
       add(pauseReceiverButtonAction);
       add(restartReceiverButtonAction);
       add(shutdownReceiverButtonAction);
+      add(saveReceiversButtonAction);
+
       addSeparator();
 
       final Receiver r = getCurrentlySelectedReceiver();
@@ -846,6 +875,10 @@ public class ReceiversPanel extends JPan
         new SmallButton(shutdownReceiverButtonAction);
       shutdownReceiverButton.setText(null);
 
+      SmallButton saveReceiversButton =
+        new SmallButton(saveReceiversButtonAction);
+      saveReceiversButton.setText(null);
+
       SmallButton restartAllButton = new SmallButton(startAllAction);
       restartAllButton.setText(null);
       
@@ -862,6 +895,7 @@ public class ReceiversPanel extends JPan
 
       add(restartReceiverButton);
       add(shutdownReceiverButton);
+      add(saveReceiversButton);
 
       addSeparator();
 



Mime
View raw message