logging-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From psm...@apache.org
Subject svn commit: r555864 - in /logging/chainsaw/trunk/src: changes/changes.xml main/java/org/apache/log4j/chainsaw/LogUI.java
Date Fri, 13 Jul 2007 04:01:07 GMT
Author: psmith
Date: Thu Jul 12 21:01:07 2007
New Revision: 555864

URL: http://svn.apache.org/viewvc?view=rev&rev=555864
Log:
Bug 42833 Added ability to hide Welcome and Drag and Drop panels.

Patch supplied by Isuru Suriarachchi

Modified:
    logging/chainsaw/trunk/src/changes/changes.xml
    logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java

Modified: logging/chainsaw/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/changes/changes.xml?view=diff&rev=555864&r1=555863&r2=555864
==============================================================================
--- logging/chainsaw/trunk/src/changes/changes.xml (original)
+++ logging/chainsaw/trunk/src/changes/changes.xml Thu Jul 12 21:01:07 2007
@@ -21,12 +21,16 @@
   </properties>
   <body>
       <release version="1.99.99" date="UNKNOWN" description="">
-      <action dev="psmith" issue="42789" type="add" due-to=" Isuru Suriarachchi  " due-to-email="">
+      <action dev="psmith" issue="42789" type="add" due-to="Isuru Suriarachchi" due-to-email="">
 		Added support for remembering filter expressions for each LogPanel
       </action>
-      <action dev="psmith" issue="42851" type="add" due-to=" Isuru Suriarachchi  " due-to-email="">
+      <action dev="psmith" issue="42851" type="add" due-to="Isuru Suriarachchi" due-to-email="">
 		Added 'Go To Line' feature to navigate to a particular event #
       </action>
+      <action dev="psmith" issue="42883" type="add" due-to="Isuru Suriarachchi" due-to-email="">
+		Added ability to hide Welcome and Drag and Drop panels.
+      </action>
+
     </release>
   </body>
 </document>

Modified: logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java
URL: http://svn.apache.org/viewvc/logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java?view=diff&rev=555864&r1=555863&r2=555864
==============================================================================
--- logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java (original)
+++ logging/chainsaw/trunk/src/main/java/org/apache/log4j/chainsaw/LogUI.java Thu Jul 12 21:01:07
2007
@@ -456,16 +456,7 @@
             
         }});
    
-    final JLabel lbl  = new JLabel();
-    lbl.setEnabled(false);
-    final String dndTitle = "Drag & Drop XML log files here";
-    SwingUtilities.invokeLater(new Runnable() {
-    	public void run() {
-    	    ensureWelcomePanelVisible();
-    	    getTabbedPane().addANewTab(dndTitle,lbl,null, "You can Drag & Drop XML log files
onto the Tabbed Pane and they will be loaded into Chainsaw" );
-    	    getTabbedPane().setEnabledAt(getTabbedPane().indexOfTab(dndTitle), false);
-    	}
-    });
+    addDragDropPanel();
     applicationPreferenceModelPanel = new ApplicationPreferenceModelPanel(applicationPreferenceModel);
     applicationPreferenceModelPanel.setOkCancelActionListener(
       new ActionListener() {
@@ -478,6 +469,23 @@
   
   }
 
+  private void addDragDropPanel(){
+    final JLabel lbl  = new JLabel();
+    lbl.setEnabled(false);
+    final String dndTitle = "Drag & Drop XML log files here";
+    SwingUtilities.invokeLater(new Runnable() {
+    	public void run() {
+    	    ensureWelcomePanelVisible();
+    	    getTabbedPane().addANewTab(dndTitle,lbl,null, "You can Drag & Drop XML log files
onto the Tabbed Pane and they will be loaded into Chainsaw" );
+    	    getTabbedPane().setEnabledAt(getTabbedPane().indexOfTab(dndTitle), false);
+            if (!getPanelMap().containsKey(dndTitle)) {
+              getPanelMap().put(dndTitle, lbl);
+            }
+        }
+    });
+  }
+
+
   private void initPlugins(PluginRegistry pluginRegistry) {
     pluginRegistry.addPluginListener(
       new PluginListener() {
@@ -804,15 +812,28 @@
     final Action hideCurrentTabAction =
       new AbstractAction("Hide") {
         public void actionPerformed(ActionEvent e) {
-          displayPanel(getCurrentLogPanel().getIdentifier(), false);
-          tbms.stateChange();
+          Component selectedComp = getTabbedPane().getSelectedComponent();
+          if (selectedComp instanceof LogPanel) {
+            displayPanel(getCurrentLogPanel().getIdentifier(), false);
+            tbms.stateChange();
+          } else {
+            getTabbedPane().remove(selectedComp);
+          }
         }
       };
 
     final Action hideOtherTabsAction =
       new AbstractAction("Hide Others") {
         public void actionPerformed(ActionEvent e) {
-          String currentName = getCurrentLogPanel().getIdentifier();
+          Component selectedComp = getTabbedPane().getSelectedComponent();
+          String currentName;
+          if (selectedComp instanceof LogPanel) {
+            currentName = getCurrentLogPanel().getIdentifier();
+          } else if (selectedComp instanceof WelcomePanel) {
+            currentName = "Welcome";
+          } else {
+            currentName = "Drag & Drop XML log files here";
+          }
 
           int count = getTabbedPane().getTabCount();
           int index = 0;
@@ -871,28 +892,6 @@
     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() {
@@ -1418,6 +1417,7 @@
       "Welcome",  new ImageIcon(ChainsawIcons.ABOUT),welcomePanel,
       "Welcome/Help", 0);
     getTabbedPane().setSelectedComponent(welcomePanel);
+    getPanelMap().put("Welcome", welcomePanel);
   }
 
   void removeWelcomePanel() {
@@ -1451,9 +1451,14 @@
 
     while (iter.hasNext()) {
       Map.Entry entry = (Map.Entry) iter.next();
-      m.put(
-        entry.getKey(),
-        new Boolean(((DockablePanel) entry.getValue()).isDocked()));
+      Object o = entry.getValue();
+      boolean valueToSend;
+      if (o instanceof LogPanel){
+        valueToSend = ((DockablePanel) entry.getValue()).isDocked();
+      } else {
+        valueToSend = true;
+      }
+      m.put(entry.getKey(), new Boolean(valueToSend));
     }
 
     return m;
@@ -1461,21 +1466,31 @@
 
   void displayPanel(String panelName, boolean display) {
     Object o = getPanelMap().get(panelName);
+    Component p = null;
 
     if (o instanceof LogPanel) {
-      LogPanel p = (LogPanel) o;
+      p = (LogPanel) o;
+    } else if (o instanceof WelcomePanel) {
+      p = (WelcomePanel) o;
+    } else if (o instanceof JLabel) {
+      p = (JLabel) o;
+    }
 
       int index = getTabbedPane().indexOfTab(panelName);
 
       if ((index == -1) && display) {
-        getTabbedPane().addTab(panelName, p);
+        if (panelName.equals("Drag & Drop XML log files here")){
+          addDragDropPanel();
+        } else {
+          getTabbedPane().addTab(panelName, p);
+        }
       }
 
       if ((index > -1) && !display) {
         getTabbedPane().removeTabAt(index);
       }
-    }
-  }
+   }
+  
 
   /**
    * Shutsdown by ensuring the Appender gets a chance to close.



Mime
View raw message