sdeboy      2003/06/19 23:57:41

  Modified:    src/java/org/apache/log4j/chainsaw LogUI.java
                        FileSaveAction.java ChainsawTabbedPane.java
                        FileMenu.java FileLoadAction.java
                        ChainsawToolBarAndMenus.java
  Log:
  - Updated code that applies the Look & Feel - ensured L&F is set prior to any UI 
component creation and removed unneeded L&F updateComponentTreeUI code in the 
individual components
  - Fixed welcome panel menu disabling once welcome panel was closed
  
  Revision  Changes    Path
  1.112     +33 -27    
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/LogUI.java
  
  Index: LogUI.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/LogUI.java,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- LogUI.java        20 Jun 2003 04:49:12 -0000      1.111
  +++ LogUI.java        20 Jun 2003 06:57:39 -0000      1.112
  @@ -201,7 +201,7 @@
     private JPanel receiversPanel;
     ChainsawTabbedPane tabbedPane;
     private JToolBar toolbar;
  -  private final ChainsawStatusBar statusBar = new ChainsawStatusBar();
  +  private ChainsawStatusBar statusBar;
     private final Map tableModelMap = new HashMap();
     private final Map tableMap = new HashMap();
     final List pausedList = new Vector();
  @@ -283,10 +283,12 @@
      *
      */
     private void initGUI() {
  +     statusBar = new ChainsawStatusBar();
       receiversPanel = new ReceiversPanel(this);
       tbms = new ChainsawToolBarAndMenus(this);
       toolbar = tbms.getToolbar();
       setJMenuBar(tbms.getMenubar());
  +    tabbedPane = new ChainsawTabbedPane();
     }
   
     /**
  @@ -294,17 +296,6 @@
      * etc etc.
      */
     public void loadSettings(LoadSettingsEvent event) {
  -    lookAndFeelClassName = event.getSetting(LogUI.LOOK_AND_FEEL);
  -
  -    if (lookAndFeelClassName != null) {
  -      SwingUtilities.invokeLater(
  -        new Runnable() {
  -          public void run() {
  -            applyLookAndFeel(lookAndFeelClassName);
  -          }
  -        });
  -    }
  -
       if (event.asBoolean(LogUI.STATUS_BAR)) {
         addStatusBar();
       } else {
  @@ -344,12 +335,30 @@
      * layout, table columns, and sets itself viewable.
      */
     public void activateViewer() {
  +    sm.configure(
  +      new SettingsListener() {
  +        public void loadSettings(LoadSettingsEvent event) {
  +          lookAndFeelClassName = event.getSetting(LogUI.LOOK_AND_FEEL);
  +
  +          if (lookAndFeelClassName != null) {
  +            applyLookAndFeel(lookAndFeelClassName);
  +          }
  +        }
  +
  +        public void saveSettings(SaveSettingsEvent event) {
  +          //required because of SettingsListener interface..not used during load
  +        }
  +      });
  +
  +
       if (
         PluginRegistry.getPlugins(
             LogManager.getLoggerRepository(), Receiver.class).size() == 0) {
         noReceiversDefined = true;
       }
   
  +    initGUI();
  +
       /**
        * Get all the SocketReceivers and configure a new SocketNodeEventListener
        * so we can get notified of new Sockets
  @@ -374,8 +383,6 @@
         item.addSocketNodeEventListener(socketListener);
       }
   
  -    initGUI();
  -
       List utilList = UtilLoggingLevel.getAllPossibleLevels();
   
       // TODO: Replace the array list creating with the standard way of retreiving 
the Level set. (TBD)
  @@ -411,14 +418,16 @@
   
       getContentPane().setLayout(new BorderLayout());
   
  -    tabbedPane = new ChainsawTabbedPane();
       tabbedPane.addChangeListener(tbms);
  -    tabbedPane.addChangeListener(new ChangeListener() {
  -     //received a statechange event - selection changed - remove icon from selected 
index
  -     public void stateChanged(ChangeEvent e) {
  -                     tabbedPane.setIconAt(tabbedPane.getSelectedIndex(), null);     
         
  -     }
  -    });
  +    tabbedPane.addChangeListener(
  +      new ChangeListener() {
  +        //received a statechange event - selection changed - remove icon from 
selected index
  +        public void stateChanged(ChangeEvent e) {
  +          if (tabbedPane.getSelectedComponent() instanceof ChainsawTabbedPane) {
  +            tabbedPane.setIconAt(tabbedPane.getSelectedIndex(), null);
  +          }
  +        }
  +      });
   
       KeyStroke ksRight =
         KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, Event.CTRL_MASK);
  @@ -944,7 +953,8 @@
         SwingUtilities.invokeLater(
           new Runnable() {
             public void run() {
  -            tabbedPane.addANewTab(ident, thisPanel, new 
ImageIcon(ChainsawIcons.TOOL_TIP));
  +            tabbedPane.addANewTab(
  +              ident, thisPanel, new ImageIcon(ChainsawIcons.TOOL_TIP));
             }
           });
   
  @@ -1057,12 +1067,7 @@
       try {
         UIManager.setLookAndFeel(lookAndFeelClassName);
         SwingUtilities.updateComponentTreeUI(this);
  -      SwingUtilities.updateComponentTreeUI(receiversPanel);
  -      tbms.lookAndFeelUpdated();
   
  -      if (tbms != null) {
  -        tbms.stateChange();
  -      }
       } catch (Exception e) {
         LogLog.error("Failed to change L&F", e);
       }
  @@ -2183,6 +2188,7 @@
       private final String ident;
       private int lastCount;
       private int currentCount;
  +
       //the tabIconHandler is associated with a new tab, and a new tab always
       //has new events
       private boolean hasNewEvents = true;
  
  
  
  1.11      +0 -6      
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/FileSaveAction.java
  
  Index: FileSaveAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/FileSaveAction.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- FileSaveAction.java       18 Jun 2003 19:10:21 -0000      1.10
  +++ FileSaveAction.java       20 Jun 2003 06:57:40 -0000      1.11
  @@ -103,12 +103,6 @@
       this.parent = parent;
     }
     
  -  void lookAndFeelUpdated() {
  -    if (chooser !=null) {
  -      SwingUtilities.updateComponentTreeUI(chooser);
  -    }
  -  }
  -  
     /*
      * When the user chooses the Save action,
      * a File chooser is presented to allow them to
  
  
  
  1.3       +79 -22    
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawTabbedPane.java
  
  Index: ChainsawTabbedPane.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawTabbedPane.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ChainsawTabbedPane.java   19 Jun 2003 05:50:12 -0000      1.2
  +++ ChainsawTabbedPane.java   20 Jun 2003 06:57:40 -0000      1.3
  @@ -1,4 +1,53 @@
   /*
  + * ============================================================================
  + *                   The Apache Software License, Version 1.1
  + * ============================================================================
  + *
  + *    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
  + *    [EMAIL PROTECTED]
  + *
  + * 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
  + * 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 <http://www.apache.org/>.
  + *
  + */
  +
  +/*
    * @author Paul Smith <[EMAIL PROTECTED]>
    *
   */
  @@ -10,10 +59,11 @@
   import javax.swing.JComponent;
   import javax.swing.JTabbedPane;
   
  +
   /**
  - * The only reason this class is needed is because 
  + * The only reason this class is needed is because
    * of a stupid 'issue' with the JTabbedPane.
  - * 
  + *
    * If the currently selected tab is the first tab,
    * and we insert a new tab at the front, then as
    * far as the JTabbedPane is concerned, NO STATE has
  @@ -21,16 +71,15 @@
    * the same (even though the TAB is different - go figure)
    * and therefore no ChangeEvent is generated and sent
    * to listeners.  Thanks very much Sun!
  - * 
  + *
    * @see http://developer.java.sun.com/developer/bugParade/bugs/4253819.html
    * @author Paul Smith <[EMAIL PROTECTED]>
  + * @author Scott Deboy <[EMAIL PROTECTED]>
    *
    */
   class ChainsawTabbedPane extends JTabbedPane {
  -
  -
     /**
  -   * 
  +   *
      */
     public ChainsawTabbedPane() {
       super();
  @@ -43,27 +92,24 @@
       super(tabPlacement);
       setBorder(null);
     }
  -  
  +
     /**
      * Returns true if this TabbedPane has an instance of the WelcomePanel
      * in it
      * @return true/false
      */
     boolean containsWelcomePanel() {
  -    return indexOfTab("Welcome")>-1;
  +    return indexOfTab("Welcome") > -1;
     }
   
  -
  -  
  -  
     /**
  -   * Our custom implementation of inserting a new tab, 
  +   * Our custom implementation of inserting a new tab,
      * this method ALWAYS inserts it at the front because
      * we get an ArrayIndexOutOfBoundsException otherwise
      * under some JDK implementations.
  -   * 
  +   *
      * This method also causes a fireStateChange() to be
  -   * called so that listeners get notified of the event.  
  +   * called so that listeners get notified of the event.
      * See the class level comments for the reason why...
      * @param name
      * @param component
  @@ -71,27 +117,38 @@
     public void addANewTab(String name, JComponent component, Icon icon) {
       int selectedIndex = getSelectedIndex();
       super.insertTab(name, icon, component, null, 0);
  -    setSelectedIndex(selectedIndex+1);
  +
  +    if (getTabCount() >= (selectedIndex + 1)) {
  +      setSelectedIndex(selectedIndex + 1);
  +    }
  +
       super.fireStateChanged();
     }
   
     public void setSelectedTab(int index) {
  -     setSelectedIndex(index); 
  -     getSelectedComponent().setVisible(true);
  +    if (getTabCount() >= index) {
  +      setSelectedIndex(index);
  +    }
  +
  +    getSelectedComponent().setVisible(true);
       getSelectedComponent().validate();
       super.fireStateChanged();
     }
  -    
  -  public void addANewTab(String name, JComponent component, Icon icon, String 
tooltip) {
  +
  +  public void addANewTab(
  +    String name, JComponent component, Icon icon, String tooltip) {
       int selectedIndex = getSelectedIndex();
       super.insertTab(name, icon, component, tooltip, 0);
  -    setSelectedIndex(selectedIndex+1);
  +
  +    if (getTabCount() >= (selectedIndex + 1)) {
  +      setSelectedIndex(selectedIndex + 1);
  +    }
  +
       super.fireStateChanged();
     }
  -  
  +
     public void remove(Component component) {
       super.remove(component);
       super.fireStateChanged();
     }
  -
   }
  
  
  
  1.11      +0 -6      
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/FileMenu.java
  
  Index: FileMenu.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/FileMenu.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- FileMenu.java     18 Jun 2003 01:55:41 -0000      1.10
  +++ FileMenu.java     20 Jun 2003 06:57:40 -0000      1.11
  @@ -64,12 +64,6 @@
       add(menuItemExit);
     }
     
  -  void lookAndFeelUpdated() {
  -    ((FileSaveAction)saveAction).lookAndFeelUpdated();
  -    ((FileLoadAction)loadLog4JAction).lookAndFeelUpdated();
  -    ((FileLoadAction)loadUtilLoggingAction).lookAndFeelUpdated();
  -  }
  -  
     Action getLog4JFileOpenAction() { return loadLog4JAction;}
     Action getUtilLoggingJFileOpenAction() { return loadUtilLoggingAction;}
     Action getFileSaveAction() { return saveAction;}
  
  
  
  1.12      +0 -5      
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/FileLoadAction.java
  
  Index: FileLoadAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/FileLoadAction.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FileLoadAction.java       18 Jun 2003 02:07:54 -0000      1.11
  +++ FileLoadAction.java       20 Jun 2003 06:57:40 -0000      1.12
  @@ -164,9 +164,4 @@
         }
       }
     }
  -  void lookAndFeelUpdated() {
  -    if (chooser!=null) {
  -      SwingUtilities.updateComponentTreeUI(chooser);
  -    }
  -  }
   }
  
  
  
  1.45      +1 -9      
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java
  
  Index: ChainsawToolBarAndMenus.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawToolBarAndMenus.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- ChainsawToolBarAndMenus.java      18 Jun 2003 22:24:01 -0000      1.44
  +++ ChainsawToolBarAndMenus.java      20 Jun 2003 06:57:40 -0000      1.45
  @@ -394,10 +394,6 @@
       return toolbar;
     }
   
  -  void lookAndFeelUpdated() {
  -    fileMenu.lookAndFeelUpdated();
  -  }
  -
     private Action createClearAction() {
       final Action action =
         new AbstractAction("Clear") {
  @@ -1022,11 +1018,7 @@
         logui.getStatusBar().clear();
         findTextField.setEnabled(false);
   
  -      if (logui.tabbedPane.containsWelcomePanel()) {
  -        closeAction.setEnabled(true);
  -      } else {
  -        closeAction.setEnabled(false);
  -      }
  +      closeAction.setEnabled(true);
       } else {
         fileMenu.getFileSaveAction().setEnabled(true);
         findTextField.setEnabled(true);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to