Return-Path: Delivered-To: apmail-jakarta-log4j-dev-archive@www.apache.org Received: (qmail 78879 invoked from network); 3 Dec 2003 04:04:21 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 3 Dec 2003 04:04:21 -0000 Received: (qmail 68348 invoked by uid 500); 3 Dec 2003 04:04:00 -0000 Delivered-To: apmail-jakarta-log4j-dev-archive@jakarta.apache.org Received: (qmail 68320 invoked by uid 500); 3 Dec 2003 04:04:00 -0000 Mailing-List: contact log4j-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Log4J Developers List" Reply-To: "Log4J Developers List" Delivered-To: mailing list log4j-dev@jakarta.apache.org Received: (qmail 68306 invoked by uid 500); 3 Dec 2003 04:04:00 -0000 Received: (qmail 68303 invoked from network); 3 Dec 2003 04:04:00 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 3 Dec 2003 04:04:00 -0000 Received: (qmail 78843 invoked by uid 1666); 3 Dec 2003 04:04:18 -0000 Date: 3 Dec 2003 04:04:18 -0000 Message-ID: <20031203040418.78842.qmail@minotaur.apache.org> From: sdeboy@apache.org To: jakarta-log4j-cvs@apache.org Subject: cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw LogUI.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N sdeboy 2003/12/02 20:04:18 Modified: src/java/org/apache/log4j/chainsaw LogUI.java Log: re-jalopyized, removed loglog.isdebugenabled calls Revision Changes Path 1.44 +791 -1004 jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java Index: LogUI.java =================================================================== RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/LogUI.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- LogUI.java 3 Dec 2003 02:33:02 -0000 1.43 +++ LogUI.java 3 Dec 2003 04:04:18 -0000 1.44 @@ -1,44 +1,50 @@ /* * ============================================================================ - * The Apache Software License, Version 1.1 + * The Apache Software License, Version 1.1 * ============================================================================ - * - * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - * + * + * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The end-user documentation included with the redistribution, if any, - * must include the following acknowledgment: "This product includes software - * developed by the Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, if and - * wherever such third-party acknowledgments normally appear. - * 4. The names "log4j" and "Apache Software Foundation" must not be used to - * endorse or promote products derived from this software without prior written - * permission. For written permission, please contact apache@apache.org. - * 5. Products derived from this software may not be called "Apache", nor may - * "Apache" appear in their name, without prior written permission of the - * Apache Software Foundation. - * + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The end-user documentation included with the redistribution, if any, must + * include the following acknowledgment: "This product includes software + * developed by the Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, if + * and wherever such third-party acknowledgments normally appear. + * + * 4. The names "log4j" and "Apache Software Foundation" must not be used to + * endorse or promote products derived from this software without prior + * written permission. For written permission, please contact + * apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", nor may + * "Apache" appear in their name, without prior written permission of the + * Apache Software Foundation. + * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- + * DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * This software consists of voluntary contributions made by many individuals - * on behalf of the Apache Software Foundation. For more information on the - * Apache Software Foundation, please see . - * + * + * This software consists of voluntary contributions made by many individuals + * on behalf of the Apache Software Foundation. For more information on the + * Apache Software Foundation, please see . + * */ package org.apache.log4j.chainsaw; @@ -124,34 +130,35 @@ import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; + /** * 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 * generated because Logging Events are streamed via a Receiver, or other * mechanism. - * + * * If a system property 'chainsaw.usecyclicbuffer' is set to 'true', each panel * will use a cyclic buffer for displaying events and once events reach the * buffer limit, the oldest events are removed from the table. - * + * * If the property is not provided, there is no limit on the table's buffer * size. - * + * * If 'chainsaw.usecyclicbuffer' is set to 'true' and a system property * 'chainsaw.cyclicbuffersize' is set to some integer value, that value will be * used as the buffer size - if the buffersize is not provided, a default size * of 500 is used. - * + * * @author Scott Deboy * @author Paul Smith * - * + * */ -public class LogUI extends JFrame implements ChainsawViewer, SettingsListener -{ +public class LogUI extends JFrame implements ChainsawViewer, SettingsListener { private static final String CONFIG_FILE_TO_USE = "config.file"; static final String USE_CYCLIC_BUFFER_PROP_NAME = "chainsaw.usecyclicbuffer"; - static final String CYCLIC_BUFFER_SIZE_PROP_NAME = "chainsaw.cyclicbuffersize"; + static final String CYCLIC_BUFFER_SIZE_PROP_NAME = + "chainsaw.cyclicbuffersize"; 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"; @@ -193,13 +200,12 @@ * by default this exits the VM, but a developer may replace this action with * something that better suits their needs */ - private Action shutdownAction = new AbstractAction() - { - public void actionPerformed(ActionEvent e) - { - System.exit(0); - } - }; + private Action shutdownAction = + new AbstractAction() { + public void actionPerformed(ActionEvent e) { + System.exit(0); + } + }; /** * Clients can register a ShutdownListener to be notified when the user has @@ -212,31 +218,27 @@ * Constructor which builds up all the visual elements of the frame including * the Menu bar */ - public LogUI() - { + public LogUI() { super("Chainsaw v2 - Log Viewer"); - if (ChainsawIcons.WINDOW_ICON != null) - { + if (ChainsawIcons.WINDOW_ICON != null) { setIconImage(new ImageIcon(ChainsawIcons.WINDOW_ICON).getImage()); } } - private static final void showSplash(Frame owner) - { + private static final void showSplash(Frame owner) { splash = new ChainsawSplash(owner); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - splash.setLocation((screenSize.width / 2) - (splash.getWidth() / 2), - (screenSize.height / 2) - (splash.getHeight() / 2)); + splash.setLocation( + (screenSize.width / 2) - (splash.getWidth() / 2), + (screenSize.height / 2) - (splash.getHeight() / 2)); splash.setVisible(true); } - private static final void removeSplash() - { - if (splash != null) - { + private static final void removeSplash() { + if (splash != null) { splash.setVisible(false); splash.dispose(); } @@ -245,33 +247,30 @@ /** * Registers a ShutdownListener with this calss so that it can be notified * when the user has requested that Chainsaw exit. - * + * * @param l */ - public void addShutdownListener(ShutdownListener l) - { + public void addShutdownListener(ShutdownListener l) { shutdownListenerList.add(ShutdownListener.class, l); } /** * Removes the registered ShutdownListener so that the listener will not be * notified on a shutdown. - * + * * @param l */ - public void removeShutdownListener(ShutdownListener l) - { + public void removeShutdownListener(ShutdownListener l) { shutdownListenerList.remove(ShutdownListener.class, l); } /** * Starts Chainsaw by attaching a new instance to the Log4J main root Logger * via a ChainsawAppender, and activates itself - * + * * @param args */ - public static void main(String[] args) - { + public static void main(String[] args) { createChainsawGUI(true, null); } @@ -279,17 +278,16 @@ * Creates, activates, and then shows the Chainsaw GUI, optionally showing * the splash screen, and using the passed shutdown action when the user * requests to exit the application (if null, then Chainsaw will exit the vm) - * + * * @param showSplash * @param shutdownAction * DOCUMENT ME! */ - public static void createChainsawGUI(boolean showSplash, Action shutdownAction) - { + public static void createChainsawGUI( + boolean showSplash, Action shutdownAction) { LogUI logUI = new LogUI(); - if (showSplash) - { + if (showSplash) { showSplash(logUI); } @@ -298,21 +296,18 @@ LogManager.getRootLogger().addAppender(logUI.handler); logUI.activateViewer(); - if (shutdownAction != null) - { + if (shutdownAction != null) { logUI.setShutdownAction(shutdownAction); } - } /** * DOCUMENT ME! - * + * * @param appender * DOCUMENT ME! */ - public void activateViewer(ChainsawAppender appender) - { + public void activateViewer(ChainsawAppender appender) { handler = new ChainsawAppenderHandler(appender); handler.addEventBatchListener(new NewTabEventBatchReceiver()); activateViewer(); @@ -321,85 +316,75 @@ /** * Initialises the menu's and toolbars, but does not actually create any of * the main panel components. - * + * */ - private void initGUI() - { + private void initGUI() { statusBar = new ChainsawStatusBar(); receiversPanel = new ReceiversPanel(this); setToolBarAndMenus(new ChainsawToolBarAndMenus(this)); toolbar = getToolBarAndMenus().getToolbar(); setJMenuBar(getToolBarAndMenus().getMenubar()); setTabbedPane(new ChainsawTabbedPane()); - // getTabbedPane().addChangeListener(getToolBarAndMenus().getPanelListener()); + // getTabbedPane().addChangeListener(getToolBarAndMenus().getPanelListener()); final JPopupMenu tabPopup = new JPopupMenu(); - Action hideCurrentTabAction = new AbstractAction("Hide") - { - public void actionPerformed(ActionEvent e) - { - displayPanel(getCurrentLogPanel().getIdentifier(), false); - tbms.stateChange(); - } - }; + Action hideCurrentTabAction = + new AbstractAction("Hide") { + public void actionPerformed(ActionEvent e) { + displayPanel(getCurrentLogPanel().getIdentifier(), false); + tbms.stateChange(); + } + }; + + Action hideOtherTabsAction = + new AbstractAction("Hide Others") { + public void actionPerformed(ActionEvent e) { + String currentName = getCurrentLogPanel().getIdentifier(); + + int count = getTabbedPane().getTabCount(); + int index = 0; + + for (int i = 0; i < count; i++) { + String name = getTabbedPane().getTitleAt(index); - Action hideOtherTabsAction = new AbstractAction("Hide Others") - { - public void actionPerformed(ActionEvent e) - { - String currentName = getCurrentLogPanel().getIdentifier(); - - int count = getTabbedPane().getTabCount(); - int index = 0; - - for (int i = 0; i < count; i++) - { - String name = getTabbedPane().getTitleAt(index); - - if (getPanelMap().keySet().contains(name) - && !name.equals(currentName)) - { - displayPanel(name, false); - tbms.stateChange(); - } - else - { - index++; + if ( + getPanelMap().keySet().contains(name) + && !name.equals(currentName)) { + displayPanel(name, false); + tbms.stateChange(); + } else { + index++; + } } } - } - }; + }; - Action showHiddenTabsAction = new AbstractAction("Show All Hidden") - { - public void actionPerformed(ActionEvent e) - { - for (Iterator iter = getPanels().keySet().iterator(); iter.hasNext(); ) - { - String identifier = (String) iter.next(); - int count = getTabbedPane().getTabCount(); - boolean found = false; + Action showHiddenTabsAction = + new AbstractAction("Show All Hidden") { + public void actionPerformed(ActionEvent e) { + for (Iterator iter = getPanels().keySet().iterator(); + iter.hasNext();) { + String identifier = (String) iter.next(); + int count = getTabbedPane().getTabCount(); + boolean found = false; - for (int i = 0; i < count; i++) - { - String name = getTabbedPane().getTitleAt(i); + for (int i = 0; i < count; i++) { + String name = getTabbedPane().getTitleAt(i); - if (name.equals(identifier)) - { - found = true; + if (name.equals(identifier)) { + found = true; - break; + break; + } } - } - if (!found) - { - displayPanel(identifier, true); - tbms.stateChange(); + if (!found) { + displayPanel(identifier, true); + tbms.stateChange(); + } } } - } - }; + }; tabPopup.add(hideCurrentTabAction); tabPopup.add(hideOtherTabsAction); @@ -413,54 +398,47 @@ /** * Given the load event, configures the size/location of the main window etc * etc. - * + * * @param event * DOCUMENT ME! */ - public void loadSettings(LoadSettingsEvent event) - { - if (event.asBoolean(LogUI.STATUS_BAR)) - { + public void loadSettings(LoadSettingsEvent event) { + if (event.asBoolean(LogUI.STATUS_BAR)) { addStatusBar(); - } - else - { + } else { removeStatusBar(); } - setLocation(event.asInt(LogUI.MAIN_WINDOW_X), event - .asInt(LogUI.MAIN_WINDOW_Y)); - setSize(event.asInt(LogUI.MAIN_WINDOW_WIDTH), event - .asInt(LogUI.MAIN_WINDOW_HEIGHT)); + setLocation( + event.asInt(LogUI.MAIN_WINDOW_X), event.asInt(LogUI.MAIN_WINDOW_Y)); + setSize( + event.asInt(LogUI.MAIN_WINDOW_WIDTH), + event.asInt(LogUI.MAIN_WINDOW_HEIGHT)); getToolBarAndMenus().stateChange(); } /** * Ensures the location/size of the main window is stored with the settings - * + * * @param event * DOCUMENT ME! */ - public void saveSettings(SaveSettingsEvent event) - { + 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()); - if (lookAndFeelClassName != null) - { + if (lookAndFeelClassName != null) { event.saveSetting(LogUI.LOOK_AND_FEEL, lookAndFeelClassName); } - event.saveSetting(LogUI.STATUS_BAR, isStatusBarVisible() - ? Boolean.TRUE - : Boolean.FALSE); + event.saveSetting( + LogUI.STATUS_BAR, isStatusBarVisible() ? Boolean.TRUE : Boolean.FALSE); - if (configURLToUse != null) - { + if (configURLToUse != null) { event.saveSetting(LogUI.CONFIG_FILE_TO_USE, configURLToUse.toString()); } } @@ -470,139 +448,109 @@ * and configures the default Tabbed Pane elements with the correct layout, * table columns, and sets itself viewable. */ - public void activateViewer() - { + public void activateViewer() { welcomePanel = new WelcomePanel(this); - final SocketNodeEventListener socketListener = new SocketNodeEventListener() - { - public void socketOpened(String remoteInfo) - { - statusBar.remoteConnectionReceived(remoteInfo); - } + final SocketNodeEventListener socketListener = + new SocketNodeEventListener() { + public void socketOpened(String remoteInfo) { + statusBar.remoteConnectionReceived(remoteInfo); + } - public void socketClosedEvent(Exception e) - { - statusBar.setMessage("Collection lost! :: " + e.getMessage()); - } - }; + public void socketClosedEvent(Exception e) { + statusBar.setMessage("Collection lost! :: " + e.getMessage()); + } + }; + + PluginListener pluginListener = + new PluginListener() { + public void pluginStarted(PluginEvent e) { + statusBar.setMessage(e.getPlugin().getName() + " started!"); - PluginListener pluginListener = new PluginListener() - { - public void pluginStarted(PluginEvent e) - { - statusBar.setMessage(e.getPlugin().getName() + " started!"); - - Method method = getAddListenerMethod(e.getPlugin()); - - if (method != null) - { - try - { - method.invoke(e.getPlugin(), new Object[]{socketListener}); - } - catch (Exception ex) - { - LogLog.error("Failed to add a SocketNodeEventListener", ex); + Method method = getAddListenerMethod(e.getPlugin()); + + if (method != null) { + try { + method.invoke(e.getPlugin(), new Object[] { socketListener }); + } catch (Exception ex) { + LogLog.error("Failed to add a SocketNodeEventListener", ex); + } } } - } - Method getRemoveListenerMethod(Plugin p) - { - try - { - return p - .getClass() - .getMethod("removeSocketNodeEventListener", - new Class[]{SocketNodeEventListener.class}); - } - catch (Exception e) - { - return null; + Method getRemoveListenerMethod(Plugin p) { + try { + return p.getClass().getMethod( + "removeSocketNodeEventListener", + new Class[] { SocketNodeEventListener.class }); + } catch (Exception e) { + return null; + } } - } - Method getAddListenerMethod(Plugin p) - { - try - { - return p - .getClass() - .getMethod("addSocketNodeEventListener", - new Class[]{SocketNodeEventListener.class}); - } - catch (Exception e) - { - return null; + Method getAddListenerMethod(Plugin p) { + try { + return p.getClass().getMethod( + "addSocketNodeEventListener", + new Class[] { SocketNodeEventListener.class }); + } catch (Exception e) { + return null; + } } - } - public void pluginStopped(PluginEvent e) - { - Method method = getRemoveListenerMethod(e.getPlugin()); - - if (method != null) - { - try - { - method.invoke(e.getPlugin(), new Object[]{socketListener}); - } - catch (Exception ex) - { - LogLog.error("Failed to remove SocketNodeEventListener", ex); + public void pluginStopped(PluginEvent e) { + Method method = getRemoveListenerMethod(e.getPlugin()); + + if (method != null) { + try { + method.invoke(e.getPlugin(), new Object[] { socketListener }); + } catch (Exception ex) { + LogLog.error("Failed to remove SocketNodeEventListener", ex); + } } - } - statusBar.setMessage(e.getPlugin().getName() + " stopped!"); - } - }; + statusBar.setMessage(e.getPlugin().getName() + " stopped!"); + } + }; PluginRegistry.addPluginListener(pluginListener); - getSettingsManager().configure(new SettingsListener() - { - public void loadSettings(LoadSettingsEvent event) - { - String configFile = event.getSetting(LogUI.CONFIG_FILE_TO_USE); - - //if both a config file are defined and a log4j.configuration property - // are set, - //don't use configFile's configuration - if ((configFile != null) && !configFile.trim().equals("") - && (System.getProperty("log4j.configuration") == null)) - { - try - { - URL url = new URL(configFile); - OptionConverter.selectAndConfigure(url, null, LogManager - .getLoggerRepository()); - - if (LogUI.this.getStatusBar() != null) - { - LogUI.this - .getStatusBar() - .setMessage("Configured Log4j using remembered URL :: " + url); - } + getSettingsManager().configure( + new SettingsListener() { + public void loadSettings(LoadSettingsEvent event) { + String configFile = event.getSetting(LogUI.CONFIG_FILE_TO_USE); + + //if both a config file are defined and a log4j.configuration property + // are set, + //don't use configFile's configuration + if ( + (configFile != null) && !configFile.trim().equals("") + && (System.getProperty("log4j.configuration") == null)) { + try { + URL url = new URL(configFile); + OptionConverter.selectAndConfigure( + url, null, LogManager.getLoggerRepository()); + + if (LogUI.this.getStatusBar() != null) { + LogUI.this.getStatusBar().setMessage( + "Configured Log4j using remembered URL :: " + url); + } - LogUI.this.configURLToUse = url; - } - catch (Exception e) - { - LogLog.error("error occurred initializing log4j", e); + LogUI.this.configURLToUse = url; + } catch (Exception e) { + LogLog.error("error occurred initializing log4j", e); + } } } - } - public void saveSettings(SaveSettingsEvent event) - { - //required because of SettingsListener interface..not used during load - } - }); + public void saveSettings(SaveSettingsEvent event) { + //required because of SettingsListener interface..not used during load + } + }); - if (PluginRegistry - .getPlugins(LogManager.getLoggerRepository(), Receiver.class).size() == 0) - { + if ( + PluginRegistry.getPlugins( + LogManager.getLoggerRepository(), Receiver.class).size() == 0) { noReceiversDefined = true; } @@ -611,25 +559,23 @@ List utilList = UtilLoggingLevel.getAllPossibleLevels(); // TODO: Replace the array list creating with the standard way of - // retreiving the Level set. (TBD) - Priority[] priorities = new Level[]{Level.FATAL, Level.ERROR, Level.WARN, - Level.INFO, Level.DEBUG}; + // retreiving the Level set. (TBD) + Priority[] priorities = + new Level[] { Level.FATAL, Level.ERROR, Level.WARN, Level.INFO, Level.DEBUG }; List priorityLevels = new ArrayList(); - for (int i = 0; i < priorities.length; i++) - { + for (int i = 0; i < priorities.length; i++) { priorityLevels.add(priorities[i].toString()); } List utilLevels = new ArrayList(); - for (Iterator iterator = utilLevels.iterator(); iterator.hasNext(); ) - { + for (Iterator iterator = utilLevels.iterator(); iterator.hasNext();) { utilLevels.add(iterator.next().toString()); } // getLevelMap().put(ChainsawConstants.UTIL_LOGGING_EVENT_TYPE, - // utilLevels); + // utilLevels); // getLevelMap().put(ChainsawConstants.LOG4J_EVENT_TYPE, priorityLevels); getFilterableColumns().add(ChainsawConstants.LEVEL_COL_NAME); getFilterableColumns().add(ChainsawConstants.LOGGER_COL_NAME); @@ -647,91 +593,84 @@ getContentPane().setLayout(new BorderLayout()); getTabbedPane().addChangeListener(getToolBarAndMenus()); - getTabbedPane().addChangeListener(new ChangeListener() - { - //received a statechange event - selection changed - remove icon from - // selected index - public void stateChanged(ChangeEvent e) - { - if (getTabbedPane().getSelectedComponent() instanceof ChainsawTabbedPane) - { - if (getTabbedPane().getSelectedIndex() > -1) - { - getTabbedPane().setIconAt(getTabbedPane().getSelectedIndex(), null); + getTabbedPane().addChangeListener( + new ChangeListener() { + //received a statechange event - selection changed - remove icon from + // selected index + public void stateChanged(ChangeEvent e) { + if ( + getTabbedPane().getSelectedComponent() instanceof ChainsawTabbedPane) { + if (getTabbedPane().getSelectedIndex() > -1) { + getTabbedPane().setIconAt( + getTabbedPane().getSelectedIndex(), null); + } } } - } - }); + }); + + KeyStroke ksRight = + KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.CTRL_MASK); + KeyStroke ksLeft = + KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, Event.CTRL_MASK); + + getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( + ksRight, "MoveRight"); + getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( + ksLeft, "MoveLeft"); + + Action moveRight = + new AbstractAction() { + public void actionPerformed(ActionEvent e) { + int temp = getTabbedPane().getSelectedIndex(); + ++temp; - KeyStroke ksRight = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, - Event.CTRL_MASK); - KeyStroke ksLeft = KeyStroke - .getKeyStroke(KeyEvent.VK_LEFT, Event.CTRL_MASK); - - getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) - .put(ksRight, "MoveRight"); - getTabbedPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) - .put(ksLeft, "MoveLeft"); - - Action moveRight = new AbstractAction() - { - public void actionPerformed(ActionEvent e) - { - int temp = getTabbedPane().getSelectedIndex(); - ++temp; - - if (temp != getTabbedPane().getTabCount()) - { - getTabbedPane().setSelectedTab(temp); + if (temp != getTabbedPane().getTabCount()) { + getTabbedPane().setSelectedTab(temp); + } } - } - }; + }; - Action moveLeft = new AbstractAction() - { - public void actionPerformed(ActionEvent e) - { - int temp = getTabbedPane().getSelectedIndex(); - --temp; - - if (temp > -1) - { - getTabbedPane().setSelectedTab(temp); + Action moveLeft = + new AbstractAction() { + public void actionPerformed(ActionEvent e) { + int temp = getTabbedPane().getSelectedIndex(); + --temp; + + if (temp > -1) { + getTabbedPane().setSelectedTab(temp); + } } - } - }; + }; getTabbedPane().getActionMap().put("MoveRight", moveRight); getTabbedPane().getActionMap().put("MoveLeft", moveLeft); /** - * We listen for double clicks, and auto-undock currently selected Tab if - * the mouse event location matches the currently selected tab - */ - getTabbedPane().addMouseListener(new MouseAdapter() - { - public void mouseClicked(MouseEvent e) - { - super.mouseClicked(e); - - if ((e.getClickCount() > 1) - && ((e.getModifiers() & InputEvent.BUTTON1_MASK) > 0)) - { - int tabIndex = getTabbedPane().getSelectedIndex(); - - if ((tabIndex != -1) - && (tabIndex == getTabbedPane().getSelectedIndex())) - { - LogPanel logPanel = getCurrentLogPanel(); - - if (logPanel != null) - { - logPanel.undock(); + * We listen for double clicks, and auto-undock currently selected Tab if + * the mouse event location matches the currently selected tab + */ + getTabbedPane().addMouseListener( + new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + super.mouseClicked(e); + + if ( + (e.getClickCount() > 1) + && ((e.getModifiers() & InputEvent.BUTTON1_MASK) > 0)) { + int tabIndex = getTabbedPane().getSelectedIndex(); + + if ( + (tabIndex != -1) + && (tabIndex == getTabbedPane().getSelectedIndex())) { + LogPanel logPanel = getCurrentLogPanel(); + + if (logPanel != null) { + logPanel.undock(); + } } } } - } - }); + }); panePanel.add(getTabbedPane()); addWelcomePanel(); @@ -742,42 +681,37 @@ receiversPanel.setVisible(false); getContentPane().add(receiversPanel, BorderLayout.EAST); - addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent event) - { - exit(); - } - }); - getSettingsManager().configure(new SettingsListener() - { - public void loadSettings(LoadSettingsEvent event) - { - lookAndFeelClassName = event.getSetting(LogUI.LOOK_AND_FEEL); - - if (lookAndFeelClassName != null) - { - applyLookAndFeel(lookAndFeelClassName); + addWindowListener( + new WindowAdapter() { + public void windowClosing(WindowEvent event) { + exit(); } - } + }); + getSettingsManager().configure( + new SettingsListener() { + public void loadSettings(LoadSettingsEvent event) { + lookAndFeelClassName = event.getSetting(LogUI.LOOK_AND_FEEL); - public void saveSettings(SaveSettingsEvent event) - { - //required because of SettingsListener interface..not used during load - } - }); + if (lookAndFeelClassName != null) { + applyLookAndFeel(lookAndFeelClassName); + } + } + + public void saveSettings(SaveSettingsEvent event) { + //required because of SettingsListener interface..not used during load + } + }); pack(); - this.handler.addPropertyChangeListener("dataRate", - new PropertyChangeListener() - { - public void propertyChange(PropertyChangeEvent evt) - { - double dataRate = ((Double) evt.getNewValue()).doubleValue(); - statusBar.setDataRate(dataRate); - } - }); + this.handler.addPropertyChangeListener( + "dataRate", + new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + double dataRate = ((Double) evt.getNewValue()).doubleValue(); + statusBar.setDataRate(dataRate); + } + }); getSettingsManager().addSettingsListener(this); getSettingsManager().addSettingsListener(getToolBarAndMenus()); @@ -787,14 +721,12 @@ removeSplash(); - synchronized (initializationLock) - { + synchronized (initializationLock) { isGUIFullyInitialized = true; initializationLock.notifyAll(); } - if (noReceiversDefined) - { + if (noReceiversDefined) { showNoReceiversWarningPanel(); } @@ -804,90 +736,77 @@ tutorialArea.setEditable(false); container.setLayout(new BorderLayout()); - try - { + try { tutorialArea.setPage(getWelcomePanel().getTutorialURL()); container.add(new JScrollPane(tutorialArea), BorderLayout.CENTER); - } - catch (Exception e) - { + } catch (Exception e) { LogLog.error("Error occurred loading the Tutorial", e); } tutorialFrame.setSize(new Dimension(640, 480)); - final Action startTutorial = new AbstractAction("Start Tutorial", - new ImageIcon(ChainsawIcons.ICON_RESUME_RECEIVER)) - { - public void actionPerformed(ActionEvent e) - { - if (JOptionPane - .showConfirmDialog( + final Action startTutorial = + new AbstractAction( + "Start Tutorial", new ImageIcon(ChainsawIcons.ICON_RESUME_RECEIVER)) { + public void actionPerformed(ActionEvent e) { + if ( + JOptionPane.showConfirmDialog( null, "This will start 3 \"Generator\" receivers for use in the Tutorial. Is that ok?", - "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) - { - new Thread(new Tutorial()).start(); - putValue("TutorialStarted", Boolean.TRUE); - } - else - { - putValue("TutorialStarted", Boolean.FALSE); + "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + new Thread(new Tutorial()).start(); + putValue("TutorialStarted", Boolean.TRUE); + } else { + putValue("TutorialStarted", Boolean.FALSE); + } } - } - }; - - final Action stopTutorial = new AbstractAction("Stop Tutorial", - new ImageIcon(ChainsawIcons.ICON_STOP_RECEIVER)) - { - public void actionPerformed(ActionEvent e) - { - if (JOptionPane - .showConfirmDialog( + }; + + final Action stopTutorial = + new AbstractAction( + "Stop Tutorial", new ImageIcon(ChainsawIcons.ICON_STOP_RECEIVER)) { + public void actionPerformed(ActionEvent e) { + if ( + JOptionPane.showConfirmDialog( null, "This will stop all of the \"Generator\" receivers used in the Tutorial, but leave any other Receiver untouched. Is that ok?", - "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) - { - new Thread(new Runnable() - { - public void run() - { - List list = PluginRegistry - .getPlugins(LogManager.getLoggerRepository(), Generator.class); - - for (Iterator iter = list.iterator(); iter.hasNext(); ) - { - Plugin plugin = (Plugin) iter.next(); - PluginRegistry.stopPlugin(plugin); - } - } - }).start(); - setEnabled(false); - startTutorial.putValue("TutorialStarted", Boolean.FALSE); + "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + new Thread( + new Runnable() { + public void run() { + List list = + PluginRegistry.getPlugins( + LogManager.getLoggerRepository(), Generator.class); + + for (Iterator iter = list.iterator(); iter.hasNext();) { + Plugin plugin = (Plugin) iter.next(); + PluginRegistry.stopPlugin(plugin); + } + } + }).start(); + setEnabled(false); + startTutorial.putValue("TutorialStarted", Boolean.FALSE); + } } - } - }; - - stopTutorial - .putValue( - Action.SHORT_DESCRIPTION, - "Removes all of the Tutorials Generator Receivers, leaving all other Receivers untouched"); - startTutorial - .putValue( - Action.SHORT_DESCRIPTION, - "Begins the Tutorial, starting up some Generator Receivers so you can see Chainsaw in action"); + }; + + stopTutorial.putValue( + Action.SHORT_DESCRIPTION, + "Removes all of the Tutorials Generator Receivers, leaving all other Receivers untouched"); + startTutorial.putValue( + Action.SHORT_DESCRIPTION, + "Begins the Tutorial, starting up some Generator Receivers so you can see Chainsaw in action"); stopTutorial.setEnabled(false); final SmallToggleButton startButton = new SmallToggleButton(startTutorial); - PropertyChangeListener pcl = new PropertyChangeListener() - { - public void propertyChange(PropertyChangeEvent evt) - { - stopTutorial.setEnabled(((Boolean) startTutorial - .getValue("TutorialStarted")) == Boolean.TRUE); - startButton.setSelected(stopTutorial.isEnabled()); - } - }; + PropertyChangeListener pcl = + new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + stopTutorial.setEnabled( + ((Boolean) startTutorial.getValue("TutorialStarted")) == Boolean.TRUE); + startButton.setSelected(stopTutorial.isEnabled()); + } + }; startTutorial.addPropertyChangeListener(pcl); stopTutorial.addPropertyChangeListener(pcl); @@ -899,275 +818,234 @@ tutorialToolbar.add(startButton); tutorialToolbar.add(stopButton); container.add(tutorialToolbar, BorderLayout.NORTH); - tutorialArea.addHyperlinkListener(new HyperlinkListener() - { - public void hyperlinkUpdate(HyperlinkEvent e) - { - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) - { - if (e.getDescription().equals("StartTutorial")) - { - startTutorial.actionPerformed(null); - } - else if (e.getDescription().equals("StopTutorial")) - { - stopTutorial.actionPerformed(null); - } - else - { - try - { - tutorialArea.setPage(e.getURL()); - } - catch (IOException e1) - { - LogLog.error("Failed to change the URL for the Tutorial", e1); + tutorialArea.addHyperlinkListener( + new HyperlinkListener() { + public void hyperlinkUpdate(HyperlinkEvent e) { + if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + if (e.getDescription().equals("StartTutorial")) { + startTutorial.actionPerformed(null); + } else if (e.getDescription().equals("StopTutorial")) { + stopTutorial.actionPerformed(null); + } else { + try { + tutorialArea.setPage(e.getURL()); + } catch (IOException e1) { + LogLog.error("Failed to change the URL for the Tutorial", e1); + } } } } - } - }); + }); } /** * Displays a warning dialog about having no Receivers defined and allows the * user to choose some options for configuration */ - private void showNoReceiversWarningPanel() - { - final NoReceiversWarningPanel noReceiversWarningPanel = new NoReceiversWarningPanel(); - - final SettingsListener sl = new SettingsListener() - { - public void loadSettings(LoadSettingsEvent event) - { - int size = event.asInt("SavedConfigs.Size"); - Object[] configs = new Object[size]; - - for (int i = 0; i < size; i++) - { - configs[i] = event.getSetting("SavedConfigs." + i); + private void showNoReceiversWarningPanel() { + final NoReceiversWarningPanel noReceiversWarningPanel = + new NoReceiversWarningPanel(); + + final SettingsListener sl = + new SettingsListener() { + public void loadSettings(LoadSettingsEvent event) { + int size = event.asInt("SavedConfigs.Size"); + Object[] configs = new Object[size]; + + for (int i = 0; i < size; i++) { + configs[i] = event.getSetting("SavedConfigs." + i); + } + + noReceiversWarningPanel.getModel().setRememberedConfigs(configs); } - noReceiversWarningPanel.getModel().setRememberedConfigs(configs); - } + public void saveSettings(SaveSettingsEvent event) { + Object[] configs = + noReceiversWarningPanel.getModel().getRememberedConfigs(); + event.saveSetting("SavedConfigs.Size", configs.length); - public void saveSettings(SaveSettingsEvent event) - { - Object[] configs = noReceiversWarningPanel.getModel() - .getRememberedConfigs(); - event.saveSetting("SavedConfigs.Size", configs.length); - - for (int i = 0; i < configs.length; i++) - { - event.saveSetting("SavedConfigs." + i, configs[i].toString()); + for (int i = 0; i < configs.length; i++) { + event.saveSetting("SavedConfigs." + i, configs[i].toString()); + } } - } - }; + }; /** - * This listener sets up the NoReciversWarningPanel and loads saves the - * configs/logfiles - */ + * This listener sets up the NoReciversWarningPanel and loads saves the + * configs/logfiles + */ getSettingsManager().addSettingsListener(sl); getSettingsManager().configure(sl); - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - final JDialog dialog = new JDialog(LogUI.this, true); - dialog.setTitle("Warning: You have no Receivers defined..."); - dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); - - dialog.setResizable(false); - - noReceiversWarningPanel.setOkActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - dialog.setVisible(false); - } - }); + SwingUtilities.invokeLater( + new Runnable() { + public void run() { + final JDialog dialog = new JDialog(LogUI.this, true); + dialog.setTitle("Warning: You have no Receivers defined..."); + dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); + + dialog.setResizable(false); + + noReceiversWarningPanel.setOkActionListener( + new ActionListener() { + public void actionPerformed(ActionEvent e) { + dialog.setVisible(false); + } + }); - dialog.getContentPane().add(noReceiversWarningPanel); + dialog.getContentPane().add(noReceiversWarningPanel); - dialog.pack(); + dialog.pack(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - dialog.setLocation((screenSize.width / 2) - (dialog.getWidth() / 2), + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + dialog.setLocation( + (screenSize.width / 2) - (dialog.getWidth() / 2), (screenSize.height / 2) - (dialog.getHeight() / 2)); - dialog.show(); + dialog.show(); - dialog.dispose(); + dialog.dispose(); - if (noReceiversWarningPanel.getModel().isManualMode()) - { - toggleReceiversPanel(); - } - else if (noReceiversWarningPanel.getModel().isSimpleReceiverMode()) - { - int port = noReceiversWarningPanel.getModel().getSimplePort(); - Class receiverClass = noReceiversWarningPanel.getModel() - .getSimpleReceiverClass(); - - try - { - Receiver simpleReceiver = (Receiver) receiverClass.newInstance(); - simpleReceiver.setName("Simple Receiver"); - - Method portMethod = simpleReceiver.getClass() - .getMethod("setPort", new Class[]{int.class}); - portMethod.invoke(simpleReceiver, new Object[]{new Integer(port)}); - - simpleReceiver.setThreshold(Level.DEBUG); - - PluginRegistry.startPlugin(simpleReceiver); - receiversPanel.updateReceiverTreeInDispatchThread(); - } - catch (Exception e) - { - LogLog.error("Error creating Receiver", e); - getStatusBar() - .setMessage("An error occurred creating your Receiver"); - } - } - else if (noReceiversWarningPanel.getModel().isLoadConfig()) - { - final URL url = noReceiversWarningPanel.getModel().getConfigToLoad(); - - if (url != null) - { - LogLog.debug("Initialiazing Log4j with " + url.toExternalForm()); - - new Thread(new Runnable() - { - public void run() - { - try - { - OptionConverter.selectAndConfigure(url, null, LogManager - .getLoggerRepository()); - } - catch (Exception e) - { - LogLog.error("Error initializing Log4j", e); - } + if (noReceiversWarningPanel.getModel().isManualMode()) { + toggleReceiversPanel(); + } else if (noReceiversWarningPanel.getModel().isSimpleReceiverMode()) { + int port = noReceiversWarningPanel.getModel().getSimplePort(); + Class receiverClass = + noReceiversWarningPanel.getModel().getSimpleReceiverClass(); + + try { + Receiver simpleReceiver = (Receiver) receiverClass.newInstance(); + simpleReceiver.setName("Simple Receiver"); + + Method portMethod = + simpleReceiver.getClass().getMethod( + "setPort", new Class[] { int.class }); + portMethod.invoke( + simpleReceiver, new Object[] { new Integer(port) }); + + simpleReceiver.setThreshold(Level.DEBUG); + + PluginRegistry.startPlugin(simpleReceiver); + receiversPanel.updateReceiverTreeInDispatchThread(); + } catch (Exception e) { + LogLog.error("Error creating Receiver", e); + getStatusBar().setMessage( + "An error occurred creating your Receiver"); + } + } else if (noReceiversWarningPanel.getModel().isLoadConfig()) { + final URL url = + noReceiversWarningPanel.getModel().getConfigToLoad(); + + if (url != null) { + LogLog.debug("Initialiazing Log4j with " + url.toExternalForm()); + + new Thread( + new Runnable() { + public void run() { + try { + OptionConverter.selectAndConfigure( + url, null, LogManager.getLoggerRepository()); + } catch (Exception e) { + LogLog.error("Error initializing Log4j", e); + } - LogManager.getLoggerRepository().getRootLogger() - .addAppender(handler); + LogManager.getLoggerRepository().getRootLogger() + .addAppender(handler); - receiversPanel.updateReceiverTreeInDispatchThread(); - } - }).start(); + receiversPanel.updateReceiverTreeInDispatchThread(); + } + }).start(); + } } } - } - }); + }); } /** * Exits the application, ensuring Settings are saved. - * + * */ - void exit() - { + void exit() { // TODO Ask the user if they want to save the settings via a dialog. getSettingsManager().saveSettings(); shutdown(); } - void addWelcomePanel() - { - getTabbedPane() - .addANewTab("Welcome", welcomePanel, - new ImageIcon(ChainsawIcons.ABOUT), "Welcome/Help"); - } - - void removeWelcomePanel() - { - if (getTabbedPane().containsWelcomePanel()) - { - getTabbedPane() - .remove(getTabbedPane() - .getComponentAt(getTabbedPane().indexOfTab("Welcome"))); + void addWelcomePanel() { + getTabbedPane().addANewTab( + "Welcome", welcomePanel, new ImageIcon(ChainsawIcons.ABOUT), + "Welcome/Help"); + } + + void removeWelcomePanel() { + if (getTabbedPane().containsWelcomePanel()) { + getTabbedPane().remove( + getTabbedPane().getComponentAt(getTabbedPane().indexOfTab("Welcome"))); } } - void toggleReceiversPanel() - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - receiversPanel.setVisible(!receiversPanel.isVisible()); - receiversPanel.invalidate(); - receiversPanel.validate(); + void toggleReceiversPanel() { + SwingUtilities.invokeLater( + new Runnable() { + public void run() { + receiversPanel.setVisible(!receiversPanel.isVisible()); + receiversPanel.invalidate(); + receiversPanel.validate(); - getToolBarAndMenus().stateChange(); - } - }); + getToolBarAndMenus().stateChange(); + } + }); } - boolean isReceiverPanelVisible() - { + boolean isReceiverPanelVisible() { return receiversPanel.isVisible(); } /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ - public ChainsawStatusBar getStatusBar() - { + public ChainsawStatusBar getStatusBar() { return statusBar; } - void showAboutBox() - { - if (aboutBox == null) - { + void showAboutBox() { + if (aboutBox == null) { aboutBox = new ChainsawAbout(this); } aboutBox.setVisible(true); } - Map getPanels() - { + Map getPanels() { Map m = new HashMap(); Set panelSet = getPanelMap().entrySet(); Iterator iter = panelSet.iterator(); - while (iter.hasNext()) - { + while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); - m.put(entry.getKey(), new Boolean(((DockablePanel) entry.getValue()) - .isDocked())); + m.put( + entry.getKey(), + new Boolean(((DockablePanel) entry.getValue()).isDocked())); } return m; } - void displayPanel(String panelName, boolean display) - { + void displayPanel(String panelName, boolean display) { Object o = getPanelMap().get(panelName); - if (o instanceof LogPanel) - { + if (o instanceof LogPanel) { LogPanel p = (LogPanel) o; int index = getTabbedPane().indexOfTab(panelName); - if ((index == -1) && display) - { + if ((index == -1) && display) { getTabbedPane().addTab(panelName, p); } - if ((index > -1) && !display) - { + if ((index > -1) && !display) { getTabbedPane().removeTabAt(index); } } @@ -1176,8 +1054,7 @@ /** * Shutsdown by ensuring the Appender gets a chance to close. */ - private void shutdown() - { + private void shutdown() { JWindow progress = new JWindow(); final ProgressPanel panel = new ProgressPanel(1, 3, "Shutting down"); progress.getContentPane().add(panel); @@ -1188,37 +1065,33 @@ progress.setLocation(p); progress.setVisible(true); - Runnable runnable = new Runnable() - { - public void run() - { - try - { - int progress = 1; - final int delay = 25; + Runnable runnable = + new Runnable() { + public void run() { + try { + int progress = 1; + final int delay = 25; - handler.close(); - panel.setProgress(progress++); + handler.close(); + panel.setProgress(progress++); - Thread.sleep(delay); + Thread.sleep(delay); - PluginRegistry.stopAllPlugins(); - panel.setProgress(progress++); + PluginRegistry.stopAllPlugins(); + panel.setProgress(progress++); - Thread.sleep(delay); + Thread.sleep(delay); - panel.setProgress(progress++); - Thread.sleep(delay); - } - catch (Exception e) - { - e.printStackTrace(); - } + panel.setProgress(progress++); + Thread.sleep(delay); + } catch (Exception e) { + e.printStackTrace(); + } - fireShutdownEvent(); - performShutdownAction(); - } - }; + fireShutdownEvent(); + performShutdownAction(); + } + }; new Thread(runnable).start(); } @@ -1226,13 +1099,12 @@ /** * Ensures all the registered ShutdownListeners are notified. */ - private void fireShutdownEvent() - { - ShutdownListener[] listeners = (ShutdownListener[]) shutdownListenerList - .getListeners(ShutdownListener.class); + private void fireShutdownEvent() { + ShutdownListener[] listeners = + (ShutdownListener[]) shutdownListenerList.getListeners( + ShutdownListener.class); - for (int i = 0; i < listeners.length; i++) - { + for (int i = 0; i < listeners.length; i++) { listeners[i].shuttingDown(); } } @@ -1241,98 +1113,80 @@ * Configures LogUI's with an action to execute when the user requests to * exit the application, the default action is to exit the VM. This Action is * called AFTER all the ShutdownListeners have been notified - * + * * @param shutdownAction */ - public final void setShutdownAction(Action shutdownAction) - { + public final void setShutdownAction(Action shutdownAction) { this.shutdownAction = shutdownAction; } /** * Using the current thread, calls the registed Shutdown action's * actionPerformed(...) method. - * + * */ - private void performShutdownAction() - { - if (LogLog.isDebugEnabled()) - { - LogLog.debug("Calling the shutdown Action. Goodbye!"); - } + private void performShutdownAction() { + LogLog.debug("Calling the shutdown Action. Goodbye!"); - shutdownAction.actionPerformed(new ActionEvent(this, - ActionEvent.ACTION_PERFORMED, "Shutting Down")); + shutdownAction.actionPerformed( + new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "Shutting Down")); } /** * Returns the currently selected LogPanel, if there is one, otherwise null - * + * * @return */ - LogPanel getCurrentLogPanel() - { + LogPanel getCurrentLogPanel() { Component selectedTab = getTabbedPane().getSelectedComponent(); - if (selectedTab instanceof LogPanel) - { + if (selectedTab instanceof LogPanel) { return (LogPanel) selectedTab; - } - else - { + } else { // System.out.println(selectedTab); } return null; } - void removeStatusBar() - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - getContentPane().remove(statusBar); - getContentPane().validate(); - getContentPane().repaint(); - } - }); + void removeStatusBar() { + SwingUtilities.invokeLater( + new Runnable() { + public void run() { + getContentPane().remove(statusBar); + getContentPane().validate(); + getContentPane().repaint(); + } + }); } - boolean isStatusBarVisible() - { + boolean isStatusBarVisible() { return getContentPane().isAncestorOf(statusBar); } - void addStatusBar() - { + void addStatusBar() { removeStatusBar(); - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - getContentPane().add(statusBar, BorderLayout.SOUTH); - getContentPane().validate(); - getContentPane().repaint(); - } - }); + SwingUtilities.invokeLater( + new Runnable() { + public void run() { + getContentPane().add(statusBar, BorderLayout.SOUTH); + getContentPane().validate(); + getContentPane().repaint(); + } + }); } /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ - public String getActiveTabName() - { + public String getActiveTabName() { int index = getTabbedPane().getSelectedIndex(); - if (index == -1) - { + if (index == -1) { return null; - } - else - { + } else { return getTabbedPane().getTitleAt(index); } } @@ -1340,16 +1194,13 @@ /** * Formats the individual elements of an LoggingEvent by ensuring that there * are no null bits, replacing them with EMPTY_STRING - * + * * @param v * @return */ - private Vector formatFields(Vector v) - { - for (int i = 0; i < v.size(); i++) - { - if (v.get(i) == null) - { + private Vector formatFields(Vector v) { + for (int i = 0; i < v.size(); i++) { + if (v.get(i) == null) { v.set(i, ChainsawConstants.EMPTY_STRING); } } @@ -1361,51 +1212,39 @@ * Regurgitates a DisplayFilter for a specific machine identifier by * deserializing the settings from a file. DisplayFilter serializes tool tip * fields and enabled flag. - * + * * @param ident * @return */ - private DisplayFilter loadDisplayFilter(String ident) - { + private DisplayFilter loadDisplayFilter(String ident) { DisplayFilter d = null; ObjectInputStream s = null; - File f = new File(SettingsManager.getInstance().getSettingsDirectory() - + File.separator + ident + ChainsawConstants.SETTINGS_EXTENSION); - - if (f.exists()) - { - try - { - s = new ObjectInputStream(new BufferedInputStream( - new FileInputStream(f))); + File f = + new File( + SettingsManager.getInstance().getSettingsDirectory() + File.separator + + ident + ChainsawConstants.SETTINGS_EXTENSION); + + if (f.exists()) { + try { + s = new ObjectInputStream( + new BufferedInputStream(new FileInputStream(f))); d = (DisplayFilter) s.readObject(); - } - catch (IOException ioe) - { + } catch (IOException ioe) { ioe.printStackTrace(); - } - catch (ClassNotFoundException cnfe) - { + } catch (ClassNotFoundException cnfe) { cnfe.printStackTrace(); - } - finally - { - if (s != null) - { - try - { + } finally { + if (s != null) { + try { s.close(); - } - catch (IOException ioe) - { + } catch (IOException ioe) { ioe.printStackTrace(); } } } } - if (d == null) - { + if (d == null) { d = new DisplayFilter(ident); } @@ -1415,46 +1254,39 @@ /** * Modify the saved Look And Feel - does not update the currently used Look * And Feel - * + * * @param lookAndFeelClassName * The FQN of the LookAndFeel */ - public void setLookAndFeel(String lookAndFeelClassName) - { + public void setLookAndFeel(String lookAndFeelClassName) { this.lookAndFeelClassName = lookAndFeelClassName; - JOptionPane.showMessageDialog(getContentPane(), - "Restart application for the new Look and Feel to take effect.", - "Look and Feel Updated", JOptionPane.INFORMATION_MESSAGE); + JOptionPane.showMessageDialog( + getContentPane(), + "Restart application for the new Look and Feel to take effect.", + "Look and Feel Updated", JOptionPane.INFORMATION_MESSAGE); } /** * Changes the currently used Look And Feel of the App - * + * * @param lookAndFeelClassName * The FQN of the LookANdFeel */ - private void applyLookAndFeel(String lookAndFeelClassName) - { - if (UIManager.getLookAndFeel().getClass().getName() - .equals(lookAndFeelClassName)) - { + private void applyLookAndFeel(String lookAndFeelClassName) { + if ( + UIManager.getLookAndFeel().getClass().getName().equals( + lookAndFeelClassName)) { LogLog.debug("No need to change L&F, already the same"); return; } - if (LogLog.isDebugEnabled()) - { - LogLog.debug("Setting L&F -> " + lookAndFeelClassName); - } + LogLog.debug("Setting L&F -> " + lookAndFeelClassName); - try - { + try { UIManager.setLookAndFeel(lookAndFeelClassName); SwingUtilities.updateComponentTreeUI(this); - } - catch (Exception e) - { + } catch (Exception e) { LogLog.error("Failed to change L&F", e); } } @@ -1462,12 +1294,11 @@ /** * Causes the Welcome Panel to become visible, and shows the URL specified as * it's contents - * + * * @param url * for content to show */ - void showHelp(URL url) - { + void showHelp(URL url) { removeWelcomePanel(); addWelcomePanel(); @@ -1477,23 +1308,20 @@ /** * DOCUMENT ME! - * + * * @return */ - private WelcomePanel getWelcomePanel() - { + private WelcomePanel getWelcomePanel() { return welcomePanel; } /** * DOCUMENT ME! - * + * * @return */ - public boolean isLogTreePanelVisible() - { - if (getCurrentLogPanel() == null) - { + public boolean isLogTreePanelVisible() { + if (getCurrentLogPanel() == null) { return false; } @@ -1502,18 +1330,18 @@ /* * (non-Javadoc) - * + * * @see org.apache.log4j.chainsaw.EventBatchListener#getInterestedIdentifier() */ + /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ - public String getInterestedIdentifier() - { + public String getInterestedIdentifier() { // this instance is interested in ALL event batches, as we determine how to - // route things + // route things return null; } @@ -1523,153 +1351,141 @@ // public Map getScrollMap() { // return scrollMap; // } + /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ - public Map getPanelMap() - { + public Map getPanelMap() { return panelMap; } // public Map getLevelMap() { // return levelMap; // } + /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ - public SettingsManager getSettingsManager() - { + public SettingsManager getSettingsManager() { return sm; } /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ - public List getFilterableColumns() - { + public List getFilterableColumns() { return filterableColumns; } /** * DOCUMENT ME! - * + * * @param tbms * DOCUMENT ME! */ - public void setToolBarAndMenus(ChainsawToolBarAndMenus tbms) - { + public void setToolBarAndMenus(ChainsawToolBarAndMenus tbms) { this.tbms = tbms; } /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ - public ChainsawToolBarAndMenus getToolBarAndMenus() - { + public ChainsawToolBarAndMenus getToolBarAndMenus() { return tbms; } /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ - public Map getTableMap() - { + public Map getTableMap() { return tableMap; } /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ - public Map getTableModelMap() - { + public Map getTableModelMap() { return tableModelMap; } /** * DOCUMENT ME! - * + * * @param tabbedPane * DOCUMENT ME! */ - public void setTabbedPane(ChainsawTabbedPane tabbedPane) - { + public void setTabbedPane(ChainsawTabbedPane tabbedPane) { this.tabbedPane = tabbedPane; } /** * DOCUMENT ME! - * + * * @return DOCUMENT ME! */ - public ChainsawTabbedPane getTabbedPane() - { + public ChainsawTabbedPane getTabbedPane() { return tabbedPane; } /** * DOCUMENT ME! */ - public void setupTutorial() - { - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); - setLocation(0, getLocation().y); - - double chainsawwidth = 0.7; - double tutorialwidth = 1 - chainsawwidth; - setSize((int) (screen.width * chainsawwidth), getSize().height); - invalidate(); - validate(); - - Dimension size = getSize(); - Point loc = getLocation(); - tutorialFrame - .setSize((int) (screen.width * tutorialwidth), size.height); - tutorialFrame.setLocation(loc.x + size.width, loc.y); - tutorialFrame.setVisible(true); - } - }); + public void setupTutorial() { + SwingUtilities.invokeLater( + new Runnable() { + public void run() { + Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); + setLocation(0, getLocation().y); + + double chainsawwidth = 0.7; + double tutorialwidth = 1 - chainsawwidth; + setSize((int) (screen.width * chainsawwidth), getSize().height); + invalidate(); + validate(); + + Dimension size = getSize(); + Point loc = getLocation(); + tutorialFrame.setSize( + (int) (screen.width * tutorialwidth), size.height); + tutorialFrame.setLocation(loc.x + size.width, loc.y); + tutorialFrame.setVisible(true); + } + }); } /** * This class handles the recption of the Event batches and creates new * LogPanels if the identifier is not in use otherwise it ignores the event * batch. - * + * * @author Paul Smith * - * + * */ - private class NewTabEventBatchReceiver implements EventBatchListener - { + private class NewTabEventBatchReceiver implements EventBatchListener { /** - * DOCUMENT ME! - * - * @param ident - * DOCUMENT ME! - * @param eventBatchEntrys - * DOCUMENT ME! - */ - public void receiveEventBatch(final String ident, - final List eventBatchEntrys) - { - if (eventBatchEntrys.size() == 0) - { + * DOCUMENT ME! + * + * @param ident + * DOCUMENT ME! + * @param eventBatchEntrys + * DOCUMENT ME! + */ + public void receiveEventBatch( + final String ident, final List eventBatchEntrys) { + if (eventBatchEntrys.size() == 0) { return; } @@ -1677,71 +1493,58 @@ JSortTable table; HashMap map = null; - if (!isGUIFullyInitialized) - { - synchronized (initializationLock) - { - while (!isGUIFullyInitialized) - { - System.out - .println("Wanting to add a row, but GUI not initialized, waiting..."); + if (!isGUIFullyInitialized) { + synchronized (initializationLock) { + while (!isGUIFullyInitialized) { + System.out.println( + "Wanting to add a row, but GUI not initialized, waiting..."); /** - * Lets wait 1 seconds and recheck. - */ - try - { + * Lets wait 1 seconds and recheck. + */ + try { initializationLock.wait(1000); - } - catch (InterruptedException e) - { + } catch (InterruptedException e) { } } } } - if (!getPanelMap().containsKey(ident)) - { - final String eventType = ((ChainsawEventBatchEntry) eventBatchEntrys - .get(0)) - .getEventType(); + if (!getPanelMap().containsKey(ident)) { + final String eventType = + ((ChainsawEventBatchEntry) eventBatchEntrys.get(0)).getEventType(); - final LogPanel thisPanel = new LogPanel(getStatusBar(), ident, - eventType); + final LogPanel thisPanel = + new LogPanel(getStatusBar(), ident, eventType); thisPanel.addEventCountListener(new TabIconHandler(ident)); - PropertyChangeListener toolbarMenuUpdateListener = new PropertyChangeListener() - { - public void propertyChange(PropertyChangeEvent evt) - { - tbms.stateChange(); - } - }; + PropertyChangeListener toolbarMenuUpdateListener = + new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + tbms.stateChange(); + } + }; thisPanel.addPropertyChangeListener(toolbarMenuUpdateListener); - thisPanel.getPreferenceModel() - .addPropertyChangeListener(toolbarMenuUpdateListener); + thisPanel.getPreferenceModel().addPropertyChangeListener( + toolbarMenuUpdateListener); - thisPanel.addPropertyChangeListener("docked", - new PropertyChangeListener() - { - public void propertyChange(PropertyChangeEvent evt) - { - LogPanel logPanel = (LogPanel) evt.getSource(); - - if (logPanel.isDocked()) - { - getPanelMap().put(logPanel.getIdentifier(), logPanel); - getTabbedPane() - .addANewTab(logPanel.getIdentifier(), logPanel, null); - } - else - { - getTabbedPane().remove(logPanel); - } + thisPanel.addPropertyChangeListener( + "docked", + new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + LogPanel logPanel = (LogPanel) evt.getSource(); + + if (logPanel.isDocked()) { + getPanelMap().put(logPanel.getIdentifier(), logPanel); + getTabbedPane().addANewTab( + logPanel.getIdentifier(), logPanel, null); + } else { + getTabbedPane().remove(logPanel); } - }); + } + }); getTabbedPane().add(ident, thisPanel); getPanelMap().put(ident, thisPanel); @@ -1750,25 +1553,24 @@ getSettingsManager().configure(thisPanel); /** - * Let the new LogPanel receive this batch - */ + * Let the new LogPanel receive this batch + */ thisPanel.receiveEventBatch(ident, eventBatchEntrys); /** - * Now add the panel as a batch listener so it can handle it's own - * batchs - */ + * Now add the panel as a batch listener so it can handle it's own + * batchs + */ handler.addEventBatchListener(thisPanel); - SwingUtilities.invokeLater(new Runnable() - { - public void run() - { - getTabbedPane() - .addANewTab(ident, thisPanel, new ImageIcon( - ChainsawIcons.ANIM_RADIO_TOWER)); - } - }); + SwingUtilities.invokeLater( + new Runnable() { + public void run() { + getTabbedPane().addANewTab( + ident, thisPanel, new ImageIcon( + ChainsawIcons.ANIM_RADIO_TOWER)); + } + }); String msg = "added tab " + ident; LogLog.debug(msg); @@ -1777,24 +1579,23 @@ } /* - * (non-Javadoc) - * - * @see org.apache.log4j.chainsaw.EventBatchListener#getInterestedIdentifier() - */ + * (non-Javadoc) + * + * @see org.apache.log4j.chainsaw.EventBatchListener#getInterestedIdentifier() + */ + /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public String getInterestedIdentifier() - { + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public String getInterestedIdentifier() { // we are interested in all batches so we can detect new identifiers return null; } } - class TabIconHandler implements EventCountListener - { + class TabIconHandler implements EventCountListener { private final String ident; private int lastCount; private int currentCount; @@ -1805,77 +1606,63 @@ ImageIcon NEW_EVENTS = new ImageIcon(ChainsawIcons.ANIM_RADIO_TOWER); ImageIcon HAS_EVENTS = new ImageIcon(ChainsawIcons.INFO); - public TabIconHandler(final String ident) - { + public TabIconHandler(final String ident) { this.ident = ident; - new Thread(new Runnable() - { - public void run() - { - while (true) - { - //if this tab is active, remove the icon - if ((getTabbedPane().getSelectedIndex() > -1) - && (getTabbedPane().getSelectedIndex() == getTabbedPane() - .indexOfTab(ident))) - { - getTabbedPane() - .setIconAt(getTabbedPane().indexOfTab(ident), null); - - //reset fields so no icon will display - lastCount = currentCount; - hasNewEvents = false; - } - else - { - //don't process undocked tabs - if (getTabbedPane().indexOfTab(ident) > -1) - { - //if the tab is not active and the counts don't match, set the - // new events icon - if (lastCount != currentCount) - { - getTabbedPane() - .setIconAt(getTabbedPane().indexOfTab(ident), NEW_EVENTS); - lastCount = currentCount; - hasNewEvents = true; - } - else - { - if (hasNewEvents) - { - getTabbedPane() - .setIconAt(getTabbedPane().indexOfTab(ident), - HAS_EVENTS); + new Thread( + new Runnable() { + public void run() { + while (true) { + //if this tab is active, remove the icon + if ( + (getTabbedPane().getSelectedIndex() > -1) + && (getTabbedPane().getSelectedIndex() == getTabbedPane() + .indexOfTab( + ident))) { + getTabbedPane().setIconAt( + getTabbedPane().indexOfTab(ident), null); + + //reset fields so no icon will display + lastCount = currentCount; + hasNewEvents = false; + } else { + //don't process undocked tabs + if (getTabbedPane().indexOfTab(ident) > -1) { + //if the tab is not active and the counts don't match, set the + // new events icon + if (lastCount != currentCount) { + getTabbedPane().setIconAt( + getTabbedPane().indexOfTab(ident), NEW_EVENTS); + lastCount = currentCount; + hasNewEvents = true; + } else { + if (hasNewEvents) { + getTabbedPane().setIconAt( + getTabbedPane().indexOfTab(ident), HAS_EVENTS); + } } } } - } - try - { - Thread.sleep(handler.getQueueInterval() + 1000); - } - catch (InterruptedException ie) - { + try { + Thread.sleep(handler.getQueueInterval() + 1000); + } catch (InterruptedException ie) { + } } } - } - }).start(); + }).start(); } /** - * DOCUMENT ME! - * - * @param currentCount - * DOCUMENT ME! - * @param totalCount - * DOCUMENT ME! - */ - public void eventCountChanged(int currentCount, int totalCount) - { + * DOCUMENT ME! + * + * @param currentCount + * DOCUMENT ME! + * @param totalCount + * DOCUMENT ME! + */ + public void eventCountChanged(int currentCount, int totalCount) { this.currentCount = currentCount; } } -} \ No newline at end of file +} --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: log4j-dev-help@jakarta.apache.org