Clover coverage report - AdWT - 1.0.0
Coverage timestamp: sam. déc. 27 2003 15:14:10 CET
file stats: LOC: 272   Methods: 19
NCLOC: 147   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
BeanContextInternalFrame.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.Component;
 10   
 import java.beans.beancontext.BeanContext;
 11   
 import java.beans.beancontext.BeanContextServices;
 12   
 
 13   
 import javax.swing.Action;
 14   
 import javax.swing.JInternalFrame;
 15   
 import javax.swing.event.InternalFrameEvent;
 16   
 import javax.swing.event.InternalFrameListener;
 17   
 
 18   
 import org.apache.log4j.Logger;
 19   
 import org.ejtools.adwt.action.Command;
 20   
 import org.ejtools.adwt.action.CommandAction;
 21   
 import org.ejtools.adwt.action.window.InternalFrameAction;
 22   
 import org.ejtools.beans.beancontext.CustomBeanContextServicesSupport;
 23   
 
 24   
 /**
 25   
  * Description of the Class
 26   
  *
 27   
  * @author    Laurent Etiemble
 28   
  * @version   $Revision: 1.6 $
 29   
  * @todo      Javadoc to complete
 30   
  */
 31   
 public class BeanContextInternalFrame extends CustomBeanContextServicesSupport implements InternalFrameListener
 32   
 {
 33   
    /** Description of the Field */
 34   
    protected CommandAction action;
 35   
    /** Description of the Field */
 36   
    protected JInternalFrame frame;
 37   
    /** Description of the Field */
 38   
    protected MDIFrameService service;
 39   
    /** Description of the Field */
 40   
    private static Logger logger = Logger.getLogger(BeanContextInternalFrame.class);
 41   
 
 42   
 
 43   
    /** Constructor for the BeanContextInternalFrame object */
 44  0
    public BeanContextInternalFrame()
 45   
    {
 46  0
       super();
 47   
 
 48  0
       this.frame = new JInternalFrame("", true, true, true, true);
 49  0
       this.frame.addInternalFrameListener(this);
 50   
 
 51  0
       this.action = new InternalFrameAction(
 52   
          new Command()
 53   
          {
 54  0
             public void execute()
 55   
             {
 56  0
                BeanContextInternalFrame.this.activate();
 57   
             }
 58   
          });
 59   
    }
 60   
 
 61   
 
 62   
    /** Description of the Method */
 63  0
    public void activate()
 64   
    {
 65  0
       try
 66   
       {
 67  0
          if (this.service != null)
 68   
          {
 69  0
             this.service.activate(this);
 70   
          }
 71  0
          if (this.action != null)
 72   
          {
 73  0
             this.action.getMenuItem().setSelected(true);
 74   
          }
 75   
       }
 76   
       catch (Exception e)
 77   
       {
 78   
          // Do nothing
 79   
       }
 80   
    }
 81   
 
 82   
 
 83   
    /** Description of the Method */
 84  0
    public void close()
 85   
    {
 86  0
       this.frame.doDefaultCloseAction();
 87   
    }
 88   
 
 89   
 
 90   
    /**
 91   
     * Gets the action attribute of the BeanContextInternalFrame object
 92   
     *
 93   
     * @return   The action value
 94   
     */
 95  0
    public CommandAction getAction()
 96   
    {
 97  0
       return this.action;
 98   
    }
 99   
 
 100   
 
 101   
    /**
 102   
     * Gets the component attribute of the BeanContextInternalFrame object
 103   
     *
 104   
     * @return   The component value
 105   
     */
 106  0
    public Component getComponent()
 107   
    {
 108  0
       return this.frame;
 109   
    }
 110   
 
 111   
 
 112   
    /**
 113   
     * Gets the title attribute of the BeanContextInternalFrame object
 114   
     *
 115   
     * @return   The title value
 116   
     */
 117  0
    public String getTitle()
 118   
    {
 119  0
       return this.frame.getTitle();
 120   
    }
 121   
 
 122   
 
 123   
    /**
 124   
     * @param event  Description of the Parameter
 125   
     */
 126  0
    public void internalFrameActivated(InternalFrameEvent event)
 127   
    {
 128  0
       this.activate();
 129   
    }
 130   
 
 131   
 
 132   
    /**
 133   
     * @param event  Description of the Parameter
 134   
     */
 135  0
    public void internalFrameClosed(InternalFrameEvent event)
 136   
    {
 137  0
       BeanContext context = this.getBeanContext();
 138  0
       if (context != null)
 139   
       {
 140  0
          context.remove(this);
 141   
       }
 142   
    }
 143   
 
 144   
 
 145   
    /**
 146   
     * @param event  Description of the Parameter
 147   
     */
 148  0
    public void internalFrameClosing(InternalFrameEvent event) { }
 149   
 
 150   
 
 151   
    /**
 152   
     * @param event  Description of the Parameter
 153   
     */
 154  0
    public void internalFrameDeactivated(InternalFrameEvent event) { }
 155   
 
 156   
 
 157   
    /**
 158   
     * @param event  Description of the Parameter
 159   
     */
 160  0
    public void internalFrameDeiconified(InternalFrameEvent event) { }
 161   
 
 162   
 
 163   
    /**
 164   
     * @param event  Description of the Parameter
 165   
     */
 166  0
    public void internalFrameIconified(InternalFrameEvent event) { }
 167   
 
 168   
 
 169   
    /**
 170   
     * @param event  Description of the Parameter
 171   
     */
 172  0
    public void internalFrameOpened(InternalFrameEvent event) { }
 173   
 
 174   
 
 175   
    /**
 176   
     * Sets the title attribute of the BeanContextInternalFrame object
 177   
     *
 178   
     * @param title  The new title value
 179   
     */
 180  0
    public void setTitle(String title)
 181   
    {
 182  0
       this.frame.setTitle(title);
 183  0
       this.action.putValue(Action.NAME, title);
 184   
    }
 185   
 
 186   
 
 187   
    /** Description of the Method */
 188  0
    protected void initializeBeanContextResources()
 189   
    {
 190  0
       super.initializeBeanContextResources();
 191   
 
 192  0
       logger.debug("In initializeBeanContextResources");
 193  0
       BeanContextServices context = (BeanContextServices) getBeanContext();
 194  0
       this.useServices(context);
 195   
 
 196  0
       if (this.service != null)
 197   
       {
 198  0
          this.service.register(this);
 199   
       }
 200   
 
 201  0
       context.add(action);
 202   
 
 203  0
       this.activate();
 204   
    }
 205   
 
 206   
 
 207   
    /** Description of the Method */
 208  0
    protected void releaseBeanContextResources()
 209   
    {
 210  0
       logger.debug("In releaseBeanContextResources");
 211  0
       BeanContextServices context = (BeanContextServices) getBeanContext();
 212   
 
 213  0
       if (this.service != null)
 214   
       {
 215  0
          this.service.unregister(this);
 216   
       }
 217   
 
 218  0
       context.remove(action);
 219  0
       this.releaseServices(context);
 220   
 
 221  0
       super.releaseBeanContextResources();
 222   
    }
 223   
 
 224   
 
 225   
    /**
 226   
     * Description of the Method
 227   
     *
 228   
     * @param context  Description of the Parameter
 229   
     */
 230  0
    protected void releaseServices(BeanContextServices context)
 231   
    {
 232  0
       if (context.hasService(MDIFrameService.class))
 233   
       {
 234  0
          logger.debug("Using service MDIFrameService...");
 235  0
          try
 236   
          {
 237  0
             context.releaseService(this, this, MDIFrameService.class);
 238   
          }
 239   
          catch (Exception e)
 240   
          {
 241  0
             logger.error("Error during utilisation of service MDIFrameService (" + e.getMessage() + ")");
 242  0
             e.printStackTrace();
 243   
          }
 244   
       }
 245   
    }
 246   
 
 247   
 
 248   
    /**
 249   
     * Description of the Method
 250   
     *
 251   
     * @param context  Description of the Parameter
 252   
     */
 253  0
    protected void useServices(BeanContextServices context)
 254   
    {
 255  0
       if (context.hasService(MDIFrameService.class))
 256   
       {
 257  0
          logger.debug("Using service MDIFrameService...");
 258  0
          try
 259   
          {
 260  0
             this.service = (MDIFrameService) context.getService(this, this, MDIFrameService.class, this.frame, this);
 261  0
             logger.debug("Service MDIFrameService registered");
 262   
          }
 263   
          catch (Exception e)
 264   
          {
 265  0
             logger.error("Error during utilisation of service MDIFrameService (" + e.getMessage() + ")");
 266  0
             e.printStackTrace();
 267   
          }
 268   
       }
 269   
    }
 270   
 
 271   
 }
 272