psmith 2003/12/04 02:40:52 Modified: src/java/org/apache/log4j/chainsaw LogUI.java Log: Fixed NPE bug found by [EMAIL PROTECTED] when attempting to close the welcome panel using the right click popup menu on the tabs. Also reordered the position of this popup code so the L&F changes affected the popup menu (was staying in the Metal L&F). Now listens for tabs being removed, and disables the hide actions if the Welcome panel has been selected. Tutorial Frame toolbar now tracks whether there are any Tutorial Generator Receivers running, and if not, ensures that the Start Tutorial button does not stay activated. Revision Changes Path 1.45 +103 -68 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.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- LogUI.java 3 Dec 2003 04:04:18 -0000 1.44 +++ LogUI.java 4 Dec 2003 10:40:52 -0000 1.45 @@ -78,6 +78,8 @@ import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.ContainerEvent; +import java.awt.event.ContainerListener; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; @@ -326,73 +328,6 @@ setJMenuBar(getToolBarAndMenus().getMenubar()); setTabbedPane(new ChainsawTabbedPane()); - // 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 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++; - } - } - } - }; - - 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); - - if (name.equals(identifier)) { - found = true; - - break; - } - } - - if (!found) { - displayPanel(identifier, true); - tbms.stateChange(); - } - } - } - }; - - tabPopup.add(hideCurrentTabAction); - tabPopup.add(hideOtherTabsAction); - tabPopup.addSeparator(); - tabPopup.add(showHiddenTabsAction); - - final PopupListener tabPopupListener = new PopupListener(tabPopup); - getTabbedPane().addMouseListener(tabPopupListener); } /** @@ -703,7 +638,94 @@ }); pack(); + + final JPopupMenu tabPopup = new JPopupMenu(); + final Action hideCurrentTabAction = + new AbstractAction("Hide") { + public void actionPerformed(ActionEvent e) { + displayPanel(getCurrentLogPanel().getIdentifier(), false); + tbms.stateChange(); + } + }; + + final 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++; + } + } + } + }; + + 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); + + if (name.equals(identifier)) { + found = true; + + break; + } + } + + if (!found) { + displayPanel(identifier, true); + tbms.stateChange(); + } + } + } + }; + + tabPopup.add(hideCurrentTabAction); + tabPopup.add(hideOtherTabsAction); + tabPopup.addSeparator(); + tabPopup.add(showHiddenTabsAction); + + final PopupListener tabPopupListener = new PopupListener(tabPopup); + getTabbedPane().addMouseListener(tabPopupListener); + + final ChangeListener actionEnabler = new ChangeListener(){ + + public void stateChanged(ChangeEvent arg0) { + boolean enabled = getCurrentLogPanel()!=null; + hideCurrentTabAction.setEnabled(enabled); + hideOtherTabsAction.setEnabled(enabled); + }}; + + getTabbedPane().addChangeListener(actionEnabler); + + getTabbedPane().addContainerListener(new ContainerListener(){ + + public void componentAdded(ContainerEvent arg0) { + actionEnabler.stateChanged(null); + } + + public void componentRemoved(ContainerEvent arg0) { + actionEnabler.stateChanged(null); + }}); + this.handler.addPropertyChangeListener( "dataRate", new PropertyChangeListener() { @@ -761,7 +783,7 @@ } } }; - + final Action stopTutorial = new AbstractAction( "Stop Tutorial", new ImageIcon(ChainsawIcons.ICON_STOP_RECEIVER)) { @@ -810,6 +832,19 @@ startTutorial.addPropertyChangeListener(pcl); stopTutorial.addPropertyChangeListener(pcl); + + PluginRegistry.addPluginListener(new PluginListener(){ + + public void pluginStarted(PluginEvent e) { + + } + + public void pluginStopped(PluginEvent e) { + List list = PluginRegistry.getPlugins(LogManager.getLoggerRepository(), Generator.class); + if (list.size() == 0) { + startTutorial.putValue("TutorialStarted", Boolean.FALSE); + } + }}); final SmallButton stopButton = new SmallButton(stopTutorial);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]