Clover coverage report -
Coverage timestamp: Sun Apr 18 2004 21:32:30 EDT
file stats: LOC: 176   Methods: 5
NCLOC: 79   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AboutBox.java 50% 97.8% 100% 94.4%
coverage coverage
 1   
 /*
 2   
  * SimplyHTML, a word processor based on Java, HTML and CSS
 3   
  * Copyright (C) 2002 Ulrich Hilger
 4   
  *
 5   
  * This program is free software; you can redistribute it and/or
 6   
  * modify it under the terms of the GNU General Public License
 7   
  * as published by the Free Software Foundation; either version 2
 8   
  * of the License, or (at your option) any later version.
 9   
  *
 10   
  * This program is distributed in the hope that it will be useful,
 11   
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12   
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13   
  * GNU General Public License for more details.
 14   
  *
 15   
  * You should have received a copy of the GNU General Public License
 16   
  * along with this program; if not, write to the Free Software
 17   
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 18   
  */
 19   
 
 20   
 import java.awt.event.ActionListener;
 21   
 import java.awt.AWTEvent;
 22   
 import java.awt.event.WindowEvent;
 23   
 import java.awt.event.ActionEvent;
 24   
 import java.awt.Frame;
 25   
 import java.awt.Container;
 26   
 import java.awt.BorderLayout;
 27   
 import java.awt.FlowLayout;
 28   
 import java.awt.GridLayout;
 29   
 import javax.swing.JDialog;
 30   
 import javax.swing.JButton;
 31   
 import javax.swing.JPanel;
 32   
 import javax.swing.JLabel;
 33   
 import javax.swing.ImageIcon;
 34   
 import java.awt.Font;
 35   
 import java.awt.Dimension;
 36   
 import javax.swing.border.*;
 37   
 
 38   
 /**
 39   
  * A dialog to display information about application SimplyHTML.
 40   
  *
 41   
  * @author Ulrich Hilger
 42   
  * @author Light Development
 43   
  * @author <a href="http://www.lightdev.com">http://www.lightdev.com</a>
 44   
  * @author <a href="mailto:info@lightdev.com">info@lightdev.com</a>
 45   
  * @author published under the terms and conditions of the
 46   
  *      GNU General Public License,
 47   
  *      for details see file gpl.txt in the distribution
 48   
  *      package of this software
 49   
  *
 50   
  * @version stage 11, April 27, 2003
 51   
  */
 52   
 
 53   
 public class AboutBox extends JDialog implements ActionListener {
 54   
 
 55   
   /** button to close the dialog */
 56   
   JButton closeButton = new JButton("Close");
 57   
 
 58   
   /** name of the license file */
 59   
   private String LICENSE = "resources/gpl.txt";
 60   
 
 61   
   /**
 62   
    * construct an <code>AboutBox</code>.
 63   
    *
 64   
    * @param parent  the parent frame of the about box
 65   
    */
 66  2
   public AboutBox(Frame parent) {
 67  2
     super(parent);
 68  2
     enableEvents(AWTEvent.WINDOW_EVENT_MASK);
 69  2
     closeButton.addActionListener(this);
 70  2
     closeButton.setText(FrmMain.dynRes.getResourceString(FrmMain.resources, "closeBtnName"));
 71  2
     constructFrame();
 72  2
     setTitle(FrmMain.dynRes.getResourceString(FrmMain.resources, "aboutFrameTitle"));
 73  2
     pack();
 74   
   }
 75   
 
 76   
   /**
 77   
    * construct the dialog contents
 78   
    */
 79  2
   private void constructFrame() {
 80   
     /** initialize dialog components */
 81  2
     Container contentPane = getContentPane();
 82  2
     JPanel infoPane = new JPanel();
 83  2
     JPanel imagePane = new JPanel();
 84  2
     JPanel textPane = new JPanel();
 85  2
     JPanel buttonPane = new JPanel();
 86  2
     JPanel northPane = new JPanel();
 87  2
     JPanel emptyPane = new JPanel();
 88  2
     LicensePane licPane = new LicensePane(new Dimension(650,200), LICENSE);
 89  2
     JLabel imageLabel = new JLabel(new ImageIcon(this.getClass().
 90   
               getResource(FrmMain.dynRes.getResourceString(FrmMain.resources, "TerpWordLogo"))));
 91  2
     JLabel emptyLabel = new JLabel("");
 92   
     //JLabel appTitleLabel = new JLabel(FrmMain.APP_NAME);
 93   
     //JLabel appStageLabel = new JLabel("Stage 11, release 2");
 94  2
     JLabel appCopyrightLabel =
 95   
                             new JLabel("Copyright (c) 2002, 2003 Ulrich Hilger");
 96  2
     JLabel appHomepageLabel = new JLabel("http://www.lightdev.com");
 97   
 
 98   
     /* set the dialog title */
 99  2
     setTitle("About this application");
 100   
     /* highlight the application name with an appropriate font */
 101   
     //appTitleLabel.setFont(new Font("SansSerif", Font.BOLD, 12));
 102   
 
 103   
     /* load the application image into a panel */
 104  2
     imagePane.setLayout(new FlowLayout());
 105  2
     imagePane.add(imageLabel);
 106  2
     imagePane.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
 107   
 
 108   
     /**
 109   
      * textPane is the panel where all the application infos are shown.
 110   
      * Infos are shown in a one columns grid of labels, each on one row.
 111   
      */
 112  2
     textPane.setLayout(new GridLayout(6, 1, 5, 5));
 113  2
     textPane.add(emptyLabel);
 114   
     //textPane.add(appTitleLabel);
 115   
     //textPane.add(appStageLabel);
 116  2
     textPane.add(appCopyrightLabel);
 117  2
     textPane.add(appHomepageLabel);
 118   
 
 119   
     /**
 120   
      * infoPane shows the application image and the application info text
 121   
      * in a one row, two column grid.
 122   
      */
 123  2
     infoPane.setLayout(new GridLayout(1,2, 5, 5));
 124  2
     infoPane.add(imagePane);
 125  2
     infoPane.add(textPane);
 126   
 
 127   
     /**
 128   
      * northPane is a helper pane to show application image and application
 129   
      * info text left aligned in the upper left corner of the dialog.
 130   
      */
 131  2
     northPane.setLayout(new BorderLayout());
 132  2
     northPane.add(infoPane, BorderLayout.WEST);
 133  2
     northPane.add(emptyPane, BorderLayout.CENTER);
 134   
 
 135   
     /* panel for showing the close button at the dialog bottom */
 136  2
     buttonPane.setLayout(new FlowLayout());
 137  2
     buttonPane.add(closeButton);
 138   
 
 139   
     /**
 140   
      * now put together all parts of above application info and combine them
 141   
      * with license information
 142   
      */
 143  2
     contentPane.setLayout(new BorderLayout());
 144  2
     contentPane.add(northPane, BorderLayout.NORTH);
 145  2
     contentPane.add(licPane, BorderLayout.CENTER);
 146  2
     contentPane.add(buttonPane, BorderLayout.SOUTH);
 147   
   }
 148   
 
 149   
   /**
 150   
    * dispose the dialog properly in case of window close events
 151   
    */
 152  8
   protected void processWindowEvent(WindowEvent e) {
 153  8
     if (e.getID() == WindowEvent.WINDOW_CLOSING) {
 154  0
       cancel();
 155   
     }
 156  8
     super.processWindowEvent(e);
 157   
   }
 158   
 
 159   
   /**
 160   
    * dispose the dialog
 161   
    */
 162  2
   private void cancel() {
 163  2
     dispose();
 164   
   }
 165   
 
 166   
   /**
 167   
    * implements the ActionListener interface to be notified of
 168   
    * clicks onto the ok button. Closes and disposes the dialog in this case.
 169   
    */
 170  2
   public void actionPerformed(ActionEvent e) {
 171  2
     if (e.getSource() == closeButton) {
 172  2
       cancel();
 173   
     }
 174   
   }
 175   
 
 176   
 }