logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sde...@apache.org
Subject svn commit: r996779 - in /logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw: ApplicationPreferenceModel.java LogUI.java ReceiverConfigurationPanel.java
Date Tue, 14 Sep 2010 07:51:36 GMT
Author: sdeboy
Date: Tue Sep 14 07:51:36 2010
New Revision: 996779

URL: http://svn.apache.org/viewvc?rev=996779&view=rev
Log:
Minor fixes to configuration load process
 - The 'always start Chainsaw with this configuration' checkbox stops all plugins (except
zeroconf) and loads the requested configuration
 - If 'always start' isn't checked, the new configuration plugins will be activated along
with the currently-active plugins

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

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=996779&r1=996778&r2=996779&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
Tue Sep 14 07:51:36 2010
@@ -30,7 +30,7 @@ import java.util.Vector;
  */
 public class ApplicationPreferenceModel {
 
-    private boolean showNoReceiverWarning = true ;
+    private boolean showNoReceiverWarning = false ;
     private boolean statusBar = true;
     private boolean toolbar = true;
     private boolean receivers = false; //setting this to true will cause the receivers panel
to be displayed by default

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=996779&r1=996778&r2=996779&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 Tue Sep 14 07:51:36
2010
@@ -41,6 +41,7 @@ import java.io.IOException;
 import java.lang.Thread.UncaughtExceptionHandler;
 import java.lang.reflect.Method;
 import java.net.MalformedURLException;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.security.AllPermission;
 import java.security.CodeSource;
@@ -419,10 +420,19 @@ public class LogUI extends JFrame implem
                 try {
                     logger.info("loading updated configuration: " + newConfiguration);
                     URL newConfigurationURL = new URL(newConfiguration);
-                    logUI.loadConfigurationUsingPluginClassLoader(newConfigurationURL);
+                    File file = new File(newConfigurationURL.toURI());
+                    if (file.exists()) {
+                        logUI.loadConfigurationUsingPluginClassLoader(newConfigurationURL);
+                    } else {
+                        logger.info("Updated configuration but file does not exist");
+                    }
                 } catch (MalformedURLException e) {
                     logger.error("Updated configuration - failed to convert config string
to URL", e);
                 }
+                catch (URISyntaxException e)
+                {
+                    logger.error("Updated configuration - failed to convert config string
to URL", e);
+                }
             }
         }});
 
@@ -1466,6 +1476,17 @@ public class LogUI extends JFrame implem
 
           dialog.setVisible(true);
           applicationPreferenceModel.setShowNoReceiverWarning(!receiverConfigurationPanel.isDontWarnMeAgain());
+          //using this config next time - stop all plugins
+          if (receiverConfigurationPanel.isDontWarnMeAgain()) {
+              List plugins = pluginRegistry.getPlugins();
+              for (Iterator iter = plugins.iterator();iter.hasNext();) {
+                  Plugin plugin = (Plugin)iter.next();
+                  //don't stop ZeroConfPlugin if it is registered
+                  if (!plugin.getName().toLowerCase().contains("zeroconf")) {
+                    pluginRegistry.stopPlugin(plugin.getName());
+                  }
+              }
+          }
           URL configURL = null;
 
           if (receiverConfigurationPanel.getModel().isNetworkReceiverMode()) {
@@ -1487,6 +1508,10 @@ 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 e) {
               MessageCenter.getInstance().getLogger().error(
                 "Error creating Receiver", e);
@@ -1522,6 +1547,9 @@ public class LogUI extends JFrame implem
                     pluginRegistry.addPlugin(fileReceiver);
                     fileReceiver.activateOptions();
                     receiversPanel.updateReceiverTreeInDispatchThread();
+                    if (receiverConfigurationPanel.isDontWarnMeAgain()) {
+                        configURL = receiverConfigurationPanel.getModel().getSavedConfigToLoad();
+                    }
                 }
             } catch (Exception e) {
                 MessageCenter.getInstance().getLogger().error(
@@ -1540,7 +1568,14 @@ public class LogUI extends JFrame implem
                     if (receiverConfigurationPanel.isDontWarnMeAgain()) {
                         applicationPreferenceModel.setConfigurationURL(finalURL.toExternalForm());
                     } else {
-                        loadConfigurationUsingPluginClassLoader(finalURL);
+                        try {
+                            if (new File(finalURL.toURI()).exists()) {
+                                loadConfigurationUsingPluginClassLoader(finalURL);
+                            }
+                        }
+                        catch (URISyntaxException e) {
+                            //ignore
+                        }
                     }
 
                     receiversPanel.updateReceiverTreeInDispatchThread();

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=996779&r1=996778&r2=996779&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
Tue Sep 14 07:51:36 2010
@@ -470,8 +470,7 @@ class ReceiverConfigurationPanel extends
                             URL url = browseConfig();
 
                             if (url != null) {
-                                getModel().configUrl = url;
-                                existingConfigurationComboBoxModel.addElement(url);
+                                existingConfigurationComboBoxModel.addElement(url.toExternalForm());
                                 existingConfigurationComboBox.getModel().setSelectedItem(
                                     url);
                             }
@@ -631,7 +630,6 @@ class ReceiverConfigurationPanel extends
      */
     class PanelModel {
 
-        private URL configUrl;
         private File file;
         private boolean cancelled;
 
@@ -692,16 +690,19 @@ class ReceiverConfigurationPanel extends
 
         URL getConfigToLoad() {
 
-            return configUrl;
+            try
+            {
+                return new URL(existingConfigurationComboBoxModel.getSelectedItem().toString());
+            }
+            catch (MalformedURLException e)
+            {
+                return null;
+            }
         }
 
         URL getSavedConfigToLoad() {
             try {
-                if (file.exists()){
-                    return file.toURL();
-                } else {
-                    logger.debug("No configuration file found");
-                }
+                return file.toURI().toURL();
             } catch (MalformedURLException e) {
                 logger.error("Error loading saved configurations by Chainsaw", e);
             }



Mime
View raw message