Clover coverage report - AdWT - 1.0.0
Coverage timestamp: sam. déc. 27 2003 15:14:10 CET
file stats: LOC: 209   Methods: 12
NCLOC: 103   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
AboutServiceProvider.java 0% 0% 0% 0%
coverage
 1   
 /*
 2   
  * EJTools, the Enterprise Java Tools
 3   
  *
 4   
  * Distributable under LGPL license.
 5   
  * See terms of license at www.gnu.org.
 6   
  */
 7   
 package org.ejtools.adwt.service;
 8   
 
 9   
 import java.awt.BorderLayout;
 10   
 import java.awt.Color;
 11   
 import java.awt.Container;
 12   
 import java.awt.GridLayout;
 13   
 import java.beans.beancontext.BeanContextServices;
 14   
 import java.util.Iterator;
 15   
 import java.util.Vector;
 16   
 
 17   
 import javax.swing.JFrame;
 18   
 import javax.swing.JLabel;
 19   
 import javax.swing.JOptionPane;
 20   
 import javax.swing.JPanel;
 21   
 import javax.swing.SwingConstants;
 22   
 
 23   
 import org.apache.log4j.Logger;
 24   
 import org.ejtools.adwt.action.Command;
 25   
 import org.ejtools.adwt.action.help.AboutAction;
 26   
 import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider;
 27   
 
 28   
 /**
 29   
  * Description of the Class
 30   
  *
 31   
  * @author    Laurent Etiemble
 32   
  * @version   $Revision: 1.5 $
 33   
  * @todo      Javadoc to complete
 34   
  * @todo      I18N to complete
 35   
  */
 36   
 public class AboutServiceProvider extends CustomBeanContextServiceProvider implements AboutService
 37   
 {
 38   
    /** Description of the Field */
 39   
    protected JPanel panel = null;
 40   
    /** Description of the Field */
 41   
    protected AboutService service = null;
 42   
    /** Description of the Field */
 43   
    private static Logger logger = Logger.getLogger(AboutServiceProvider.class);
 44   
 
 45   
 
 46   
    /** Constructor for the AboutServiceProvider object */
 47  0
    public AboutServiceProvider()
 48   
    {
 49  0
       this.service = this;
 50   
    }
 51   
 
 52   
 
 53   
    /**
 54   
     * Constructor for the AboutServiceProvider object
 55   
     *
 56   
     * @param service  Description of Parameter
 57   
     */
 58  0
    public AboutServiceProvider(AboutService service)
 59   
    {
 60  0
       this.service = service;
 61   
    }
 62   
 
 63   
 
 64   
    /**
 65   
     * Gets the currentServiceSelectors attribute of the ApplicationServiceProvider object
 66   
     *
 67   
     * @param bcs           Description of Parameter
 68   
     * @param serviceClass  Description of Parameter
 69   
     * @return              The currentServiceSelectors value
 70   
     */
 71  0
    public Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass)
 72   
    {
 73  0
       return (new Vector().iterator());
 74   
    }
 75   
 
 76   
 
 77   
    /**
 78   
     * Gets the panel attribute of the AboutServiceProvider object
 79   
     *
 80   
     * @return   The panel value
 81   
     */
 82  0
    public Container getPanel()
 83   
    {
 84  0
       if (this.panel == null)
 85   
       {
 86  0
          this.createPanel();
 87   
       }
 88  0
       return this.panel;
 89   
    }
 90   
 
 91   
 
 92   
    /**
 93   
     * Gets the service attribute of the ApplicationServiceProvider object
 94   
     *
 95   
     * @param bcs              Description of Parameter
 96   
     * @param requestor        Description of Parameter
 97   
     * @param serviceClass     Description of Parameter
 98   
     * @param serviceSelector  Description of Parameter
 99   
     * @return                 The service value
 100   
     */
 101  0
    public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector)
 102   
    {
 103  0
       return this.service;
 104   
    }
 105   
 
 106   
 
 107   
    /**
 108   
     * Getter for the title attribute
 109   
     *
 110   
     * @return   The value of title attribute
 111   
     * @todo     I18N
 112   
     */
 113  0
    public String getTitle()
 114   
    {
 115  0
       return "About Service";
 116   
    }
 117   
 
 118   
 
 119   
    /**
 120   
     * Description of the Method
 121   
     *
 122   
     * @param bcs        Description of Parameter
 123   
     * @param requestor  Description of Parameter
 124   
     * @param service    Description of Parameter
 125   
     */
 126  0
    public void releaseService(BeanContextServices bcs, Object requestor, Object service) { }
 127   
 
 128   
 
 129   
    /**
 130   
     * Description of the Method
 131   
     *
 132   
     * @todo   I18N
 133   
     */
 134  0
    protected void createPanel()
 135   
    {
 136  0
       this.panel = new JPanel(new BorderLayout());
 137   
 
 138   
       // North part
 139  0
       this.panel.add("North", new JLabel("Insert your logo here"));
 140   
 
 141   
       // Center part
 142  0
       this.panel.add("Center", new JLabel("This is the default AboutService"));
 143   
 
 144   
       // South part
 145  0
       JPanel info = new JPanel(new GridLayout(2, 1));
 146  0
       JLabel java = new JLabel("Java version:" + System.getProperty("java.version"), SwingConstants.CENTER);
 147  0
       java.setForeground(Color.black);
 148  0
       info.add(java);
 149  0
       JLabel vm = new JLabel("VM:" + System.getProperty("java.vm.name") + ", " + System.getProperty("java.vm.version"), SwingConstants.CENTER);
 150  0
       vm.setForeground(Color.black);
 151  0
       info.add(vm);
 152  0
       this.panel.add("South", info);
 153   
    }
 154   
 
 155   
 
 156   
    /**
 157   
     * @return   The serviceClass value
 158   
     */
 159  0
    protected Class[] getServiceClass()
 160   
    {
 161  0
       return new Class[]{AboutService.class};
 162   
    }
 163   
 
 164   
 
 165   
    /** */
 166  0
    protected void initializeBeanContextResources()
 167   
    {
 168  0
       super.initializeBeanContextResources();
 169   
 
 170   
       // Add the About button
 171  0
       this.add(new AboutAction(
 172   
          new Command()
 173   
          {
 174  0
             public void execute()
 175   
             {
 176  0
                AboutServiceProvider.this.show();
 177   
             }
 178   
          }
 179   
          ));
 180   
 
 181  0
       logger.debug("AboutService added");
 182   
    }
 183   
 
 184   
 
 185   
    /** Description of the Method */
 186  0
    protected void show()
 187   
    {
 188  0
       BeanContextServices context = (BeanContextServices) getBeanContext();
 189   
 
 190  0
       if (context.hasService(FrameService.class))
 191   
       {
 192  0
          logger.debug("Using service FrameService...");
 193  0
          try
 194   
          {
 195  0
             FrameService fservice = (FrameService) context.getService(this, this, FrameService.class, this, this);
 196  0
             JFrame frame = (JFrame) fservice.getContainer();
 197   
             // I18N Todo
 198  0
             JOptionPane.showMessageDialog(frame, service.getPanel(), service.getTitle(), JOptionPane.PLAIN_MESSAGE);
 199  0
             context.releaseService(this, this, FrameService.class);
 200   
          }
 201   
          catch (Exception e)
 202   
          {
 203  0
             logger.error("Error during utilisation ofgetBeanContext() service FrameService (" + e.getMessage() + ")");
 204   
          }
 205   
       }
 206   
    }
 207   
 }
 208   
 
 209