You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gr...@apache.org on 2023/12/17 19:05:48 UTC

(logging-chainsaw) branch master updated (53367f5 -> d907e4e)

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

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


    from 53367f5  grouped show/display methods
     new 25de107  reordered methods
     new d907e4e  tidying

The 2 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:
 .../org/apache/log4j/chainsaw/logui/LogUI.java     | 155 +++++++++++----------
 1 file changed, 78 insertions(+), 77 deletions(-)


(logging-chainsaw) 02/02: tidying

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

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

commit d907e4e63addf722b36439b90d7c12580d7f24e7
Author: Christian Grobmeier <cg...@grobmeier.de>
AuthorDate: Sun Dec 17 20:05:43 2023 +0100

    tidying
---
 .../org/apache/log4j/chainsaw/logui/LogUI.java     | 97 +++++++++++-----------
 1 file changed, 48 insertions(+), 49 deletions(-)

diff --git a/src/main/java/org/apache/log4j/chainsaw/logui/LogUI.java b/src/main/java/org/apache/log4j/chainsaw/logui/LogUI.java
index 49bd80a..ffbca1a 100644
--- a/src/main/java/org/apache/log4j/chainsaw/logui/LogUI.java
+++ b/src/main/java/org/apache/log4j/chainsaw/logui/LogUI.java
@@ -18,9 +18,7 @@
 package org.apache.log4j.chainsaw.logui;
 
 import org.apache.commons.configuration2.AbstractConfiguration;
-import org.apache.commons.configuration2.event.ConfigurationEvent;
 import org.apache.log4j.chainsaw.*;
-import org.apache.log4j.chainsaw.color.RuleColorizer;
 import org.apache.log4j.chainsaw.components.elements.SmallButton;
 import org.apache.log4j.chainsaw.components.logpanel.LogPanel;
 import org.apache.log4j.chainsaw.components.tabbedpane.ChainsawTabbedPane;
@@ -59,7 +57,6 @@ import java.util.Map;
 import java.util.ServiceLoader;
 import java.util.Set;
 
-
 /**
  * The main entry point for Chainsaw, this class represents the first frame
  * that is used to display a Welcome panel, and any other panels that are
@@ -96,19 +93,19 @@ public class LogUI extends JFrame {
     private final Map<String, Component> panelMap = new HashMap<>();
     public ChainsawAppender chainsawAppender;
     private SettingsManager settingsManager;
-    private List<ChainsawReceiver> receivers = new ArrayList<>();
-    private List<ReceiverEventListener> receiverListeners = new ArrayList<>();
-    private ZeroConfPlugin zeroConf = new ZeroConfPlugin(settingsManager);
+    private final List<ChainsawReceiver> receivers = new ArrayList<>();
+    private final List<ReceiverEventListener> receiverListeners = new ArrayList<>();
+    private final ZeroConfPlugin zeroConf = new ZeroConfPlugin(settingsManager);
 
     /**
      * Clients can register a ShutdownListener to be notified when the user has
      * requested Chainsaw to exit.
      */
-    private EventListenerList shutdownListenerList = new EventListenerList();
+    private final EventListenerList shutdownListenerList = new EventListenerList();
 
-    private AbstractConfiguration configuration;
+    private final AbstractConfiguration configuration;
 
-    private ShutdownManager shutdownManager;
+    private final ShutdownManager shutdownManager;
     private LogUIPanelBuilder logUIPanelBuilder;
 
     /**
@@ -135,30 +132,53 @@ public class LogUI extends JFrame {
      * the main panel components.
      */
     private void initGUI() {
-
         setupHelpSystem();
         statusBar = new ChainsawStatusBar(this, configuration);
 
         boolean showStatusBar = configuration.getBoolean("statusBar", true);
         setStatusBarVisible(showStatusBar);
 
-        this.chainsawToolBarAndMenus = new ChainsawToolBarAndMenus(this, configuration);
+        chainsawToolBarAndMenus = new ChainsawToolBarAndMenus(this, configuration);
         toolbar = chainsawToolBarAndMenus.getToolbar();
         setJMenuBar(chainsawToolBarAndMenus.getMenubar());
 
         tabbedPane = new ChainsawTabbedPane();
 
-        /**
-         * This adds Drag & Drop capability to Chainsaw
-         */
+        createDragAndDrop();
+
+        applicationPreferenceModelPanel = new ApplicationPreferenceModelPanel(settingsManager);
+
+        applicationPreferenceModelPanel.setOkCancelActionListener(e -> preferencesFrame.setVisible(false));
+
+        KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
+        Action closeAction = new AbstractAction() {
+            public void actionPerformed(ActionEvent e) {
+                preferencesFrame.setVisible(false);
+            }
+        };
+        preferencesFrame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
+        preferencesFrame.getRootPane().
+            getActionMap().put("ESCAPE", closeAction);
+
+        logUIPanelBuilder = new LogUIPanelBuilder(tabbedPane, identifierPanels, chainsawToolBarAndMenus, panelMap, settingsManager, statusBar, zeroConf);
+
+        OSXIntegration.init(this);
+    }
+
+    /**
+     * This adds Drag & Drop capability to Chainsaw
+     */
+    private void createDragAndDrop() {
         FileDnDTarget dnDTarget = new FileDnDTarget(tabbedPane);
         dnDTarget.addPropertyChangeListener("fileList", evt -> {
             final List fileList = (List) evt.getNewValue();
 
             Thread thread = new Thread(() -> {
                 logger.debug("Loading files: {}", fileList);
+
                 for (Object aFileList : fileList) {
                     File file = (File) aFileList;
+
                     try {
                         getStatusBar().setMessage("Loading " + file.getAbsolutePath() + "...");
                     } catch (Exception e) {
@@ -171,27 +191,7 @@ public class LogUI extends JFrame {
 
             thread.setPriority(Thread.MIN_PRIORITY);
             thread.start();
-
         });
-
-        applicationPreferenceModelPanel = new ApplicationPreferenceModelPanel(settingsManager);
-
-        applicationPreferenceModelPanel.setOkCancelActionListener(
-            e -> preferencesFrame.setVisible(false));
-        KeyStroke escape = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false);
-        Action closeAction = new AbstractAction() {
-            public void actionPerformed(ActionEvent e) {
-                preferencesFrame.setVisible(false);
-            }
-        };
-        preferencesFrame.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE");
-        preferencesFrame.getRootPane().
-            getActionMap().put("ESCAPE", closeAction);
-
-        logUIPanelBuilder = new LogUIPanelBuilder(tabbedPane, identifierPanels, chainsawToolBarAndMenus, panelMap, settingsManager, statusBar, zeroConf);
-
-        OSXIntegration.init(this);
-
     }
 
     /**
@@ -220,7 +220,6 @@ public class LogUI extends JFrame {
 
 
         tb.add(exampleButton);
-
         tb.add(Box.createHorizontalGlue());
 
         /*
@@ -239,24 +238,29 @@ public class LogUI extends JFrame {
             });
     }
 
+    /**
+     * ensure that the Welcome Panel is made visible
+     */
     private void ensureWelcomePanelVisible() {
-        // ensure that the Welcome Panel is made visible
         if (!tabbedPane.containsWelcomePanel()) {
             addWelcomePanel();
         }
+
         tabbedPane.setSelectedComponent(welcomePanel);
     }
 
     /**
-     * Given the load event, configures the size/location of the main window etc
-     * etc.
+     * Given the load event, configures the size/location of the main window etc. etc.
      */
     private void loadSettings() {
         AbstractConfiguration config = settingsManager.getGlobalConfiguration();
         setLocation(
-            config.getInt(LogUI.MAIN_WINDOW_X, 0), config.getInt(LogUI.MAIN_WINDOW_Y, 0));
+            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;
@@ -295,10 +299,6 @@ public class LogUI extends JFrame {
         LogUiKeyStrokeCreator.createKeyStrokeLeft(tabbedPane);
         LogUiKeyStrokeCreator.createKeyStrokeGotoLine(tabbedPane, this);
 
-        /**
-         * We listen for double clicks, and auto-undock currently selected Tab if
-         * the mouse event location matches the currently selected tab
-         */
         MouseAdapter mouseAdapter = createMouseAdapter();
         tabbedPane.addMouseListener(mouseAdapter);
 
@@ -357,10 +357,10 @@ public class LogUI extends JFrame {
          * loads the saved tab settings and if there are hidden tabs,
          * hide those tabs out of currently loaded tabs..
          */
-
         if (!configuration.getBoolean("displayWelcomeTab", true)) {
             displayPanel(ChainsawTabbedPane.WELCOME_TAB, false);
         }
+
         if (!configuration.getBoolean("displayZeroconfTab", true)) {
             displayPanel(ChainsawTabbedPane.ZEROCONF, false);
         }
@@ -439,7 +439,6 @@ public class LogUI extends JFrame {
         preferencesFrame.setVisible(true);
     }
 
-
     /**
      * Registers a ShutdownListener with this class so that it can be notified
      * when the user has requested that Chainsaw exit.
@@ -459,11 +458,9 @@ public class LogUI extends JFrame {
         }
 
         settingsManager.saveAllSettings();
-
         return shutdownManager.shutdown();
     }
 
-
     public void loadReceiver() {
         Runnable r = () -> {
             JFileChooser jfc = new JFileChooser(SettingsManager.getSettingsDirectory());
@@ -509,7 +506,6 @@ public class LogUI extends JFrame {
         return result;
     }
 
-
     /**
      * Returns the currently selected LogPanel, if there is one, otherwise null
      *
@@ -588,7 +584,10 @@ public class LogUI extends JFrame {
         return statusBar;
     }
 
-
+    /**
+     * We listen for double clicks, and auto-undock currently selected Tab if
+     * the mouse event location matches the currently selected tab
+     */
     private MouseAdapter createMouseAdapter() {
         return new MouseAdapter() {
             @Override


(logging-chainsaw) 01/02: reordered methods

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

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

commit 25de1072ffa7bca008b7ece5200bdb5910293f2d
Author: Christian Grobmeier <cg...@grobmeier.de>
AuthorDate: Sun Dec 17 19:51:09 2023 +0100

    reordered methods
---
 .../org/apache/log4j/chainsaw/logui/LogUI.java     | 66 +++++++++++-----------
 1 file changed, 34 insertions(+), 32 deletions(-)

diff --git a/src/main/java/org/apache/log4j/chainsaw/logui/LogUI.java b/src/main/java/org/apache/log4j/chainsaw/logui/LogUI.java
index f17570f..49bd80a 100644
--- a/src/main/java/org/apache/log4j/chainsaw/logui/LogUI.java
+++ b/src/main/java/org/apache/log4j/chainsaw/logui/LogUI.java
@@ -130,16 +130,6 @@ public class LogUI extends JFrame {
         shutdownManager = new ShutdownManager(this, configuration, receivers, shutdownListenerList);
     }
 
-    /**
-     * Registers a ShutdownListener with this class so that it can be notified
-     * when the user has requested that Chainsaw exit.
-     *
-     * @param listener the listener to add
-     */
-    public void addShutdownListener(ShutdownListener listener) {
-        shutdownListenerList.add(ShutdownListener.class, listener);
-    }
-
     /**
      * Initialises the menu's and toolbars, but does not actually create any of
      * the main panel components.
@@ -406,19 +396,6 @@ public class LogUI extends JFrame {
         logUIPanelBuilder.buildLogPanel(false, "Chainsaw", chainsawAppender.getReceiver());
     }
 
-    /**
-     * Exits the application, ensuring Settings are saved.
-     */
-    public boolean exit() {
-        for (ChainsawReceiver rx : receivers) {
-            settingsManager.saveSettingsForReceiver(rx);
-        }
-
-        settingsManager.saveAllSettings();
-
-        return shutdownManager.shutdown();
-    }
-
     public void addWelcomePanel() {
         tabbedPane.insertTab(
             ChainsawTabbedPane.WELCOME_TAB, new ImageIcon(ChainsawIcons.ABOUT), welcomePanel,
@@ -458,15 +435,35 @@ public class LogUI extends JFrame {
         }
     }
 
+    public void showApplicationPreferences() {
+        preferencesFrame.setVisible(true);
+    }
+
 
-    public ChainsawStatusBar getStatusBar() {
-        return statusBar;
+    /**
+     * Registers a ShutdownListener with this class so that it can be notified
+     * when the user has requested that Chainsaw exit.
+     *
+     * @param listener the listener to add
+     */
+    public void addShutdownListener(ShutdownListener listener) {
+        shutdownListenerList.add(ShutdownListener.class, listener);
     }
 
-    public void showApplicationPreferences() {
-        preferencesFrame.setVisible(true);
+    /**
+     * Exits the application, ensuring Settings are saved.
+     */
+    public boolean exit() {
+        for (ChainsawReceiver rx : receivers) {
+            settingsManager.saveSettingsForReceiver(rx);
+        }
+
+        settingsManager.saveAllSettings();
+
+        return shutdownManager.shutdown();
     }
 
+
     public void loadReceiver() {
         Runnable r = () -> {
             JFileChooser jfc = new JFileChooser(SettingsManager.getSettingsDirectory());
@@ -565,11 +562,6 @@ public class LogUI extends JFrame {
         return getCurrentLogPanel() != null && getCurrentLogPanel().isLogTreeVisible();
     }
 
-    /** @deprecated */
-    public ChainsawTabbedPane getTabbedPane() {
-        return tabbedPane;
-    }
-
     public void addReceiver(ChainsawReceiver rx) {
         receivers.add(rx);
         logUIPanelBuilder.buildLogPanel(false, rx.getName(), rx);
@@ -587,6 +579,16 @@ public class LogUI extends JFrame {
         return receivers;
     }
 
+    /** @deprecated */
+    public ChainsawTabbedPane getTabbedPane() {
+        return tabbedPane;
+    }
+
+    public ChainsawStatusBar getStatusBar() {
+        return statusBar;
+    }
+
+
     private MouseAdapter createMouseAdapter() {
         return new MouseAdapter() {
             @Override