logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From psm...@apache.org
Subject cvs commit: jakarta-log4j/src/java/org/apache/log4j/chainsaw WelcomePanel.java
Date Mon, 22 Sep 2003 07:01:23 GMT
psmith      2003/09/22 00:01:23

  Modified:    src/java/org/apache/log4j/chainsaw WelcomePanel.java
  Log:
  Changes so that the Welcome panel can kick of the Tutorial.
  
  Revision  Changes    Path
  1.5       +48 -53    jakarta-log4j/src/java/org/apache/log4j/chainsaw/WelcomePanel.java
  
  Index: WelcomePanel.java
  ===================================================================
  RCS file: /home/cvs/jakarta-log4j/src/java/org/apache/log4j/chainsaw/WelcomePanel.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WelcomePanel.java	19 Sep 2003 08:15:33 -0000	1.4
  +++ WelcomePanel.java	22 Sep 2003 07:01:23 -0000	1.5
  @@ -49,20 +49,12 @@
   
   package org.apache.log4j.chainsaw;
   
  -import org.apache.log4j.chainsaw.help.Tutorial;
  -import org.apache.log4j.chainsaw.icons.ChainsawIcons;
  -
   import java.awt.BorderLayout;
   import java.awt.Color;
   import java.awt.Dimension;
  -import java.awt.GridBagConstraints;
  -import java.awt.GridBagLayout;
   import java.awt.event.ActionEvent;
  -
   import java.io.IOException;
  -
   import java.net.URL;
  -
   import java.util.Stack;
   
   import javax.swing.AbstractAction;
  @@ -73,12 +65,13 @@
   import javax.swing.JEditorPane;
   import javax.swing.JPanel;
   import javax.swing.JScrollPane;
  -import javax.swing.JSeparator;
   import javax.swing.JToolBar;
   import javax.swing.SwingUtilities;
   import javax.swing.event.HyperlinkEvent;
   import javax.swing.event.HyperlinkListener;
   
  +import org.apache.log4j.chainsaw.icons.ChainsawIcons;
  +
   
   /**
    * An initial Welcome Panel that is used when Chainsaw starts up, displays
  @@ -89,30 +82,32 @@
    * @author Scott Deboy <sdeboy@apache.org>
    */
   public class WelcomePanel extends JPanel {
  -  private static WelcomePanel instance = new WelcomePanel();
     private Stack urlStack = new Stack();
     private final JEditorPane textInfo = new JEditorPane();
  -  private final URLToolbar urlToolbar =  new URLToolbar();
  +  private final URLToolbar urlToolbar = new URLToolbar();
     private final URL helpURL;
     private final URL exampleConfigURL;
     private final URL tutorialURL;
  -  
  -  private WelcomePanel() {
  +  private LogUI logui;
  +
  +  public WelcomePanel(LogUI logui) {
       setLayout(new BorderLayout());
  +    this.logui = logui;
       setBackground(Color.white);
       add(urlToolbar, BorderLayout.NORTH);
   
  -     helpURL =
  +    helpURL =
         getClass().getClassLoader().getResource(
           "org/apache/log4j/chainsaw/WelcomePanel.html");
  -        
  +
       exampleConfigURL =
  -    getClass().getClassLoader().getResource(
  -      "org/apache/log4j/chainsaw/log4j-receiver-sample.xml");
  +      getClass().getClassLoader().getResource(
  +        "org/apache/log4j/chainsaw/log4j-receiver-sample.xml");
  +
  +    tutorialURL =
  +      getClass().getClassLoader().getResource(
  +        "org/apache/log4j/chainsaw/help/tutorial.html");
   
  -	tutorialURL =    getClass().getClassLoader().getResource(
  -	"org/apache/log4j/chainsaw/help/tutorial.html");
  - 
       if (helpURL != null) {
         textInfo.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
         textInfo.setEditable(false);
  @@ -128,9 +123,6 @@
             new HyperlinkListener() {
               public void hyperlinkUpdate(HyperlinkEvent e) {
                 if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
  -				if(e.getDescription().equals("StartTutorial")){
  -					new Thread(new Tutorial()).start();	
  -				}else{
                   urlStack.add(textInfo.getPage());
   
                   try {
  @@ -139,7 +131,6 @@
                   } catch (IOException e1) {
                     e1.printStackTrace();
                   }
  -				}
                 }
               }
             });
  @@ -148,7 +139,7 @@
         }
       }
     }
  -  
  +
     void setURL(final URL url) {
       SwingUtilities.invokeLater(
         new Runnable() {
  @@ -162,7 +153,13 @@
             }
           }
         });
  -    
  +  }
  +
  +  /**
  +   * @return
  +   */
  +  public final URL getTutorialURL() {
  +    return tutorialURL;
     }
   
     private class URLToolbar extends JToolBar {
  @@ -172,11 +169,11 @@
             if (urlStack.isEmpty()) {
               return;
             }
  -          setURL((URL)urlStack.pop());
   
  +          setURL((URL) urlStack.pop());
           }
         };
  -      
  +
       private final Action homeAction =
         new AbstractAction(null, new ImageIcon(ChainsawIcons.ICON_HOME)) {
           public void actionPerformed(ActionEvent e) {
  @@ -186,35 +183,41 @@
         };
   
       private URLToolbar() {
  -    	setFloatable(false);
  +      setFloatable(false);
         updateToolbar();
         previousAction.putValue(Action.SHORT_DESCRIPTION, "Back");
         homeAction.putValue(Action.SHORT_DESCRIPTION, "Home");
   
         JButton home = new SmallButton(homeAction);
         add(home);
  -      
  -	  addSeparator();      
  +
  +      addSeparator();
  +
         JButton previous = new SmallButton(previousAction);
         previous.setEnabled(false);
         add(previous);
  -      
  +
         addSeparator();
  -      add(new SmallButton(new AbstractAction("Tutorial"){
  +      add(
  +        new SmallButton(
  +          new AbstractAction("Tutorial", new ImageIcon(ChainsawIcons.HELP)) {
  +          public void actionPerformed(ActionEvent e) {
  +            logui.setupTutorial();
  +          }
  +        }));
  +      addSeparator();
  +
  +      final Action exampleConfigAction =
  +        new AbstractAction("View example Receiver configuration") {
  +          public void actionPerformed(ActionEvent e) {
  +            setURL(exampleConfigURL);
  +          }
  +        };
   
  -		public void actionPerformed(ActionEvent e) {
  -			setURL(tutorialURL);
  -			
  -		}}));
  -	addSeparator();
  -      final Action exampleConfigAction = new AbstractAction("View example Receiver configuration"){
  +      exampleConfigAction.putValue(
  +        Action.SHORT_DESCRIPTION,
  +        "Displays an example Log4j configuration file with several Receivers defined.");
   
  -        public void actionPerformed(ActionEvent e) {
  -          setURL(exampleConfigURL);
  -          
  -        }};
  -      exampleConfigAction.putValue(Action.SHORT_DESCRIPTION, "Displays an example Log4j
configuration file with several Receivers defined.");
  -      
         JButton exampleButton = new SmallButton(exampleConfigAction);
         add(exampleButton);
   
  @@ -226,12 +229,4 @@
         previousAction.setEnabled(!urlStack.isEmpty());
       }
     }
  -  /**
  -   * 
  -   */
  -  public static WelcomePanel getInstance() {
  -    return instance;
  -    
  -  }
  -  
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-dev-help@jakarta.apache.org


Mime
View raw message