You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rm...@apache.org on 2022/06/20 14:45:39 UTC

[logging-chainsaw] branch master updated (5f740bb -> 1db7981)

This is an automated email from the ASF dual-hosted git repository.

rmiddleton pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git


    from 5f740bb  Slightly update version
     new 94a4437  Comment out unused menu options for now
     new b2c8a61  Work on converting settings to commons configuration
     new a473f38  Toolbar/statusbar/receiver works
     new 1db7981  Updates to the configuration

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 pom.xml                                            |  10 +
 .../chainsaw/ApplicationPreferenceModelPanel.java  | 461 ++++++++++-----------
 .../log4j/chainsaw/ChainsawToolBarAndMenus.java    |  67 +--
 .../java/org/apache/log4j/chainsaw/FileMenu.java   |  18 +-
 .../java/org/apache/log4j/chainsaw/LogPanel.java   |  44 +-
 .../log4j/chainsaw/LogPanelPreferenceModel.java    |   2 +-
 src/main/java/org/apache/log4j/chainsaw/LogUI.java | 347 +++++++---------
 .../log4j/chainsaw/TableColorizingRenderer.java    |  17 +-
 .../apache/log4j/chainsaw/color/ColorPanel.java    |  24 +-
 .../apache/log4j/chainsaw/color/RuleColorizer.java |  19 +-
 .../log4j/chainsaw/prefs/ProfileManager.java       |   6 +-
 .../log4j/chainsaw/prefs/SettingsManager.java      | 365 +++++-----------
 .../apache/log4j/chainsaw/prefs/default.properties |   6 +-
 13 files changed, 588 insertions(+), 798 deletions(-)


[logging-chainsaw] 02/04: Work on converting settings to commons configuration

Posted by rm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rmiddleton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git

commit b2c8a61e7782edd8f85c2a653ef179be1d6f0dd4
Author: Robert Middleton <ro...@rm5248.com>
AuthorDate: Sun Jun 19 18:39:18 2022 -0400

    Work on converting settings to commons configuration
---
 pom.xml                                            |  10 +
 .../chainsaw/ApplicationPreferenceModelPanel.java  |   6 +-
 .../log4j/chainsaw/ChainsawToolBarAndMenus.java    |  70 +++--
 .../java/org/apache/log4j/chainsaw/LogPanel.java   |  44 +--
 .../log4j/chainsaw/LogPanelPreferenceModel.java    |   2 +-
 src/main/java/org/apache/log4j/chainsaw/LogUI.java | 330 ++++++++-----------
 .../log4j/chainsaw/TableColorizingRenderer.java    |  17 +-
 .../apache/log4j/chainsaw/color/ColorPanel.java    |  24 +-
 .../apache/log4j/chainsaw/color/RuleColorizer.java |  18 +-
 .../log4j/chainsaw/prefs/ProfileManager.java       |   6 +-
 .../log4j/chainsaw/prefs/SettingsManager.java      | 350 +++++----------------
 11 files changed, 324 insertions(+), 553 deletions(-)

diff --git a/pom.xml b/pom.xml
index 55fae10..22fadea 100644
--- a/pom.xml
+++ b/pom.xml
@@ -210,6 +210,16 @@
       <artifactId>genson</artifactId>
       <version>1.6</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-configuration2</artifactId>
+      <version>2.7</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-beanutils</groupId>
+      <artifactId>commons-beanutils</artifactId>
+      <version>1.9.4</version>
+     </dependency>
   </dependencies>
 
   <reporting>
diff --git a/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModelPanel.java b/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModelPanel.java
index 535aff3..9678a08 100644
--- a/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModelPanel.java
+++ b/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModelPanel.java
@@ -349,7 +349,7 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
         private void initComponents() {
             setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
 
-            configurationURL = new JComboBox<>(new DefaultComboBoxModel<>(committedPreferenceModel.getConfigurationURLs()));
+            configurationURL = new JComboBox(); //new JComboBox<>(new DefaultComboBoxModel<>(committedPreferenceModel.getConfigurationURLs()));
             configurationURL.setEditable(true);
             configurationURL.setPrototypeDisplayValue("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
             configurationURL.setPreferredSize(new Dimension(375, 13));
@@ -447,8 +447,8 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
                     return true;
                 }
             });
-            String configToDisplay = committedPreferenceModel.getBypassConfigurationURL() != null ? committedPreferenceModel.getBypassConfigurationURL() : committedPreferenceModel.getConfigurationURL();
-            configurationURL.setSelectedItem(configToDisplay);
+//            String configToDisplay = committedPreferenceModel.getBypassConfigurationURL() != null ? committedPreferenceModel.getBypassConfigurationURL() : committedPreferenceModel.getConfigurationURL();
+//            configurationURL.setSelectedItem(configToDisplay);
         }
 
         public void browseForConfiguration() {
diff --git a/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java b/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
index e23ea02..7fbeff3 100644
--- a/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
+++ b/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
@@ -32,6 +32,8 @@ import java.awt.event.KeyEvent;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
+import org.apache.commons.configuration2.AbstractConfiguration;
+import org.apache.log4j.chainsaw.prefs.SettingsManager;
 
 
 /**
@@ -130,20 +132,20 @@ class ChainsawToolBarAndMenus implements ChangeListener {
                 toggleLogTreeAction, toggleScrollToBottomAction, changeModelAction,
             };
 
-        logui.getApplicationPreferenceModel().addPropertyChangeListener(
-            "statusBar",
-            evt -> {
-                boolean value = (Boolean) evt.getNewValue();
-                toggleStatusBarCheck.setSelected(value);
-            });
-
-        logui.getApplicationPreferenceModel().addPropertyChangeListener(
-            "receivers",
-            evt -> {
-                boolean value = (Boolean) evt.getNewValue();
-                showReceiversButton.setSelected(value);
-                toggleShowReceiversCheck.setSelected(value);
-            });
+//        logui.getApplicationPreferenceModel().addPropertyChangeListener(
+//            "statusBar",
+//            evt -> {
+//                boolean value = (Boolean) evt.getNewValue();
+//                toggleStatusBarCheck.setSelected(value);
+//            });
+//
+//        logui.getApplicationPreferenceModel().addPropertyChangeListener(
+//            "receivers",
+//            evt -> {
+//                boolean value = (Boolean) evt.getNewValue();
+//                showReceiversButton.setSelected(value);
+//                toggleShowReceiversCheck.setSelected(value);
+//            });
     }
 
     /**
@@ -385,17 +387,18 @@ class ChainsawToolBarAndMenus implements ChangeListener {
 
         viewMenu.setMnemonic('V');
 
+        AbstractConfiguration configuration = SettingsManager.getInstance().getGlobalConfiguration();
+
         final JCheckBoxMenuItem showToolbarCheck =
             new JCheckBoxMenuItem(toggleToolbarAction);
-        showToolbarCheck.setSelected(
-            logui.getApplicationPreferenceModel().isToolbar());
-
-        logui.getApplicationPreferenceModel().addPropertyChangeListener(
-            "toolbar",
-            evt -> {
-                boolean value = (Boolean) evt.getNewValue();
-                showToolbarCheck.setSelected(value);
-            });
+        showToolbarCheck.setSelected(configuration.getBoolean("toolbar", true));
+
+//        logui.getApplicationPreferenceModel().addPropertyChangeListener(
+//            "toolbar",
+//            evt -> {
+//                boolean value = (Boolean) evt.getNewValue();
+//                showToolbarCheck.setSelected(value);
+//            });
 
         menuShowWelcome.setAction(toggleWelcomeVisibleAction);
 
@@ -436,8 +439,8 @@ class ChainsawToolBarAndMenus implements ChangeListener {
         final Action toggleStatusBarAction =
             new AbstractAction("Show Status bar") {
                 public void actionPerformed(ActionEvent arg0) {
-                    logui.getApplicationPreferenceModel().setStatusBar(
-                        toggleStatusBarCheck.isSelected());
+//                    logui.getApplicationPreferenceModel().setStatusBar(
+//                        toggleStatusBarCheck.isSelected());
                 }
             };
 
@@ -445,7 +448,7 @@ class ChainsawToolBarAndMenus implements ChangeListener {
             Action.MNEMONIC_KEY, KeyEvent.VK_B);
         toggleStatusBarCheck.setAction(toggleStatusBarAction);
         toggleStatusBarCheck.setSelected(
-            logui.getApplicationPreferenceModel().isStatusBar());
+            configuration.getBoolean("statusBar", true));
 
         activeTabMenu.add(pause);
         activeTabMenu.add(toggleCyclicMenuItem);
@@ -621,8 +624,8 @@ class ChainsawToolBarAndMenus implements ChangeListener {
         final Action action =
             new AbstractAction("Show Receivers") {
                 public void actionPerformed(ActionEvent arg0) {
-                    logui.getApplicationPreferenceModel().setReceivers(
-                        !logui.getApplicationPreferenceModel().isReceivers());
+//                    logui.getApplicationPreferenceModel().setReceivers(
+//                        !logui.getApplicationPreferenceModel().isReceivers());
                 }
             };
 
@@ -669,8 +672,8 @@ class ChainsawToolBarAndMenus implements ChangeListener {
         final Action action =
             new AbstractAction("Show Toolbar") {
                 public void actionPerformed(ActionEvent e) {
-                    logui.getApplicationPreferenceModel().setToolbar(
-                        !logui.getApplicationPreferenceModel().isToolbar());
+//                    logui.getApplicationPreferenceModel().setToolbar(
+//                        !logui.getApplicationPreferenceModel().isToolbar());
                 }
             };
 
@@ -780,9 +783,12 @@ class ChainsawToolBarAndMenus implements ChangeListener {
     }
 
     private void scanState() {
+        AbstractConfiguration configuration = SettingsManager.getInstance().getGlobalConfiguration();
+        boolean showReceiversByDefault = configuration.getBoolean("showReceivers", false);
+
         toggleStatusBarCheck.setSelected(logui.isStatusBarVisible());
         toggleShowReceiversCheck.setSelected(
-            logui.getApplicationPreferenceModel().isReceivers());
+            showReceiversByDefault);
 
         logTreePaneButton.setSelected(logui.isLogTreePanelVisible());
         LogPanel panel = logui.getCurrentLogPanel();
@@ -794,7 +800,7 @@ class ChainsawToolBarAndMenus implements ChangeListener {
             toggleDetailMenuItem.setSelected(false);
         }
         showReceiversButton.setSelected(
-            logui.getApplicationPreferenceModel().isReceivers());
+            showReceiversByDefault);
         menuShowWelcome.setSelected(logui.getTabbedPane().containsWelcomePanel());
 
         /**
diff --git a/src/main/java/org/apache/log4j/chainsaw/LogPanel.java b/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
index 348fdbf..b2cb46c 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LogPanel.java
@@ -528,27 +528,27 @@ public class LogPanel extends DockablePanel implements Profileable, ChainsawEven
                 menuItemToggleDetails.setSelected(value);
             });
 
-        applicationPreferenceModel.addPropertyChangeListener("searchColor", new PropertyChangeListener() {
-            public void propertyChange(PropertyChangeEvent evt) {
-                if (table != null) {
-                    table.repaint();
-                }
-                if (searchTable != null) {
-                    searchTable.repaint();
-                }
-            }
-        });
-
-        applicationPreferenceModel.addPropertyChangeListener("alternatingColor", new PropertyChangeListener() {
-            public void propertyChange(PropertyChangeEvent evt) {
-                if (table != null) {
-                    table.repaint();
-                }
-                if (searchTable != null) {
-                    searchTable.repaint();
-                }
-            }
-        });
+//        applicationPreferenceModel.addPropertyChangeListener("searchColor", new PropertyChangeListener() {
+//            public void propertyChange(PropertyChangeEvent evt) {
+//                if (table != null) {
+//                    table.repaint();
+//                }
+//                if (searchTable != null) {
+//                    searchTable.repaint();
+//                }
+//            }
+//        });
+//
+//        applicationPreferenceModel.addPropertyChangeListener("alternatingColor", new PropertyChangeListener() {
+//            public void propertyChange(PropertyChangeEvent evt) {
+//                if (table != null) {
+//                    table.repaint();
+//                }
+//                if (searchTable != null) {
+//                    searchTable.repaint();
+//                }
+//            }
+//        });
 
         /*
          *End of preferenceModel listeners
@@ -2133,7 +2133,7 @@ public class LogPanel extends DockablePanel implements Profileable, ChainsawEven
         }
 
         //no need to URL encode the identifier
-        colorizer.saveColorSettings(identifier);
+//        colorizer.saveColorSettings(identifier);
     }
 
     private XStream buildXStreamForLogPanelPreference() {
diff --git a/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java b/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
index c0844c2..f563ad9 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LogPanelPreferenceModel.java
@@ -43,7 +43,7 @@ public class LogPanelPreferenceModel implements Serializable {
     static {
         Collection list = new ArrayList();
 
-        Properties properties = SettingsManager.getInstance().getDefaultSettings();
+        Properties properties = new Properties(); //SettingsManager.getInstance().getDefaultSettings();
 
         for (Map.Entry<Object, Object> objectObjectEntry : properties.entrySet()) {
             Map.Entry<Object, Object> entry = objectObjectEntry;
diff --git a/src/main/java/org/apache/log4j/chainsaw/LogUI.java b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
index 806e1de..1283669 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LogUI.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
@@ -60,6 +60,7 @@ import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
+import org.apache.commons.configuration2.AbstractConfiguration;
 import org.apache.log4j.chainsaw.logevents.ChainsawLoggingEvent;
 import org.apache.log4j.chainsaw.zeroconf.ZeroConfPlugin;
 import org.apache.logging.log4j.core.LoggerContext;
@@ -82,7 +83,7 @@ import org.w3c.dom.Element;
  * @author Scott Deboy &lt;sdeboy@apache.org&gt;
  * @author Paul Smith  &lt;psmith@apache.org&gt;
  */
-public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
+public class LogUI extends JFrame {
     private static final String MAIN_WINDOW_HEIGHT = "main.window.height";
     private static final String MAIN_WINDOW_WIDTH = "main.window.width";
     private static final String MAIN_WINDOW_Y = "main.window.y";
@@ -206,26 +207,20 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
             System.setProperty("apple.laf.useScreenMenuBar", "true");
         }
 
-        final ApplicationPreferenceModel model = new ApplicationPreferenceModel();
-
-        SettingsManager.getInstance().configure(new ApplicationPreferenceModelSaver(model));
-        //if a configuration URL param was provided, set the configuration URL field to null
-        if (configurationURLAppArg != null) {
-            model.setBypassConfigurationURL(configurationURLAppArg);
-        }
+        AbstractConfiguration configuration = SettingsManager.getInstance().getGlobalConfiguration();
 
         EventQueue.invokeLater(() -> {
-            String lookAndFeelClassName = model.getLookAndFeelClassName();
+            String lookAndFeelClassName = configuration.getString("lookAndFeelClassName");
             if (lookAndFeelClassName == null || lookAndFeelClassName.trim().equals("")) {
                 String osName = System.getProperty("os.name");
                 if (osName.toLowerCase(Locale.ENGLISH).startsWith("mac")) {
                     //no need to assign look and feel
                 } else if (osName.toLowerCase(Locale.ENGLISH).startsWith("windows")) {
                     lookAndFeelClassName = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
-                    model.setLookAndFeelClassName(lookAndFeelClassName);
+                    configuration.setProperty("lookAndFeelClassName",lookAndFeelClassName);
                 } else if (osName.toLowerCase(Locale.ENGLISH).startsWith("linux")) {
                     lookAndFeelClassName = "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
-                    model.setLookAndFeelClassName(lookAndFeelClassName);
+                    configuration.setProperty("lookAndFeelClassName",lookAndFeelClassName);
                 }
             }
 
@@ -238,7 +233,7 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
                     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                 }catch(Exception ex){}
             }
-            createChainsawGUI(model, null);
+            createChainsawGUI(null);
         });
     }
 
@@ -250,10 +245,10 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
      * @param model
      * @param newShutdownAction DOCUMENT ME!
      */
-    public static void createChainsawGUI(
-        ApplicationPreferenceModel model, Action newShutdownAction) {
+    public static void createChainsawGUI(Action newShutdownAction) {
+        AbstractConfiguration config = SettingsManager.getInstance().getGlobalConfiguration();
 
-        if (model.isOkToRemoveSecurityManager()) {
+        if (config.getBoolean("okToRemoveSecurityManager", false)) {
 //            statusBar.setMessage("User has authorised removal of Java Security Manager via preferences");
             System.setSecurityManager(null);
             // this SHOULD set the Policy/Permission stuff for any
@@ -273,12 +268,11 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
         }
 
         final LogUI logUI = new LogUI();
-        logUI.applicationPreferenceModel = model;
 
-        if (model.isShowSplash()) {
+        if (config.getBoolean("slowSplash", true)) {
             showSplash(logUI);
         }
-        logUI.cyclicBufferSize = model.getCyclicBufferSize();
+        logUI.cyclicBufferSize = config.getInt("cyclicBufferSize", 50000);
 
         final LoggerContext ctx = (LoggerContext) org.apache.logging.log4j.LogManager.getContext(false);
         logUI.chainsawAppender = ctx.getConfiguration().getAppender("chainsaw");
@@ -297,46 +291,46 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
             logger.error("Uncaught exception in thread " + t, e);
         });
 
-        String config = configurationURLAppArg;
-        if (config != null) {
-            logger.info("Command-line configuration arg provided (overriding auto-configuration URL) - using: " + config);
-        } else {
-            config = model.getConfigurationURL();
-        }
-
-        if (config != null && (!config.trim().equals(""))) {
-            config = config.trim();
-            try {
-                URL configURL = new URL(config);
-                logger.info("Using '" + config + "' for auto-configuration");
-//                logUI.loadConfigurationUsingPluginClassLoader(configURL);
-            } catch (MalformedURLException e) {
-                logger.error("Initial configuration - failed to convert config string to url", e);
-            } catch (IOException e) {
-                logger.error("Unable to access auto-configuration URL: " + config);
-            }
-        }
+//        String config = configurationURLAppArg;
+//        if (config != null) {
+//            logger.info("Command-line configuration arg provided (overriding auto-configuration URL) - using: " + config);
+//        } else {
+//            config = model.getConfigurationURL();
+//        }
+
+//        if (config != null && (!config.trim().equals(""))) {
+//            config = config.trim();
+//            try {
+//                URL configURL = new URL(config);
+//                logger.info("Using '" + config + "' for auto-configuration");
+////                logUI.loadConfigurationUsingPluginClassLoader(configURL);
+//            } catch (MalformedURLException e) {
+//                logger.error("Initial configuration - failed to convert config string to url", e);
+//            } catch (IOException e) {
+//                logger.error("Unable to access auto-configuration URL: " + config);
+//            }
+//        }
 
         //register a listener to load the configuration when it changes (avoid having to restart Chainsaw when applying a new configuration)
         //this doesn't remove receivers from receivers panel, it just triggers DOMConfigurator.configure.
-        model.addPropertyChangeListener("configurationURL", evt -> {
-            String newConfiguration = evt.getNewValue().toString();
-            if (newConfiguration != null && !(newConfiguration.trim().equals(""))) {
-                newConfiguration = newConfiguration.trim();
-                try {
-                    logger.info("loading updated configuration: " + newConfiguration);
-                    URL newConfigurationURL = new URL(newConfiguration);
-                    File file = new File(newConfigurationURL.toURI());
-                    if (file.exists()) {
-//                        logUI.loadConfigurationUsingPluginClassLoader(newConfigurationURL);
-                    } else {
-                        logger.info("Updated configuration but file does not exist");
-                    }
-                } catch (MalformedURLException | URISyntaxException e) {
-                    logger.error("Updated configuration - failed to convert config string to URL", e);
-                }
-            }
-        });
+//        model.addPropertyChangeListener("configurationURL", evt -> {
+//            String newConfiguration = evt.getNewValue().toString();
+//            if (newConfiguration != null && !(newConfiguration.trim().equals(""))) {
+//                newConfiguration = newConfiguration.trim();
+//                try {
+//                    logger.info("loading updated configuration: " + newConfiguration);
+//                    URL newConfigurationURL = new URL(newConfiguration);
+//                    File file = new File(newConfigurationURL.toURI());
+//                    if (file.exists()) {
+////                        logUI.loadConfigurationUsingPluginClassLoader(newConfigurationURL);
+//                    } else {
+//                        logger.info("Updated configuration but file does not exist");
+//                    }
+//                } catch (MalformedURLException | URISyntaxException e) {
+//                    logger.error("Updated configuration - failed to convert config string to URL", e);
+//                }
+//            }
+//        });
 
         EventQueue.invokeLater(logUI::activateViewer);
         EventQueue.invokeLater(logUI::buildChainsawLogPanel);
@@ -355,41 +349,6 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
         }
     }
 
-    /**
-     * Allow Chainsaw v2 to be ran in-process (configured as a ChainsawAppender)
-     * NOTE: Closing Chainsaw will NOT stop the application generating the events.
-     *
-     * @param appender
-     */
-    public void activateViewer(ChainsawAppender appender) {
-
-        if (OSXIntegration.IS_OSX) {
-            System.setProperty("apple.laf.useScreenMenuBar", "true");
-        }
-
-        final ApplicationPreferenceModel model = new ApplicationPreferenceModel();
-        SettingsManager.getInstance().configure(new ApplicationPreferenceModelSaver(model));
-
-        cyclicBufferSize = model.getCyclicBufferSize();
-
-        setShutdownAction(
-            new AbstractAction() {
-                public void actionPerformed(ActionEvent e) {
-                }
-            });
-
-        applicationPreferenceModel = new ApplicationPreferenceModel();
-
-        SettingsManager.getInstance().configure(new ApplicationPreferenceModelSaver(model));
-
-        EventQueue.invokeLater(() -> {
-//            loadLookAndFeelUsingPluginClassLoader(model.getLookAndFeelClassName());
-            createChainsawGUI(model, null);
-            getApplicationPreferenceModel().apply(model);
-            activateViewer();
-        });
-    }
-
     /**
      * Initialises the menu's and toolbars, but does not actually create any of
      * the main panel components.
@@ -405,8 +364,8 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
         setJMenuBar(getToolBarAndMenus().getMenubar());
 
         setTabbedPane(new ChainsawTabbedPane());
-        getSettingsManager().addSettingsListener(getTabbedPane());
-        getSettingsManager().configure(getTabbedPane());
+//        getSettingsManager().addSettingsListener(getTabbedPane());
+//        getSettingsManager().configure(getTabbedPane());
 
         /**
          * This adds Drag & Drop capability to Chainsaw
@@ -458,10 +417,10 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
 
     private void setupReceiverPanel() {
         receiversPanel = new ReceiversPanel(this, statusBar);
-        receiversPanel.addPropertyChangeListener(
-            "visible",
-            evt -> getApplicationPreferenceModel().setReceivers(
-                (Boolean) evt.getNewValue()));
+//        receiversPanel.addPropertyChangeListener(
+//            "visible",
+//            evt -> getApplicationPreferenceModel().setReceivers(
+//                (Boolean) evt.getNewValue()));
     }
 
     /**
@@ -529,11 +488,12 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
      *
      * @param event DOCUMENT ME!
      */
-    public void loadSettings(LoadSettingsEvent event) {
+    private void loadSettings() {
+        AbstractConfiguration config = SettingsManager.getInstance().getGlobalConfiguration();
         setLocation(
-            event.asInt(LogUI.MAIN_WINDOW_X), event.asInt(LogUI.MAIN_WINDOW_Y));
-        int width = event.asInt(LogUI.MAIN_WINDOW_WIDTH);
-        int height = event.asInt(LogUI.MAIN_WINDOW_HEIGHT);
+            config.getInt(LogUI.MAIN_WINDOW_X, 0), config.getInt(LogUI.MAIN_WINDOW_Y, 0));
+        int width = config.getInt(LogUI.MAIN_WINDOW_WIDTH, -1);
+        int height = config.getInt(LogUI.MAIN_WINDOW_HEIGHT, -1);
         if (width == -1 && height == -1) {
             width = Toolkit.getDefaultToolkit().getScreenSize().width;
             height = Toolkit.getDefaultToolkit().getScreenSize().height;
@@ -547,27 +507,6 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
         RuleColorizer colorizer = new RuleColorizer();
         colorizer.loadColorSettings(ChainsawConstants.DEFAULT_COLOR_RULE_NAME);
         allColorizers.put(ChainsawConstants.DEFAULT_COLOR_RULE_NAME, colorizer);
-        if (event.getSetting("SavedConfig.logFormat") != null) {
-            receiverConfigurationPanel.getModel().setLogFormat(event.getSetting("SavedConfig.logFormat"));
-        }
-    }
-
-    /**
-     * Ensures the location/size of the main window is stored with the settings
-     *
-     * @param event DOCUMENT ME!
-     */
-    public void saveSettings(SaveSettingsEvent event) {
-        event.saveSetting(LogUI.MAIN_WINDOW_X, (int) getLocation().getX());
-        event.saveSetting(LogUI.MAIN_WINDOW_Y, (int) getLocation().getY());
-
-        event.saveSetting(LogUI.MAIN_WINDOW_WIDTH, getWidth());
-        event.saveSetting(LogUI.MAIN_WINDOW_HEIGHT, getHeight());
-        RuleColorizer colorizer = allColorizers.get(ChainsawConstants.DEFAULT_COLOR_RULE_NAME);
-        colorizer.saveColorSettings(ChainsawConstants.DEFAULT_COLOR_RULE_NAME);
-        if (receiverConfigurationPanel.getModel().getLogFormat() != null) {
-            event.saveSetting("SavedConfig.logFormat", receiverConfigurationPanel.getModel().getLogFormat());
-        }
     }
 
     public void buildChainsawLogPanel(){
@@ -582,6 +521,7 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
      */
     public void activateViewer() {
         initGUI();
+        loadSettings();
 
         initPrefModelListeners();
 
@@ -822,22 +762,22 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
 //                statusBar.setDataRate(dataRate);
 //            });
 
-        getSettingsManager().addSettingsListener(this);
-        getSettingsManager().addSettingsListener(MRUFileListPreferenceSaver.getInstance());
-        getSettingsManager().addSettingsListener(receiversPanel);
-        try {
-            //if an uncaught exception is thrown, allow the UI to continue to load
-            getSettingsManager().loadSettings();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
+//        getSettingsManager().addSettingsListener(this);
+//        getSettingsManager().addSettingsListener(MRUFileListPreferenceSaver.getInstance());
+//        getSettingsManager().addSettingsListener(receiversPanel);
+//        try {
+//            //if an uncaught exception is thrown, allow the UI to continue to load
+//            getSettingsManager().loadSettings();
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
         //app preferences have already been loaded (and configuration url possibly set to blank if being overridden)
         //but we need a listener so the settings will be saved on exit (added after loadsettings was called)
-        getSettingsManager().addSettingsListener(new ApplicationPreferenceModelSaver(applicationPreferenceModel));
+//        getSettingsManager().addSettingsListener(new ApplicationPreferenceModelSaver(applicationPreferenceModel));
 
         setVisible(true);
 
-        if (applicationPreferenceModel.isReceivers()) {
+        if (sm.getGlobalConfiguration().getBoolean("showReceivers", false)) {
             showReceiverPanel();
         } else {
             hideReceiverPanel();
@@ -852,7 +792,7 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
 
         if (
             noReceiversDefined
-                && applicationPreferenceModel.isShowNoReceiverWarning()) {
+                && sm.getGlobalConfiguration().getBoolean("showNoReceiverWarning", true)) {
             SwingHelper.invokeOnEDT(this::showReceiverConfigurationPanel);
         }
 
@@ -995,10 +935,10 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
          * hide those tabs out of currently loaded tabs..
          */
 
-        if (!getTabbedPane().tabSetting.isWelcome()) {
+        if (!sm.getGlobalConfiguration().getBoolean("displayWelcomeTab", true)) {
             displayPanel(ChainsawTabbedPane.WELCOME_TAB, false);
         }
-        if (!getTabbedPane().tabSetting.isZeroconf()) {
+        if (!sm.getGlobalConfiguration().getBoolean("displayZeroconfTab", true)) {
             displayPanel(ChainsawTabbedPane.ZEROCONF, false);
         }
         tbms.stateChange();
@@ -1039,13 +979,13 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
 //            evt -> handler.setIdentifierExpression(evt.getNewValue().toString()));
 //        handler.setIdentifierExpression(applicationPreferenceModel.getIdentifierExpression());
 
-
-        applicationPreferenceModel.addPropertyChangeListener(
-            "toolTipDisplayMillis",
-            evt -> ToolTipManager.sharedInstance().setDismissDelay(
-                (Integer) evt.getNewValue()));
+        int tooltipDisplayMillis = sm.getGlobalConfiguration().getInt("tooltipDisplayMillis", 4000);
+//        applicationPreferenceModel.addPropertyChangeListener(
+//            "toolTipDisplayMillis",
+//            evt -> ToolTipManager.sharedInstance().setDismissDelay(
+//                (Integer) evt.getNewValue()));
         ToolTipManager.sharedInstance().setDismissDelay(
-            applicationPreferenceModel.getToolTipDisplayMillis());
+            tooltipDisplayMillis);
 
 //        applicationPreferenceModel.addPropertyChangeListener(
 //            "responsiveness",
@@ -1055,57 +995,58 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
 //            });
 //        handler.setQueueInterval((applicationPreferenceModel.getResponsiveness() * 1000) - 750);
 
-        applicationPreferenceModel.addPropertyChangeListener(
-            "tabPlacement",
-            evt -> SwingUtilities.invokeLater(
-                () -> {
-                    int placement = (Integer) evt.getNewValue();
-
-                    switch (placement) {
-                        case SwingConstants.TOP:
-                        case SwingConstants.BOTTOM:
-                            tabbedPane.setTabPlacement(placement);
-
-                            break;
-
-                        default:
-                            break;
-                    }
-                }));
-
-        applicationPreferenceModel.addPropertyChangeListener(
-            "statusBar",
-            evt -> {
-                boolean value = (Boolean) evt.getNewValue();
-                setStatusBarVisible(value);
-            });
-        setStatusBarVisible(applicationPreferenceModel.isStatusBar());
-
-        applicationPreferenceModel.addPropertyChangeListener(
-            "receivers",
-            evt -> {
-                boolean value = (Boolean) evt.getNewValue();
-
-                if (value) {
-                    showReceiverPanel();
-                } else {
-                    hideReceiverPanel();
-                }
-            });
-//    if (applicationPreferenceModel.isReceivers()) {
-//      showReceiverPanel();
-//    } else {
-//      hideReceiverPanel();
-//    }
-
-
-        applicationPreferenceModel.addPropertyChangeListener(
-            "toolbar",
-            evt -> {
-                boolean value = (Boolean) evt.getNewValue();
-                toolbar.setVisible(value);
-            });
-        toolbar.setVisible(applicationPreferenceModel.isToolbar());
+//        applicationPreferenceModel.addPropertyChangeListener(
+//            "tabPlacement",
+//            evt -> SwingUtilities.invokeLater(
+//                () -> {
+//                    int placement = (Integer) evt.getNewValue();
+//
+//                    switch (placement) {
+//                        case SwingConstants.TOP:
+//                        case SwingConstants.BOTTOM:
+//                            tabbedPane.setTabPlacement(placement);
+//
+//                            break;
+//
+//                        default:
+//                            break;
+//                    }
+//                }));
+//
+//        applicationPreferenceModel.addPropertyChangeListener(
+//            "statusBar",
+//            evt -> {
+//                boolean value = (Boolean) evt.getNewValue();
+//                setStatusBarVisible(value);
+//            });
+//        setStatusBarVisible(applicationPreferenceModel.isStatusBar());
+//
+//        applicationPreferenceModel.addPropertyChangeListener(
+//            "receivers",
+//            evt -> {
+//                boolean value = (Boolean) evt.getNewValue();
+//
+//                if (value) {
+//                    showReceiverPanel();
+//                } else {
+//                    hideReceiverPanel();
+//                }
+//            });
+////    if (applicationPreferenceModel.isReceivers()) {
+////      showReceiverPanel();
+////    } else {
+////      hideReceiverPanel();
+////    }
+//
+//
+//        applicationPreferenceModel.addPropertyChangeListener(
+//            "toolbar",
+//            evt -> {
+//                boolean value = (Boolean) evt.getNewValue();
+//                toolbar.setVisible(value);
+//            });
+        boolean showToolbar = sm.getGlobalConfiguration().getBoolean("toolbar", true);
+        toolbar.setVisible(showToolbar);
 
     }
 
@@ -1292,7 +1233,7 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
      * Exits the application, ensuring Settings are saved.
      */
     public boolean exit() {
-        getSettingsManager().saveSettings();
+        getSettingsManager().saveAllSettings();
 
         return shutdown();
     }
@@ -1663,9 +1604,6 @@ public class LogUI extends JFrame implements ChainsawViewer, SettingsListener {
         throws IllegalArgumentException {
         final LogPanel thisPanel = new LogPanel(getStatusBar(), ident, cyclicBufferSize, allColorizers, applicationPreferenceModel);
 
-        getSettingsManager().addSettingsListener(thisPanel);
-        getSettingsManager().configure(thisPanel);
-
         if( !customExpression && rx != null ){
             thisPanel.setReceiver(rx);
         }
diff --git a/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java b/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
index aa110f5..964d6c7 100644
--- a/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
+++ b/src/main/java/org/apache/log4j/chainsaw/TableColorizingRenderer.java
@@ -39,6 +39,8 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 import java.util.TimeZone;
+import org.apache.commons.configuration2.AbstractConfiguration;
+import org.apache.log4j.chainsaw.prefs.SettingsManager;
 
 
 /**
@@ -402,14 +404,15 @@ public class TableColorizingRenderer extends DefaultTableCellRenderer {
         Color background;
         Color foreground;
         Rule loggerRule = colorizer.getLoggerRule();
+        AbstractConfiguration configuration = SettingsManager.getInstance().getGlobalConfiguration();
         //use logger colors in table instead of event colors if event passes logger rule
         if (loggerRule != null && loggerRule.evaluate(loggingEventWrapper.getLoggingEvent(), null)) {
-            background = applicationPreferenceModel.getSearchBackgroundColor();
-            foreground = applicationPreferenceModel.getSearchForegroundColor();
+            background = configuration.get(Color.class, "searchBackgroundColor", ChainsawConstants.FIND_LOGGER_BACKGROUND);
+            foreground = configuration.get(Color.class, "searchForegroundColor", ChainsawConstants.FIND_LOGGER_FOREGROUND);
         } else {
-            if (colorizeSearch && !applicationPreferenceModel.isBypassSearchColors()) {
-                background = loggingEventWrapper.isSearchMatch() ? applicationPreferenceModel.getSearchBackgroundColor() : loggingEventWrapper.getBackground();
-                foreground = loggingEventWrapper.isSearchMatch() ? applicationPreferenceModel.getSearchForegroundColor() : loggingEventWrapper.getForeground();
+            if (colorizeSearch && !configuration.getBoolean("bypassSearchColors", false)) {
+                background = loggingEventWrapper.isSearchMatch() ? configuration.get(Color.class, "searchBackgroundColor", ChainsawConstants.FIND_LOGGER_BACKGROUND) : loggingEventWrapper.getBackground();
+                foreground = loggingEventWrapper.isSearchMatch() ? configuration.get(Color.class, "searchForegroundColor", ChainsawConstants.FIND_LOGGER_FOREGROUND) : loggingEventWrapper.getForeground();
             } else {
                 background = loggingEventWrapper.getBackground();
                 foreground = loggingEventWrapper.getForeground();
@@ -420,8 +423,8 @@ public class TableColorizingRenderer extends DefaultTableCellRenderer {
          * Colourize background based on row striping if the event still has default foreground and background color
          */
         if (background.equals(ChainsawConstants.COLOR_DEFAULT_BACKGROUND) && foreground.equals(ChainsawConstants.COLOR_DEFAULT_FOREGROUND) && (row % 2) != 0) {
-            background = applicationPreferenceModel.getAlternatingColorBackgroundColor();
-            foreground = applicationPreferenceModel.getAlternatingColorForegroundColor();
+            background = configuration.get(Color.class, "alternatingColorBackground", ChainsawConstants.COLOR_ODD_ROW_BACKGROUND);
+            foreground = configuration.get(Color.class, "alternatingColorForeground", ChainsawConstants.COLOR_ODD_ROW_FOREGROUND);
         }
 
         component.setBackground(background);
diff --git a/src/main/java/org/apache/log4j/chainsaw/color/ColorPanel.java b/src/main/java/org/apache/log4j/chainsaw/color/ColorPanel.java
index 20de124..136c874 100644
--- a/src/main/java/org/apache/log4j/chainsaw/color/ColorPanel.java
+++ b/src/main/java/org/apache/log4j/chainsaw/color/ColorPanel.java
@@ -42,6 +42,8 @@ import java.util.List;
 import javax.swing.table.AbstractTableModel;
 import javax.swing.table.TableCellEditor;
 import javax.swing.table.TableModel;
+import org.apache.commons.configuration2.AbstractConfiguration;
+import org.apache.log4j.chainsaw.prefs.SettingsManager;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -90,6 +92,8 @@ public class ColorPanel extends JPanel {
                       final Map<String, RuleColorizer> allLogPanelColorizers, final ApplicationPreferenceModel applicationPreferenceModel) {
         super(new BorderLayout());
 
+        AbstractConfiguration configuration = SettingsManager.getInstance().getGlobalConfiguration();
+
         this.currentLogPanelColorizer = currentLogPanelColorizer;
         this.colorizer = currentLogPanelColorizer;
         this.filterModel = filterModel;
@@ -132,15 +136,15 @@ public class ColorPanel extends JPanel {
         //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());
+        searchDataVectorEntry.add(configuration.get(Color.class, "searchBackgroundColor", ChainsawConstants.FIND_LOGGER_BACKGROUND));
+        searchDataVectorEntry.add(configuration.get(Color.class, "searchForegroundColor", ChainsawConstants.FIND_LOGGER_FOREGROUND));
         searchDataVector.add(searchDataVectorEntry);
         searchTableModel.setDataVector(searchDataVector, searchColumns);
 
         alternatingColorDataVector = new Vector<>();
         alternatingColorDataVectorEntry = new Vector<>();
-        alternatingColorDataVectorEntry.add(applicationPreferenceModel.getAlternatingColorBackgroundColor());
-        alternatingColorDataVectorEntry.add(applicationPreferenceModel.getAlternatingColorForegroundColor());
+        alternatingColorDataVectorEntry.add(configuration.get(Color.class, "alternatingColorBackground", ChainsawConstants.COLOR_ODD_ROW_BACKGROUND));
+        alternatingColorDataVectorEntry.add(configuration.get(Color.class, "alternatingColorForeground", ChainsawConstants.COLOR_ODD_ROW_FOREGROUND));
         alternatingColorDataVector.add(alternatingColorDataVectorEntry);
         alternatingColorTableModel.setDataVector(alternatingColorDataVector, alternatingColorColumns);
 
@@ -189,7 +193,7 @@ public class ColorPanel extends JPanel {
         southPanel.add(Box.createVerticalStrut(5));
         JPanel searchAndAlternatingColorPanel = buildSearchAndAlternatingColorPanel();
         JPanel bypassSearchColorsPanel = buildBypassSearchColorsPanel();
-        bypassSearchColorsCheckBox.setSelected(applicationPreferenceModel.isBypassSearchColors());
+        bypassSearchColorsCheckBox.setSelected(configuration.getBoolean("bypassSearchColors", false));
 
         JPanel globalLabelPanel = new JPanel();
         globalLabelPanel.setLayout(new BoxLayout(globalLabelPanel, BoxLayout.X_AXIS));
@@ -267,11 +271,13 @@ public class ColorPanel extends JPanel {
                 logPanelColorizersModel.addElement(entry.getKey());
             }
         }
+
+        AbstractConfiguration configuration = SettingsManager.getInstance().getGlobalConfiguration();
         //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());
+        searchDataVectorEntry.set(0, configuration.get(Color.class, "searchBackgroundColor", ChainsawConstants.FIND_LOGGER_BACKGROUND));
+        searchDataVectorEntry.set(1, configuration.get(Color.class, "searchForegroundColor", ChainsawConstants.FIND_LOGGER_FOREGROUND));
+        alternatingColorDataVectorEntry.set(0, configuration.get(Color.class, "alternatingColorBackground", ChainsawConstants.COLOR_ODD_ROW_BACKGROUND));
+        alternatingColorDataVectorEntry.set(1, configuration.get(Color.class, "alternatingColorForeground", ChainsawConstants.COLOR_ODD_ROW_FOREGROUND));
     }
 
     public JPanel buildBypassSearchColorsPanel() {
diff --git a/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.java b/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.java
index 5626e89..cf982ec 100644
--- a/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.java
+++ b/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.java
@@ -30,6 +30,7 @@ import java.io.*;
 import java.net.URLEncoder;
 import java.util.*;
 import java.util.List;
+import org.apache.commons.configuration2.AbstractConfiguration;
 import org.apache.log4j.chainsaw.logevents.ChainsawLoggingEvent;
 
 
@@ -236,12 +237,19 @@ public class RuleColorizer implements Colorizer {
     }
 
     /**
-     * Load panel color settings if they exist - otherwise, load default color settings
+     * Load panel color settings if they exist from the given configuration - otherwise, load default color settings
      */
-    public void loadColorSettings(String name) {
-        if (!doLoadColorSettings(name)) {
-            doLoadColorSettings(ChainsawConstants.DEFAULT_COLOR_RULE_NAME);
-        }
+    public void loadColorSettings(String name){}
+    
+    public void loadColorSettings(AbstractConfiguration configuration) {
+        // When we save/load the rule, we really need to load a map of rules
+        // There's no real good way to do this, so we will do this the somewhat Qt-ish
+        // way and have a key that first tells us how many entries we need to read,
+        // and read the entries based off of their number
+//        configuration.getInt( "colors.", 0)
+//        if (!doLoadColorSettings(name)) {
+//            doLoadColorSettings(ChainsawConstants.DEFAULT_COLOR_RULE_NAME);
+//        }
     }
 
     private boolean doLoadColorSettings(String name) {
diff --git a/src/main/java/org/apache/log4j/chainsaw/prefs/ProfileManager.java b/src/main/java/org/apache/log4j/chainsaw/prefs/ProfileManager.java
index 0bfaa9f..0a01c3e 100644
--- a/src/main/java/org/apache/log4j/chainsaw/prefs/ProfileManager.java
+++ b/src/main/java/org/apache/log4j/chainsaw/prefs/ProfileManager.java
@@ -30,9 +30,9 @@ public class ProfileManager {
     }
 
     public void configure(Profileable p) {
-        Properties props = new Properties(SettingsManager.getInstance().getDefaultSettings());
-        LoadSettingsEvent event = new LoadSettingsEvent(this, props);
-        p.loadSettings(event);
+//        Properties props = new Properties(SettingsManager.getInstance().getDefaultSettings());
+//        LoadSettingsEvent event = new LoadSettingsEvent(this, props);
+//        p.loadSettings(event);
     }
 
     public void configure(Profileable p, String profileName) {
diff --git a/src/main/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java b/src/main/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java
index efbb373..a4a6357 100644
--- a/src/main/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java
+++ b/src/main/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java
@@ -20,7 +20,18 @@ import javax.swing.event.EventListenerList;
 import java.io.*;
 import java.net.URLEncoder;
 import java.util.EventListener;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.Properties;
+import org.apache.commons.configuration2.AbstractConfiguration;
+import org.apache.commons.configuration2.PropertiesConfiguration;
+import org.apache.commons.configuration2.builder.BasicConfigurationBuilder;
+import org.apache.commons.configuration2.builder.FileBasedConfigurationBuilder;
+import org.apache.commons.configuration2.builder.fluent.Parameters;
+import org.apache.commons.configuration2.convert.DefaultListDelimiterHandler;
+import org.apache.commons.configuration2.ex.ConfigurationException;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
 
 /**
@@ -33,318 +44,107 @@ import java.util.Properties;
 public final class SettingsManager {
     private static final SettingsManager instance = new SettingsManager();
     private static final String GLOBAL_SETTINGS_FILE_NAME = "chainsaw.settings.properties";
-    private static final String HEADER = "Chainsaws Settings Files";
-    private EventListenerList listenerList = new EventListenerList();
-    private Properties defaultProperties = new Properties();
+    private static final Logger logger = LogManager.getLogger();
+
+    private PropertiesConfiguration m_configuration;
+    private FileBasedConfigurationBuilder<PropertiesConfiguration> m_builder;
+    private Map<String,FileBasedConfigurationBuilder<PropertiesConfiguration>> m_tabSettings;
 
     /**
      * Initialises the SettingsManager by loading the default Properties from
      * a resource
      */
     private SettingsManager() {
-        //	load the default properties as a Resource
-        InputStream is = null;
-
-        try {
-            is = this.getClass().getClassLoader()
-                .getResource("org/apache/log4j/chainsaw/prefs/default.properties")
-                .openStream();
-            defaultProperties.load(is);
-
-            //      defaultProperties.list(System.out);
-            is.close();
-        } catch (IOException e) {
-            e.printStackTrace();
-        } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (Exception e) {
-                }
-            }
-        }
-    }
-
-    /**
-     * Returns the singleton instance of the SettingsManager
-     *
-     * @return settings manager
-     */
-    public static SettingsManager getInstance() {
-        return instance;
-    }
-
-    /**
-     * Registers the listener with the manager
-     *
-     * @param listener
-     */
-    public void addSettingsListener(SettingsListener listener) {
-        listenerList.add(SettingsListener.class, listener);
-    }
+        m_tabSettings = new HashMap<>();
+        Parameters params = new Parameters();
+        File f = new File(getSettingsDirectory(), GLOBAL_SETTINGS_FILE_NAME);
 
-    /**
-     * Requests that the settings be loaded, all listeners will be notified of
-     * this call, and configure themselves according to the values found in the
-     * loaded settings
-     */
-    public void loadSettings() {
-        /*
-         * Ok, note we ensure we have a .chainsaw directory in the users
-         * home folder, and create a chainsaw.settings.properties file..
-         */
         File settingsDir = getSettingsDirectory();
 
         if (!settingsDir.exists()) {
             settingsDir.mkdir();
         }
 
-        loadGlobalSettings();
-        loadProfileableSettings();
-    }
-
-    /**
-     *
-     */
-    private void loadProfileableSettings() {
-        EventListener[] listeners = listenerList.getListeners(SettingsListener.class);
-
-        for (EventListener listener : listeners) {
-            SettingsListener settingsListener = (SettingsListener) listener;
-
-            if (settingsListener instanceof Profileable) {
-                Profileable p = (Profileable) settingsListener;
-                loadProfileble(p);
-            }
+        m_builder =
+            new FileBasedConfigurationBuilder<PropertiesConfiguration>(
+                PropertiesConfiguration.class)
+                .configure(params.fileBased()
+                        .setListDelimiterHandler(
+                            new DefaultListDelimiterHandler(','))
+                        .setFile(f)
+                );
+
+
+        try{
+            PropertiesConfiguration config = m_builder.getConfiguration();
+            m_configuration = config;
+        }catch( ConfigurationException ex ){
+            logger.error( "Can't load properties??" );
         }
     }
 
-    private void loadProfileble(Profileable p) {
-        LoadSettingsEvent event = createProfilebleEvent(p);
-        p.loadSettings(event);
-    }
-
-    private LoadSettingsEvent createProfilebleEvent(Profileable p) {
-        Properties loadedProperties = new Properties();
-        loadedProperties.putAll(getDefaultSettings());
-        loadedProperties.putAll(loadProperties(p));
-
-
-        LoadSettingsEvent event = new LoadSettingsEvent(this, loadedProperties);
-
-        return event;
-    }
-
     /**
-     * @param p
-     * @return
+     * Returns the singleton instance of the SettingsManager
+     *
+     * @return settings manager
      */
-    private Properties loadProperties(Profileable p) {
-        Properties properties = new Properties(defaultProperties);
-        InputStream is = null;
-
-        File f = new File(getSettingsDirectory(),
-            URLEncoder.encode(p.getNamespace() + ".properties"));
-
-        if (!f.exists()) {
-            f = new File(getSettingsDirectory(),
-                p.getNamespace() + ".properties");
-        }
-
-        if (f.exists()) {
-            try {
-                is = new BufferedInputStream(new FileInputStream(f));
-
-                Properties toLoad = new Properties();
-                toLoad.load(is);
-                properties.putAll(toLoad);
-            } catch (IOException ioe) {
-                ioe.printStackTrace();
-            } finally {
-                if (is != null) {
-                    try {
-                        is.close();
-                    } catch (IOException e1) {
-                        e1.printStackTrace();
-                    }
-                }
-            }
-        }
-
-        return properties;
-    }
-
-    private void loadGlobalSettings() {
-        EventListener[] listeners = listenerList.getListeners(SettingsListener.class);
-        LoadSettingsEvent event = null;
-
-        for (EventListener listener : listeners) {
-            SettingsListener settingsListener = (SettingsListener) listener;
-
-            if (event == null) {
-                Properties loadedProperties = loadGlobalProperties();
-
-                //        loadedProperties.list(System.out);
-                event = new LoadSettingsEvent(this, loadedProperties);
-            }
-
-            settingsListener.loadSettings(event);
-        }
+    public static SettingsManager getInstance() {
+        return instance;
     }
 
-    /**
-     * Creates a SaveSettingsEvent and calls all the SettingsListeners
-     * to populate the properties with configuration information
-     */
-    public void saveSettings() {
-        /*
-         * Ok, note we ensure we have a .chainsaw directory in the users
-         * home folder, and create a chainsaw.settings.properties file..
-         */
-        File settingsDir = getSettingsDirectory();
-
-        if (!settingsDir.exists()) {
-            settingsDir.mkdir();
-        }
-
-        saveGlobalSettings(settingsDir);
-        saveProfileableSetting(settingsDir);
+    public AbstractConfiguration getGlobalConfiguration(){
+        return m_configuration;
     }
 
-    /**
-     * Looks up all the Profileable's that have been registered
-     * and creates a new event for each of them, and ensures that they
-     * are saved within a separate external store
-     *
-     * @param settingsDir
-     */
-    private void saveProfileableSetting(File settingsDir) {
-        EventListener[] listeners = listenerList.getListeners(SettingsListener.class);
-        SaveSettingsEvent event;
-
-        for (EventListener listener : listeners) {
-            SettingsListener settingsListener = (SettingsListener) listener;
-
-            if (settingsListener instanceof Profileable) {
-                Profileable profileable = (Profileable) settingsListener;
-                event = new SaveSettingsEvent(this, getSettingsDirectory());
+    public AbstractConfiguration getSettingsForReceiverTab(String identifier){
 
-                profileable.saveSettings(event);
+        PropertiesConfiguration configuration = null;
 
-                OutputStream os = null;
-
-                try {
-                    os = new BufferedOutputStream(new FileOutputStream(
-                        new File(settingsDir,
-                            URLEncoder.encode(profileable.getNamespace()) + ".properties")));
-                    event.getProperties().store(os, HEADER);
-                } catch (Exception e) {
-                    e.printStackTrace();
-                } finally {
-                    if (os != null) {
-                        try {
-                            os.close();
-                        } catch (IOException e1) {
-                            e1.printStackTrace();
-                        }
-                    }
-                }
-            }
+        if( m_tabSettings.containsKey( identifier ) ){
+            try{
+                return m_tabSettings.get( identifier ).getConfiguration();
+            }catch( ConfigurationException ex ){}
         }
-    }
-
-    private void saveGlobalSettings(File settingsDir) {
-        EventListener[] listeners = listenerList.getListeners(SettingsListener.class);
-        SaveSettingsEvent event = null;
-
-        for (EventListener listener : listeners) {
-            SettingsListener settingsListener = (SettingsListener) listener;
-
-            if (!(settingsListener instanceof Profileable)) {
-                if (event == null) {
-                    event = new SaveSettingsEvent(this, getSettingsDirectory());
-                }
 
-                settingsListener.saveSettings(event);
-            }
-        }
+        // Either we don't contain the key, or we got an exception.  Regardless,
+        // create a new configuration that we can use
+        Parameters params = new Parameters();
+        File f = new File(getSettingsDirectory(), identifier + "-receiver.properties");
+        FileBasedConfigurationBuilder<PropertiesConfiguration> builder =
+                new FileBasedConfigurationBuilder<PropertiesConfiguration>(
+                PropertiesConfiguration.class)
+                .configure(params.fileBased()
+                        .setListDelimiterHandler(
+                            new DefaultListDelimiterHandler(','))
+                        .setFile(f)
+                );
 
-        OutputStream os = null;
+        m_tabSettings.put( identifier, builder );
 
-        try {
-            os = new BufferedOutputStream(new FileOutputStream(
-                new File(settingsDir, GLOBAL_SETTINGS_FILE_NAME)));
-            event.getProperties().store(os, HEADER);
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            if (os != null) {
-                try {
-                    os.close();
-                } catch (IOException e1) {
-                    e1.printStackTrace();
-                }
-            }
-        }
+        try{
+            return builder.getConfiguration();
+        }catch( ConfigurationException ex ){}
+        
+        return null;
     }
 
     public File getSettingsDirectory() {
         return new File(System.getProperty("user.home"), ".chainsaw");
     }
 
-    public void configure(SettingsListener listener) {
-        if (listener instanceof Profileable) {
-            loadProfileble((Profileable) listener);
-        } else {
-            Properties loadedProperties = loadGlobalProperties();
-            LoadSettingsEvent event = new LoadSettingsEvent(this,
-                loadedProperties);
-            listener.loadSettings(event);
+    public void saveAllSettings(){
+        try{
+            m_builder.save();
+        }catch( ConfigurationException ex ){
+            logger.error( "Unable to save global settings: {}", ex );
         }
-    }
-
-    /**
-     * Returns the current Properties settings for this user
-     * by merging the default Properties with the ones we find in their directory.
-     *
-     * @return
-     */
-    private Properties loadGlobalProperties() {
-        Properties properties = new Properties(defaultProperties);
-        InputStream is = null;
-
-        File f = new File(getSettingsDirectory(), GLOBAL_SETTINGS_FILE_NAME);
-
-        if (f.exists()) {
-            try {
-                is = new BufferedInputStream(new FileInputStream(f));
 
-                Properties toLoad = new Properties();
-                toLoad.load(is);
-                properties.putAll(toLoad);
-            } catch (IOException ioe) {
-                ioe.printStackTrace();
-            } finally {
-                if (is != null) {
-                    try {
-                        is.close();
-                    } catch (IOException e1) {
-                        e1.printStackTrace();
-                    }
-                }
+        for( String key : m_tabSettings.keySet() ){
+            try{
+                m_tabSettings.get(key).save();
+            }catch( ConfigurationException ex ){
+                logger.error( "Unable to save settings for {}", key );
             }
         }
-
-        return properties;
-    }
-
-    /**
-     * Returns the loaded default settings, which can be used by
-     * other classes within this package.
-     *
-     * @return Properties defaults
-     */
-    public Properties getDefaultSettings() {
-        return defaultProperties;
     }
 }


[logging-chainsaw] 04/04: Updates to the configuration

Posted by rm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rmiddleton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git

commit 1db7981fe2d20f8f73caa9db033c567b4d1796cf
Author: Robert Middleton <ro...@rm5248.com>
AuthorDate: Mon Jun 20 10:45:31 2022 -0400

    Updates to the configuration
---
 .../chainsaw/ApplicationPreferenceModelPanel.java  | 443 ++++++++++-----------
 src/main/java/org/apache/log4j/chainsaw/LogUI.java |   2 +-
 .../log4j/chainsaw/prefs/SettingsManager.java      |  34 +-
 .../apache/log4j/chainsaw/prefs/default.properties |   6 +-
 4 files changed, 230 insertions(+), 255 deletions(-)

diff --git a/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModelPanel.java b/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModelPanel.java
index dc6439b..db37e38 100644
--- a/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModelPanel.java
+++ b/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModelPanel.java
@@ -44,72 +44,30 @@ import org.apache.log4j.chainsaw.prefs.SettingsManager;
  * @author Paul Smith &lt;psmith@apache.org&gt;
  */
 public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
-    private ApplicationPreferenceModel committedPreferenceModel;
-    private ApplicationPreferenceModel uncommittedPreferenceModel =
-        new ApplicationPreferenceModel();
+    private static final Logger logger = LogManager.getLogger();
+    
     private JTextField identifierExpression;
     private JTextField toolTipDisplayMillis;
     private JTextField cyclicBufferSize;
     private JComboBox<String> configurationURL;
-    private final Logger logger;
     private GeneralAllPrefPanel generalAllPrefPanel;
 
-    ApplicationPreferenceModelPanel(ApplicationPreferenceModel model) {
-        this.committedPreferenceModel = model;
-        logger = LogManager.getLogger(ApplicationPreferenceModelPanel.class);
+    ApplicationPreferenceModelPanel() {
         initComponents();
         getOkButton().addActionListener(
             e -> {
-                uncommittedPreferenceModel.setConfigurationURL((String) configurationURL.getSelectedItem());
-                uncommittedPreferenceModel.setIdentifierExpression(
-                    identifierExpression.getText());
-                try {
-                    int millis = Integer.parseInt(toolTipDisplayMillis.getText());
-                    if (millis >= 0) {
-                        uncommittedPreferenceModel.setToolTipDisplayMillis(millis);
-                    }
-                } catch (NumberFormatException nfe) {
-                }
-                try {
-                    int bufferSize = Integer.parseInt(cyclicBufferSize.getText());
-                    if (bufferSize >= 0) {
-                        uncommittedPreferenceModel.setCyclicBufferSize(bufferSize);
-                    }
-                } catch (NumberFormatException nfe) {
-                }
-                committedPreferenceModel.apply(uncommittedPreferenceModel);
+                SettingsManager.getInstance().saveGlobalSettings();
                 hidePanel();
             });
 
         getCancelButton().addActionListener(
             e -> {
-                uncommittedPreferenceModel.apply(committedPreferenceModel);
                 hidePanel();
             });
     }
 
+    public void updateModel(){
 
-    public static void main(String[] args) {
-        JFrame f = new JFrame("App Preferences Panel Test Bed");
-        ApplicationPreferenceModel model = new ApplicationPreferenceModel();
-        ApplicationPreferenceModelPanel panel =
-            new ApplicationPreferenceModelPanel(model);
-        f.getContentPane().add(panel);
-
-        model.addPropertyChangeListener(System.out::println);
-        panel.setOkCancelActionListener(
-            e -> System.exit(1));
-
-        f.setSize(640, 480);
-        f.setVisible(true);
-    }
-
-    /**
-     * Ensures this panels DISPLAYED model is in sync with
-     * the model initially passed to the constructor.
-     */
-    public void updateModel() {
-        this.uncommittedPreferenceModel.apply(committedPreferenceModel);
     }
 
     /* (non-Javadoc)
@@ -165,7 +123,7 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
 
             setupComponents();
             setupListeners();
-            setupInitialValues();
+            updateModel();
         }
 
         /**
@@ -175,9 +133,9 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
             final AbstractConfiguration config = SettingsManager.getInstance().getGlobalConfiguration();
 
             topPlacement.addActionListener(
-                e -> uncommittedPreferenceModel.setTabPlacement(SwingConstants.TOP));
+                e -> config.setProperty("tabPlacement", SwingConstants.TOP));
             bottomPlacement.addActionListener(
-                e -> uncommittedPreferenceModel.setTabPlacement(SwingConstants.BOTTOM));
+                e -> config.setProperty("tabPlacement", SwingConstants.BOTTOM));
 
             statusBar.addActionListener(
                 e -> config.setProperty("statusBar",statusBar.isSelected()));
@@ -188,45 +146,45 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
             receivers.addActionListener(
                 e -> config.setProperty("showReceivers",receivers.isSelected()));
 
-            uncommittedPreferenceModel.addPropertyChangeListener(
-                "tabPlacement",
-                evt -> {
-                    int value = (Integer) evt.getNewValue();
-
-                    configureTabPlacement(value);
-                });
-
-            uncommittedPreferenceModel.addPropertyChangeListener(
-                "statusBar",
-                evt -> statusBar.setSelected(
-                    (Boolean) evt.getNewValue()));
-
-            uncommittedPreferenceModel.addPropertyChangeListener(
-                "toolbar",
-                evt -> toolBar.setSelected((Boolean) evt.getNewValue()));
-
-            uncommittedPreferenceModel.addPropertyChangeListener(
-                "receivers",
-                evt -> receivers.setSelected(
-                    (Boolean) evt.getNewValue()));
-
-            uncommittedPreferenceModel.addPropertyChangeListener(
-                "lookAndFeelClassName",
-                evt -> {
-                    String lf = evt.getNewValue().toString();
-
-                    Enumeration enumeration = lookAndFeelGroup.getElements();
-
-                    while (enumeration.hasMoreElements()) {
-                        JRadioButton button = (JRadioButton) enumeration.nextElement();
-
-                        if (button.getName() != null && button.getName().equals(lf)) {
-                            button.setSelected(true);
-
-                            break;
-                        }
-                    }
-                });
+//            uncommittedPreferenceModel.addPropertyChangeListener(
+//                "tabPlacement",
+//                evt -> {
+//                    int value = (Integer) evt.getNewValue();
+//
+//                    configureTabPlacement(value);
+//                });
+//
+//            uncommittedPreferenceModel.addPropertyChangeListener(
+//                "statusBar",
+//                evt -> statusBar.setSelected(
+//                    (Boolean) evt.getNewValue()));
+//
+//            uncommittedPreferenceModel.addPropertyChangeListener(
+//                "toolbar",
+//                evt -> toolBar.setSelected((Boolean) evt.getNewValue()));
+//
+//            uncommittedPreferenceModel.addPropertyChangeListener(
+//                "receivers",
+//                evt -> receivers.setSelected(
+//                    (Boolean) evt.getNewValue()));
+//
+//            uncommittedPreferenceModel.addPropertyChangeListener(
+//                "lookAndFeelClassName",
+//                evt -> {
+//                    String lf = evt.getNewValue().toString();
+//
+//                    Enumeration enumeration = lookAndFeelGroup.getElements();
+//
+//                    while (enumeration.hasMoreElements()) {
+//                        JRadioButton button = (JRadioButton) enumeration.nextElement();
+//
+//                        if (button.getName() != null && button.getName().equals(lf)) {
+//                            button.setSelected(true);
+//
+//                            break;
+//                        }
+//                    }
+//                });
         }
 
         /**
@@ -265,12 +223,13 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
             JPanel lfPanel = new JPanel();
             lfPanel.setLayout(new BoxLayout(lfPanel, BoxLayout.Y_AXIS));
             lfPanel.setBorder(BorderFactory.createTitledBorder(" Look & Feel "));
+            final AbstractConfiguration configuration = SettingsManager.getInstance().getGlobalConfiguration();
 
             for (final UIManager.LookAndFeelInfo lfInfo : lookAndFeels) {
                 final JRadioButton lfItem = new JRadioButton(" " + lfInfo.getName() + " ");
                 lfItem.setName(lfInfo.getClassName());
                 lfItem.addActionListener(
-                    e -> uncommittedPreferenceModel.setLookAndFeelClassName(
+                    e -> configuration.setProperty("lookAndFeelClassName",
                         lfInfo.getClassName()));
                 lookAndFeelGroup.add(lfItem);
                 lfPanel.add(lfItem);
@@ -281,7 +240,7 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
                     Class.forName("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
                 final JRadioButton lfIGTK = new JRadioButton(" GTK+ 2.0 ");
                 lfIGTK.addActionListener(
-                    e -> uncommittedPreferenceModel.setLookAndFeelClassName(
+                    e -> configuration.setProperty("lookAndFeelClassName",
                         gtkLF.getName()));
                 lookAndFeelGroup.add(lfIGTK);
                 lfPanel.add(lfIGTK);
@@ -314,15 +273,17 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
             }
         }
 
-        private void setupInitialValues() {
-            statusBar.setSelected(uncommittedPreferenceModel.isStatusBar());
-            receivers.setSelected(uncommittedPreferenceModel.isReceivers());
-            toolBar.setSelected(uncommittedPreferenceModel.isToolbar());
-            configureTabPlacement(uncommittedPreferenceModel.getTabPlacement());
+        public void updateModel(){
+            AbstractConfiguration config = SettingsManager.getInstance().getGlobalConfiguration();
+
+            statusBar.setSelected(config.getBoolean("statusBar"));
+            receivers.setSelected(config.getBoolean("showReceivers"));
+            toolBar.setSelected(config.getBoolean("toolbar"));
+            configureTabPlacement(config.getInt("tabPlacement"));
             Enumeration e = lookAndFeelGroup.getElements();
             while (e.hasMoreElements()) {
                 JRadioButton radioButton = (JRadioButton) e.nextElement();
-                if (radioButton.getText().equals(uncommittedPreferenceModel.getLookAndFeelClassName())) {
+                if (radioButton.getText().equals(config.getString("lookAndFeelClassName"))) {
                     radioButton.setSelected(true);
                     break;
                 }
@@ -427,7 +388,7 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
             p6.add(configURLPanel);
 
             JButton browseButton = new JButton(" Open File... ");
-            browseButton.addActionListener(e -> browseForConfiguration());
+//            browseButton.addActionListener(e -> browseForConfiguration());
             Box browsePanel = new Box(BoxLayout.X_AXIS);
             browsePanel.add(Box.createHorizontalGlue());
             browsePanel.add(browseButton);
@@ -455,35 +416,35 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
 //            configurationURL.setSelectedItem(configToDisplay);
         }
 
-        public void browseForConfiguration() {
-            String defaultPath = ".";
-            if (configurationURL.getItemCount() > 0) {
-                Object selectedItem = configurationURL.getSelectedItem();
-                if (selectedItem != null) {
-                    File currentConfigurationPath = new File(selectedItem.toString()).getParentFile();
-                    if (currentConfigurationPath != null) {
-                        defaultPath = currentConfigurationPath.getPath();
-                        //FileDialog will not navigate to this location unless we remove the prefixing protocol and slash
-                        //at least on winxp
-                        if (defaultPath.toLowerCase(Locale.ENGLISH).startsWith("file:\\")) {
-                            defaultPath = defaultPath.substring("file:\\".length());
-                        }
-                    }
-                }
-            }
-            File selectedFile = SwingHelper.promptForFile(this, defaultPath, "Select a Chainsaw configuration file", true);
-            if (selectedFile != null) {
-                try {
-                    String newConfigurationFile = selectedFile.toURI().toURL().toExternalForm();
-                    if (!committedPreferenceModel.getConfigurationURLs().contains(newConfigurationFile)) {
-                        configurationURL.addItem(newConfigurationFile);
-                    }
-                    configurationURL.setSelectedItem(newConfigurationFile);
-                } catch (MalformedURLException e1) {
-                    e1.printStackTrace();
-                }
-            }
-        }
+//        public void browseForConfiguration() {
+//            String defaultPath = ".";
+//            if (configurationURL.getItemCount() > 0) {
+//                Object selectedItem = configurationURL.getSelectedItem();
+//                if (selectedItem != null) {
+//                    File currentConfigurationPath = new File(selectedItem.toString()).getParentFile();
+//                    if (currentConfigurationPath != null) {
+//                        defaultPath = currentConfigurationPath.getPath();
+//                        //FileDialog will not navigate to this location unless we remove the prefixing protocol and slash
+//                        //at least on winxp
+//                        if (defaultPath.toLowerCase(Locale.ENGLISH).startsWith("file:\\")) {
+//                            defaultPath = defaultPath.substring("file:\\".length());
+//                        }
+//                    }
+//                }
+//            }
+//            File selectedFile = SwingHelper.promptForFile(this, defaultPath, "Select a Chainsaw configuration file", true);
+//            if (selectedFile != null) {
+//                try {
+//                    String newConfigurationFile = selectedFile.toURI().toURL().toExternalForm();
+//                    if (!committedPreferenceModel.getConfigurationURLs().contains(newConfigurationFile)) {
+//                        configurationURL.addItem(newConfigurationFile);
+//                    }
+//                    configurationURL.setSelectedItem(newConfigurationFile);
+//                } catch (MalformedURLException e1) {
+//                    e1.printStackTrace();
+//                }
+//            }
+//        }
 
         private void initSliderComponent() {
             responsiveSlider.setToolTipText(
@@ -500,107 +461,107 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
         }
 
         private void setupListeners() {
-            uncommittedPreferenceModel.addPropertyChangeListener(
-                "showNoReceiverWarning",
-                evt -> showNoReceiverWarning.setSelected(
-                    (Boolean) evt.getNewValue()));
-
-            uncommittedPreferenceModel.addPropertyChangeListener("showSplash", evt -> {
-                boolean value = (Boolean) evt.getNewValue();
-                showSplash.setSelected(value);
-            });
-
-            uncommittedPreferenceModel.addPropertyChangeListener("okToRemoveSecurityManager", evt -> {
-                boolean newValue = (Boolean) evt.getNewValue();
-                if (newValue) {
-                    okToRemoveSecurityManager.setSelected(newValue);
-                } else {
-                    okToRemoveSecurityManager.setSelected(false);
-                }
-
-            });
-
-
-            uncommittedPreferenceModel.addPropertyChangeListener(
-                "identifierExpression",
-                evt -> identifierExpression.setText(evt.getNewValue().toString()));
-
-            uncommittedPreferenceModel.addPropertyChangeListener(
-                "responsiveness",
-                evt -> {
-                    int value = (Integer) evt.getNewValue();
-
-                    if (value >= 1000) {
-                        int newValue = (value - 750) / 1000;
-                        logger.debug(
-                            "Adjusting old Responsiveness value from " + value + " to "
-                                + newValue);
-                        value = newValue;
-                    }
-
-                    responsiveSlider.setValue(value);
-                });
-
-            uncommittedPreferenceModel.addPropertyChangeListener(
-                "toolTipDisplayMillis",
-                evt -> toolTipDisplayMillis.setText(evt.getNewValue().toString()));
-
-            uncommittedPreferenceModel.addPropertyChangeListener(
-                "cyclicBufferSize",
-                evt -> cyclicBufferSize.setText(evt.getNewValue().toString()));
-
-            showNoReceiverWarning.addActionListener(
-                e -> uncommittedPreferenceModel.setShowNoReceiverWarning(
-                    showNoReceiverWarning.isSelected()));
-
-            showSplash.addActionListener(e -> uncommittedPreferenceModel.setShowSplash(showSplash.isSelected()));
-
-            okToRemoveSecurityManager.addActionListener(e -> {
-
-                if (okToRemoveSecurityManager.isSelected() && JOptionPane.showConfirmDialog(okToRemoveSecurityManager, "By ticking this option, you are authorizing Chainsaw to remove Java's Security Manager.\n\n" +
-                    "This is required under Java Web Start so that it can access Jars/classes locally.  Without this, Receivers like JMSReceiver + DBReceiver that require" +
-                    " specific driver jars will NOT be able to be run.  \n\n" +
-                    "By ticking this, you are saying that this is ok.", "Please Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
-                    uncommittedPreferenceModel.setOkToRemoveSecurityManager(true);
-                } else {
-                    uncommittedPreferenceModel.setOkToRemoveSecurityManager(false);
-                }
-
-            });
-
-
-            responsiveSlider.getModel().addChangeListener(
-                e -> {
-                    if (responsiveSlider.getValueIsAdjusting()) {
-                        /**
-                         * We'll wait until it stops.
-                         */
-                    } else {
-                        int value = responsiveSlider.getValue();
-
-                        if (value == 0) {
-                            value = 1;
-                        }
-
-                        logger.debug("Adjust responsiveness to " + value);
-                        uncommittedPreferenceModel.setResponsiveness(value);
-                    }
-                });
-
-            uncommittedPreferenceModel.addPropertyChangeListener(
-                "confirmExit",
-                evt -> {
-                    boolean value = (Boolean) evt.getNewValue();
-                    confirmExit.setSelected(value);
-                });
-
-            uncommittedPreferenceModel.addPropertyChangeListener("configurationURL", evt -> {
-                String value = evt.getNewValue().toString();
-                configurationURL.setSelectedItem(value);
-            });
-            confirmExit.addActionListener(
-                e -> uncommittedPreferenceModel.setConfirmExit(
-                    confirmExit.isSelected()));
+//            uncommittedPreferenceModel.addPropertyChangeListener(
+//                "showNoReceiverWarning",
+//                evt -> showNoReceiverWarning.setSelected(
+//                    (Boolean) evt.getNewValue()));
+//
+//            uncommittedPreferenceModel.addPropertyChangeListener("showSplash", evt -> {
+//                boolean value = (Boolean) evt.getNewValue();
+//                showSplash.setSelected(value);
+//            });
+//
+//            uncommittedPreferenceModel.addPropertyChangeListener("okToRemoveSecurityManager", evt -> {
+//                boolean newValue = (Boolean) evt.getNewValue();
+//                if (newValue) {
+//                    okToRemoveSecurityManager.setSelected(newValue);
+//                } else {
+//                    okToRemoveSecurityManager.setSelected(false);
+//                }
+//
+//            });
+//
+//
+//            uncommittedPreferenceModel.addPropertyChangeListener(
+//                "identifierExpression",
+//                evt -> identifierExpression.setText(evt.getNewValue().toString()));
+//
+//            uncommittedPreferenceModel.addPropertyChangeListener(
+//                "responsiveness",
+//                evt -> {
+//                    int value = (Integer) evt.getNewValue();
+//
+//                    if (value >= 1000) {
+//                        int newValue = (value - 750) / 1000;
+//                        logger.debug(
+//                            "Adjusting old Responsiveness value from " + value + " to "
+//                                + newValue);
+//                        value = newValue;
+//                    }
+//
+//                    responsiveSlider.setValue(value);
+//                });
+//
+//            uncommittedPreferenceModel.addPropertyChangeListener(
+//                "toolTipDisplayMillis",
+//                evt -> toolTipDisplayMillis.setText(evt.getNewValue().toString()));
+//
+//            uncommittedPreferenceModel.addPropertyChangeListener(
+//                "cyclicBufferSize",
+//                evt -> cyclicBufferSize.setText(evt.getNewValue().toString()));
+//
+//            showNoReceiverWarning.addActionListener(
+//                e -> uncommittedPreferenceModel.setShowNoReceiverWarning(
+//                    showNoReceiverWarning.isSelected()));
+//
+//            showSplash.addActionListener(e -> uncommittedPreferenceModel.setShowSplash(showSplash.isSelected()));
+//
+//            okToRemoveSecurityManager.addActionListener(e -> {
+//
+//                if (okToRemoveSecurityManager.isSelected() && JOptionPane.showConfirmDialog(okToRemoveSecurityManager, "By ticking this option, you are authorizing Chainsaw to remove Java's Security Manager.\n\n" +
+//                    "This is required under Java Web Start so that it can access Jars/classes locally.  Without this, Receivers like JMSReceiver + DBReceiver that require" +
+//                    " specific driver jars will NOT be able to be run.  \n\n" +
+//                    "By ticking this, you are saying that this is ok.", "Please Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
+//                    uncommittedPreferenceModel.setOkToRemoveSecurityManager(true);
+//                } else {
+//                    uncommittedPreferenceModel.setOkToRemoveSecurityManager(false);
+//                }
+//
+//            });
+//
+//
+//            responsiveSlider.getModel().addChangeListener(
+//                e -> {
+//                    if (responsiveSlider.getValueIsAdjusting()) {
+//                        /**
+//                         * We'll wait until it stops.
+//                         */
+//                    } else {
+//                        int value = responsiveSlider.getValue();
+//
+//                        if (value == 0) {
+//                            value = 1;
+//                        }
+//
+//                        logger.debug("Adjust responsiveness to " + value);
+//                        uncommittedPreferenceModel.setResponsiveness(value);
+//                    }
+//                });
+//
+//            uncommittedPreferenceModel.addPropertyChangeListener(
+//                "confirmExit",
+//                evt -> {
+//                    boolean value = (Boolean) evt.getNewValue();
+//                    confirmExit.setSelected(value);
+//                });
+//
+//            uncommittedPreferenceModel.addPropertyChangeListener("configurationURL", evt -> {
+//                String value = evt.getNewValue().toString();
+//                configurationURL.setSelectedItem(value);
+//            });
+//            confirmExit.addActionListener(
+//                e -> uncommittedPreferenceModel.setConfirmExit(
+//                    confirmExit.isSelected()));
         }
 
         private void setupInitialValues() {
@@ -610,19 +571,19 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
             sliderLabelMap.put(4, new JLabel(" Slow "));
 
             //
-            showNoReceiverWarning.setSelected(
-                uncommittedPreferenceModel.isShowNoReceiverWarning());
-            identifierExpression.setText(
-                uncommittedPreferenceModel.getIdentifierExpression());
-
-            confirmExit.setSelected(uncommittedPreferenceModel.isConfirmExit());
-            okToRemoveSecurityManager.setSelected(uncommittedPreferenceModel.isOkToRemoveSecurityManager());
-            showNoReceiverWarning.setSelected(uncommittedPreferenceModel.isShowNoReceiverWarning());
-            showSplash.setSelected(uncommittedPreferenceModel.isShowSplash());
-            identifierExpression.setText(uncommittedPreferenceModel.getIdentifierExpression());
-            toolTipDisplayMillis.setText(uncommittedPreferenceModel.getToolTipDisplayMillis() + "");
-            cyclicBufferSize.setText(uncommittedPreferenceModel.getCyclicBufferSize() + "");
-            configurationURL.setSelectedItem(uncommittedPreferenceModel.getConfigurationURL());
+//            showNoReceiverWarning.setSelected(
+//                uncommittedPreferenceModel.isShowNoReceiverWarning());
+//            identifierExpression.setText(
+//                uncommittedPreferenceModel.getIdentifierExpression());
+//
+//            confirmExit.setSelected(uncommittedPreferenceModel.isConfirmExit());
+//            okToRemoveSecurityManager.setSelected(uncommittedPreferenceModel.isOkToRemoveSecurityManager());
+//            showNoReceiverWarning.setSelected(uncommittedPreferenceModel.isShowNoReceiverWarning());
+//            showSplash.setSelected(uncommittedPreferenceModel.isShowSplash());
+//            identifierExpression.setText(uncommittedPreferenceModel.getIdentifierExpression());
+//            toolTipDisplayMillis.setText(uncommittedPreferenceModel.getToolTipDisplayMillis() + "");
+//            cyclicBufferSize.setText(uncommittedPreferenceModel.getCyclicBufferSize() + "");
+//            configurationURL.setSelectedItem(uncommittedPreferenceModel.getConfigurationURL());
         }
     }
 }
diff --git a/src/main/java/org/apache/log4j/chainsaw/LogUI.java b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
index 2903ec2..d7382fb 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LogUI.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
@@ -398,7 +398,7 @@ public class LogUI extends JFrame {
 
         });
 
-        applicationPreferenceModelPanel = new ApplicationPreferenceModelPanel(applicationPreferenceModel);
+        applicationPreferenceModelPanel = new ApplicationPreferenceModelPanel();
 
         applicationPreferenceModelPanel.setOkCancelActionListener(
             e -> preferencesFrame.setVisible(false));
diff --git a/src/main/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java b/src/main/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java
index c844ade..9309aaf 100644
--- a/src/main/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java
+++ b/src/main/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java
@@ -18,6 +18,7 @@ package org.apache.log4j.chainsaw.prefs;
 
 import javax.swing.event.EventListenerList;
 import java.io.*;
+import java.net.URL;
 import java.net.URLEncoder;
 import java.util.EventListener;
 import java.util.HashMap;
@@ -65,33 +66,34 @@ public final class SettingsManager {
             settingsDir.mkdir();
         }
 
+        URL defaultPrefs = this.getClass().getClassLoader()
+                .getResource("org/apache/log4j/chainsaw/prefs/default.properties");
+
         m_builder =
             new FileBasedConfigurationBuilder<PropertiesConfiguration>(
                 PropertiesConfiguration.class)
                 .configure(params.fileBased()
-                        .setListDelimiterHandler(
-                            new DefaultListDelimiterHandler(','))
-                        .setFile(f)
+                        .setURL(defaultPrefs)
                 );
 
-
         try{
             PropertiesConfiguration config = m_builder.getConfiguration();
             m_configuration = config;
+            m_builder.getFileHandler().setFile(f);
             return;
         }catch( ConfigurationException ex ){
         }
 
         // If we get here, it is likely that we have not opened the file.
         // Force a save to create the file
-        try{
-            m_builder.save();
-            PropertiesConfiguration config = m_builder.getConfiguration();
-            m_configuration = config;
-            return;
-        }catch( ConfigurationException ex ){
-            ex.printStackTrace();
-        }
+//        try{
+//            m_builder.save();
+//            PropertiesConfiguration config = m_builder.getConfiguration();
+//            m_configuration = config;
+//            return;
+//        }catch( ConfigurationException ex ){
+//            ex.printStackTrace();
+//        }
     }
 
     /**
@@ -143,6 +145,14 @@ public final class SettingsManager {
         return new File(System.getProperty("user.home"), ".chainsaw");
     }
 
+    public void saveGlobalSettings(){
+        try{
+            m_builder.save();
+        }catch( ConfigurationException ex ){
+            logger.error( "Unable to save global settings: {}", ex );
+        }
+    }
+
     public void saveAllSettings(){
         try{
             m_builder.save();
diff --git a/src/main/resources/org/apache/log4j/chainsaw/prefs/default.properties b/src/main/resources/org/apache/log4j/chainsaw/prefs/default.properties
index 8035e50..302135c 100644
--- a/src/main/resources/org/apache/log4j/chainsaw/prefs/default.properties
+++ b/src/main/resources/org/apache/log4j/chainsaw/prefs/default.properties
@@ -31,8 +31,12 @@ table.columns.widths=50,80,95,50,100,500,100,100,100,100,100,100,100,100
 SavedConfigs.Size=0
 DateFormat.1=HH:mm:ss
 DateFormat.2=HH:mm
-identifierExpression=PROP.hostname - PROP.application
 
+tabPlacement=1
+statusBar=true
+toolbar=true
+showReceivers=false
+confirmExit=true
 
 # These are the default LogPanel settings
 dateFormatPattern=HH:mm:ss


[logging-chainsaw] 01/04: Comment out unused menu options for now

Posted by rm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rmiddleton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git

commit 94a4437434b069019fc4fb151228ef92945f99f7
Author: Robert Middleton <ro...@rm5248.com>
AuthorDate: Sat Jun 18 18:33:58 2022 -0400

    Comment out unused menu options for now
---
 src/main/java/org/apache/log4j/chainsaw/FileMenu.java | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/main/java/org/apache/log4j/chainsaw/FileMenu.java b/src/main/java/org/apache/log4j/chainsaw/FileMenu.java
index a170308..56d6c67 100644
--- a/src/main/java/org/apache/log4j/chainsaw/FileMenu.java
+++ b/src/main/java/org/apache/log4j/chainsaw/FileMenu.java
@@ -110,15 +110,15 @@ class FileMenu extends JMenu {
 
         JMenuItem menuItemExit = new JMenuItem(exitAction);
 
-        add(loadChainsawConfig);
-        add(loadLog4JFile);
-        add(loadUtilLoggingFile);
-        addSeparator();
-        add(remoteLog4JFile);
-        add(remoteUtilLoggingFile);
-        addSeparator();
-        add(saveFile);
-        addSeparator();
+//        add(loadChainsawConfig);
+//        add(loadLog4JFile);
+//        add(loadUtilLoggingFile);
+//        addSeparator();
+//        add(remoteLog4JFile);
+//        add(remoteUtilLoggingFile);
+//        addSeparator();
+//        add(saveFile);
+//        addSeparator();
 
         final JMenu mrulog4j = new JMenu("MRU...");
 


[logging-chainsaw] 03/04: Toolbar/statusbar/receiver works

Posted by rm...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rmiddleton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-chainsaw.git

commit a473f38b26a2ad9e32c222f2fcfcdf310fb9a1db
Author: Robert Middleton <ro...@rm5248.com>
AuthorDate: Mon Jun 20 10:00:16 2022 -0400

    Toolbar/statusbar/receiver works
---
 .../chainsaw/ApplicationPreferenceModelPanel.java  | 10 +++-
 .../log4j/chainsaw/ChainsawToolBarAndMenus.java    | 65 +++++++++++-----------
 src/main/java/org/apache/log4j/chainsaw/LogUI.java | 57 +++++++++++++------
 .../apache/log4j/chainsaw/color/RuleColorizer.java |  7 ++-
 .../log4j/chainsaw/prefs/SettingsManager.java      | 15 ++++-
 5 files changed, 99 insertions(+), 55 deletions(-)

diff --git a/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModelPanel.java b/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModelPanel.java
index 9678a08..dc6439b 100644
--- a/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModelPanel.java
+++ b/src/main/java/org/apache/log4j/chainsaw/ApplicationPreferenceModelPanel.java
@@ -34,6 +34,8 @@ import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Locale;
+import org.apache.commons.configuration2.AbstractConfiguration;
+import org.apache.log4j.chainsaw.prefs.SettingsManager;
 
 
 /**
@@ -170,19 +172,21 @@ public class ApplicationPreferenceModelPanel extends AbstractPreferencePanel {
          *
          */
         private void setupListeners() {
+            final AbstractConfiguration config = SettingsManager.getInstance().getGlobalConfiguration();
+
             topPlacement.addActionListener(
                 e -> uncommittedPreferenceModel.setTabPlacement(SwingConstants.TOP));
             bottomPlacement.addActionListener(
                 e -> uncommittedPreferenceModel.setTabPlacement(SwingConstants.BOTTOM));
 
             statusBar.addActionListener(
-                e -> uncommittedPreferenceModel.setStatusBar(statusBar.isSelected()));
+                e -> config.setProperty("statusBar",statusBar.isSelected()));
 
             toolBar.addActionListener(
-                e -> uncommittedPreferenceModel.setToolbar(toolBar.isSelected()));
+                e -> config.setProperty("toolbar",toolBar.isSelected()));
 
             receivers.addActionListener(
-                e -> uncommittedPreferenceModel.setReceivers(receivers.isSelected()));
+                e -> config.setProperty("showReceivers",receivers.isSelected()));
 
             uncommittedPreferenceModel.addPropertyChangeListener(
                 "tabPlacement",
diff --git a/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java b/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
index 7fbeff3..c8e3988 100644
--- a/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
+++ b/src/main/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
@@ -33,6 +33,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import org.apache.commons.configuration2.AbstractConfiguration;
+import org.apache.commons.configuration2.event.ConfigurationEvent;
 import org.apache.log4j.chainsaw.prefs.SettingsManager;
 
 
@@ -67,6 +68,8 @@ class ChainsawToolBarAndMenus implements ChangeListener {
     private final Collection lookAndFeelMenus = new ArrayList();
     private final JCheckBoxMenuItem toggleShowReceiversCheck =
         new JCheckBoxMenuItem();
+    private final JCheckBoxMenuItem toggleShowToolbarCheck =
+            new JCheckBoxMenuItem();
     private final JCheckBoxMenuItem toggleLogTreeMenuItem =
         new JCheckBoxMenuItem();
     private final JCheckBoxMenuItem toggleScrollToBottomMenuItem =
@@ -132,20 +135,22 @@ class ChainsawToolBarAndMenus implements ChangeListener {
                 toggleLogTreeAction, toggleScrollToBottomAction, changeModelAction,
             };
 
-//        logui.getApplicationPreferenceModel().addPropertyChangeListener(
-//            "statusBar",
-//            evt -> {
-//                boolean value = (Boolean) evt.getNewValue();
-//                toggleStatusBarCheck.setSelected(value);
-//            });
-//
-//        logui.getApplicationPreferenceModel().addPropertyChangeListener(
-//            "receivers",
-//            evt -> {
-//                boolean value = (Boolean) evt.getNewValue();
-//                showReceiversButton.setSelected(value);
-//                toggleShowReceiversCheck.setSelected(value);
-//            });
+            SettingsManager.getInstance().getGlobalConfiguration().addEventListener(ConfigurationEvent.SET_PROPERTY,
+            evt -> {
+                if( evt.getPropertyName().equals( "statusBar" ) ){
+                    boolean value = (Boolean) evt.getPropertyValue();
+                    toggleStatusBarCheck.setSelected(value);
+                }
+            });
+
+            SettingsManager.getInstance().getGlobalConfiguration().addEventListener(ConfigurationEvent.SET_PROPERTY,
+            evt -> {
+                if( evt.getPropertyName().equals( "showReceivers" ) ){
+                    boolean value = (Boolean) evt.getPropertyValue();
+                    showReceiversButton.setSelected(value);
+                    toggleShowReceiversCheck.setSelected(value);
+                }
+            });
     }
 
     /**
@@ -389,16 +394,8 @@ class ChainsawToolBarAndMenus implements ChangeListener {
 
         AbstractConfiguration configuration = SettingsManager.getInstance().getGlobalConfiguration();
 
-        final JCheckBoxMenuItem showToolbarCheck =
-            new JCheckBoxMenuItem(toggleToolbarAction);
-        showToolbarCheck.setSelected(configuration.getBoolean("toolbar", true));
-
-//        logui.getApplicationPreferenceModel().addPropertyChangeListener(
-//            "toolbar",
-//            evt -> {
-//                boolean value = (Boolean) evt.getNewValue();
-//                showToolbarCheck.setSelected(value);
-//            });
+        toggleShowToolbarCheck.setAction(toggleToolbarAction);
+        toggleShowToolbarCheck.setSelected(configuration.getBoolean("toolbar", true));
 
         menuShowWelcome.setAction(toggleWelcomeVisibleAction);
 
@@ -439,8 +436,9 @@ class ChainsawToolBarAndMenus implements ChangeListener {
         final Action toggleStatusBarAction =
             new AbstractAction("Show Status bar") {
                 public void actionPerformed(ActionEvent arg0) {
-//                    logui.getApplicationPreferenceModel().setStatusBar(
-//                        toggleStatusBarCheck.isSelected());
+                    boolean isSelected = toggleStatusBarCheck.isSelected();
+                    SettingsManager.getInstance().getGlobalConfiguration()
+                            .setProperty("statusBar", isSelected);
                 }
             };
 
@@ -478,7 +476,7 @@ class ChainsawToolBarAndMenus implements ChangeListener {
         activeTabMenu.add(toggleScrollToBottomMenuItem);
         activeTabMenu.add(menuItemUseRightMouse);
 
-        viewMenu.add(showToolbarCheck);
+        viewMenu.add(toggleShowToolbarCheck);
         viewMenu.add(toggleStatusBarCheck);
         viewMenu.add(toggleShowReceiversCheck);
         viewMenu.add(menuShowWelcome);
@@ -624,8 +622,12 @@ class ChainsawToolBarAndMenus implements ChangeListener {
         final Action action =
             new AbstractAction("Show Receivers") {
                 public void actionPerformed(ActionEvent arg0) {
-//                    logui.getApplicationPreferenceModel().setReceivers(
-//                        !logui.getApplicationPreferenceModel().isReceivers());
+                    // Since this action can be triggered from either a button
+                    // or a check box, get the current value and invert it.
+                    boolean currentValue = SettingsManager.getInstance().getGlobalConfiguration()
+                            .getBoolean("showReceivers", false);
+                    SettingsManager.getInstance().getGlobalConfiguration()
+                            .setProperty("showReceivers", !currentValue);
                 }
             };
 
@@ -672,8 +674,9 @@ class ChainsawToolBarAndMenus implements ChangeListener {
         final Action action =
             new AbstractAction("Show Toolbar") {
                 public void actionPerformed(ActionEvent e) {
-//                    logui.getApplicationPreferenceModel().setToolbar(
-//                        !logui.getApplicationPreferenceModel().isToolbar());
+                    boolean isSelected = toggleShowToolbarCheck.isSelected();
+                    SettingsManager.getInstance().getGlobalConfiguration()
+                            .setProperty("toolbar", isSelected);
                 }
             };
 
diff --git a/src/main/java/org/apache/log4j/chainsaw/LogUI.java b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
index 1283669..2903ec2 100644
--- a/src/main/java/org/apache/log4j/chainsaw/LogUI.java
+++ b/src/main/java/org/apache/log4j/chainsaw/LogUI.java
@@ -61,6 +61,7 @@ import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 import org.apache.commons.configuration2.AbstractConfiguration;
+import org.apache.commons.configuration2.event.ConfigurationEvent;
 import org.apache.log4j.chainsaw.logevents.ChainsawLoggingEvent;
 import org.apache.log4j.chainsaw.zeroconf.ZeroConfPlugin;
 import org.apache.logging.log4j.core.LoggerContext;
@@ -523,8 +524,6 @@ public class LogUI extends JFrame {
         initGUI();
         loadSettings();
 
-        initPrefModelListeners();
-
         if (m_receivers.size() == 0) {
             noReceiversDefined = true;
         }
@@ -755,6 +754,9 @@ public class LogUI extends JFrame {
         final PopupListener tabPopupListener = new PopupListener(tabPopup);
         getTabbedPane().addMouseListener(tabPopupListener);
 
+
+        initPrefModelListeners();
+
 //        this.handler.addPropertyChangeListener(
 //            "dataRate",
 //            evt -> {
@@ -1013,13 +1015,34 @@ public class LogUI extends JFrame {
 //                    }
 //                }));
 //
-//        applicationPreferenceModel.addPropertyChangeListener(
-//            "statusBar",
-//            evt -> {
-//                boolean value = (Boolean) evt.getNewValue();
-//                setStatusBarVisible(value);
-//            });
-//        setStatusBarVisible(applicationPreferenceModel.isStatusBar());
+        sm.getGlobalConfiguration().addEventListener(ConfigurationEvent.SET_PROPERTY,
+            evt -> {
+                if( evt.getPropertyName().equals( "statusBar" ) ){
+                    boolean value = (Boolean) evt.getPropertyValue();
+                    statusBar.setVisible(value);
+                }
+            });
+        boolean showStatusBar = sm.getGlobalConfiguration().getBoolean("statusBar", true);
+        setStatusBarVisible(showStatusBar);
+
+        sm.getGlobalConfiguration().addEventListener(ConfigurationEvent.SET_PROPERTY,
+            evt -> {
+                if( evt.getPropertyName().equals( "showReceivers" ) ){
+                    boolean value = (Boolean) evt.getPropertyValue();
+                    if( value ){
+                        showReceiverPanel();
+                    }else{
+                        hideReceiverPanel();
+                    }
+                }
+            });
+        boolean showReceivers = sm.getGlobalConfiguration().getBoolean("showReceivers", false);
+        setStatusBarVisible(showStatusBar);
+        if( showReceivers ){
+            showReceiverPanel();
+        }else{
+            hideReceiverPanel();
+        }
 //
 //        applicationPreferenceModel.addPropertyChangeListener(
 //            "receivers",
@@ -1039,12 +1062,13 @@ public class LogUI extends JFrame {
 ////    }
 //
 //
-//        applicationPreferenceModel.addPropertyChangeListener(
-//            "toolbar",
-//            evt -> {
-//                boolean value = (Boolean) evt.getNewValue();
-//                toolbar.setVisible(value);
-//            });
+        sm.getGlobalConfiguration().addEventListener(ConfigurationEvent.SET_PROPERTY,
+            evt -> {
+                if( evt.getPropertyName().equals( "toolbar" ) ){
+                    boolean value = (Boolean) evt.getPropertyValue();
+                    toolbar.setVisible(value);
+                }
+            });
         boolean showToolbar = sm.getGlobalConfiguration().getBoolean("toolbar", true);
         toolbar.setVisible(showToolbar);
 
@@ -1310,7 +1334,8 @@ public class LogUI extends JFrame {
      * Shutsdown by ensuring the Appender gets a chance to close.
      */
     public boolean shutdown() {
-        if (getApplicationPreferenceModel().isConfirmExit()) {
+        boolean confirmExit = sm.getGlobalConfiguration().getBoolean("confirmExit", true);
+        if (confirmExit) {
             if (
                 JOptionPane.showConfirmDialog(
                     LogUI.this, "Are you sure you want to exit Chainsaw?",
diff --git a/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.java b/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.java
index cf982ec..4965cdc 100644
--- a/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.java
+++ b/src/main/java/org/apache/log4j/chainsaw/color/RuleColorizer.java
@@ -243,9 +243,10 @@ public class RuleColorizer implements Colorizer {
     
     public void loadColorSettings(AbstractConfiguration configuration) {
         // When we save/load the rule, we really need to load a map of rules
-        // There's no real good way to do this, so we will do this the somewhat Qt-ish
-        // way and have a key that first tells us how many entries we need to read,
-        // and read the entries based off of their number
+        // There's no real good way to do this, so we will do this the somewhat
+        // dumb way and just load up to 32 color rules, since that seems like
+        // a good number
+//        configuration.get
 //        configuration.getInt( "colors.", 0)
 //        if (!doLoadColorSettings(name)) {
 //            doLoadColorSettings(ChainsawConstants.DEFAULT_COLOR_RULE_NAME);
diff --git a/src/main/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java b/src/main/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java
index a4a6357..c844ade 100644
--- a/src/main/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java
+++ b/src/main/java/org/apache/log4j/chainsaw/prefs/SettingsManager.java
@@ -42,9 +42,9 @@ import org.apache.logging.log4j.Logger;
  * @author Scott Deboy &lt;sdeboy@apache.org&gt;
  */
 public final class SettingsManager {
+    private static final Logger logger = LogManager.getLogger();
     private static final SettingsManager instance = new SettingsManager();
     private static final String GLOBAL_SETTINGS_FILE_NAME = "chainsaw.settings.properties";
-    private static final Logger logger = LogManager.getLogger();
 
     private PropertiesConfiguration m_configuration;
     private FileBasedConfigurationBuilder<PropertiesConfiguration> m_builder;
@@ -78,8 +78,19 @@ public final class SettingsManager {
         try{
             PropertiesConfiguration config = m_builder.getConfiguration();
             m_configuration = config;
+            return;
+        }catch( ConfigurationException ex ){
+        }
+
+        // If we get here, it is likely that we have not opened the file.
+        // Force a save to create the file
+        try{
+            m_builder.save();
+            PropertiesConfiguration config = m_builder.getConfiguration();
+            m_configuration = config;
+            return;
         }catch( ConfigurationException ex ){
-            logger.error( "Can't load properties??" );
+            ex.printStackTrace();
         }
     }