Clover coverage report - AdWT - 1.0.0
Coverage timestamp: sam. déc. 27 2003 15:14:10 CET
file stats: LOC: 145   Methods: 10
NCLOC: 67   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
BeanContextListModel.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;
 8   
 
 9   
 import java.beans.beancontext.BeanContext;
 10   
 import java.beans.beancontext.BeanContextMembershipEvent;
 11   
 import java.beans.beancontext.BeanContextMembershipListener;
 12   
 import java.util.Collection;
 13   
 import java.util.Iterator;
 14   
 import java.util.Vector;
 15   
 
 16   
 import javax.swing.ListModel;
 17   
 import javax.swing.event.ListDataEvent;
 18   
 import javax.swing.event.ListDataListener;
 19   
 
 20   
 /**
 21   
  * Description of the Class
 22   
  *
 23   
  * @author    Laurent Etiemble
 24   
  * @version   $Revision: 1.2 $
 25   
  */
 26   
 public class BeanContextListModel implements ListModel, BeanContextMembershipListener
 27   
 {
 28   
    /** Description of the Field */
 29   
    protected Collection listeners = new Vector();
 30   
    /** Description of the Field */
 31   
    protected BeanContext root;
 32   
 
 33   
 
 34   
    /**
 35   
     * Constructor for the BeanContextListModel object
 36   
     *
 37   
     * @param root  Description of the Parameter
 38   
     */
 39  0
    public BeanContextListModel(BeanContext root)
 40   
    {
 41  0
       this.root = root;
 42  0
       this.root.addBeanContextMembershipListener(this);
 43   
    }
 44   
 
 45   
 
 46   
    /**
 47   
     * Adds a feature to the ListDataListener attribute of the
 48   
     * BeanContextListModel object
 49   
     *
 50   
     * @param l  The feature to be added to the ListDataListener attribute
 51   
     */
 52  0
    public void addListDataListener(ListDataListener l)
 53   
    {
 54  0
       this.listeners.add(l);
 55   
    }
 56   
 
 57   
 
 58   
    /**
 59   
     * Description of the Method
 60   
     *
 61   
     * @param bcme  Description of the Parameter
 62   
     */
 63  0
    public void childrenAdded(BeanContextMembershipEvent bcme)
 64   
    {
 65  0
       this.fireContentsChanged();
 66   
    }
 67   
 
 68   
 
 69   
    /**
 70   
     * Description of the Method
 71   
     *
 72   
     * @param bcme  Description of the Parameter
 73   
     */
 74  0
    public void childrenRemoved(BeanContextMembershipEvent bcme)
 75   
    {
 76  0
       this.fireContentsChanged();
 77   
    }
 78   
 
 79   
 
 80   
    /**
 81   
     * Gets the elementAt attribute of the BeanContextListModel object
 82   
     *
 83   
     * @param index  Description of the Parameter
 84   
     * @return       The elementAt value
 85   
     */
 86  0
    public Object getElementAt(int index)
 87   
    {
 88  0
       int i = 0;
 89  0
       Object result = null;
 90  0
       for (Iterator it = this.root.iterator(); it.hasNext(); i++)
 91   
       {
 92  0
          result = it.next();
 93  0
          if (i == index)
 94   
          {
 95  0
             break;
 96   
          }
 97  0
          result = null;
 98   
       }
 99  0
       return result;
 100   
    }
 101   
 
 102   
 
 103   
    /**
 104   
     * Gets the size attribute of the BeanContextListModel object
 105   
     *
 106   
     * @return   The size value
 107   
     */
 108  0
    public int getSize()
 109   
    {
 110  0
       return root.size();
 111   
    }
 112   
 
 113   
 
 114   
    /**
 115   
     * Description of the Method
 116   
     *
 117   
     * @param l  Description of the Parameter
 118   
     */
 119  0
    public void removeListDataListener(ListDataListener l)
 120   
    {
 121  0
       this.listeners.remove(l);
 122   
    }
 123   
 
 124   
 
 125   
    /** Description of the Method */
 126  0
    protected void fireContentsChanged()
 127   
    {
 128  0
       ListDataEvent event = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, this.root.size());
 129  0
       Object[] copy = this.listeners.toArray();
 130  0
       for (int i = 0; i < copy.length; i++)
 131   
       {
 132  0
          ListDataListener listener = (ListDataListener) copy[i];
 133  0
          listener.contentsChanged(event);
 134   
       }
 135   
    }
 136   
 
 137   
 
 138   
    /** Description of the Method */
 139  0
    protected void fireIntervalAdded() { }
 140   
 
 141   
 
 142   
    /** Description of the Method */
 143  0
    protected void fireIntervalRemoved() { }
 144   
 }
 145