Clover coverage report - AdWT - 1.0.0
Coverage timestamp: sam. déc. 27 2003 15:14:10 CET
file stats: LOC: 144   Methods: 7
NCLOC: 102   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
BeanContextListPanel.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.awt.Dimension;
 10   
 import java.beans.beancontext.BeanContext;
 11   
 import java.beans.beancontext.BeanContextChildComponentProxy;
 12   
 import java.beans.beancontext.BeanContextContainerProxy;
 13   
 
 14   
 import javax.swing.BorderFactory;
 15   
 import javax.swing.JLabel;
 16   
 import javax.swing.JList;
 17   
 import javax.swing.JPanel;
 18   
 import javax.swing.JScrollPane;
 19   
 import javax.swing.JSplitPane;
 20   
 import javax.swing.ListModel;
 21   
 import javax.swing.SwingUtilities;
 22   
 import javax.swing.event.ListDataEvent;
 23   
 import javax.swing.event.ListDataListener;
 24   
 import javax.swing.event.ListSelectionEvent;
 25   
 import javax.swing.event.ListSelectionListener;
 26   
 
 27   
 /**
 28   
  * Description of the Class
 29   
  *
 30   
  * @author    Laurent Etiemble
 31   
  * @version   $Revision: 1.5 $
 32   
  */
 33   
 public class BeanContextListPanel extends JSplitPane
 34   
 {
 35   
    /** Description of the Field */
 36   
    protected JList list;
 37   
 
 38   
 
 39   
    /**
 40   
     * Constructor for the BeanContextListPanel object
 41   
     *
 42   
     * @param beancontext  Description of Parameter
 43   
     */
 44  0
    public BeanContextListPanel(BeanContext beancontext)
 45   
    {
 46  0
       this(beancontext, null);
 47   
    }
 48   
 
 49   
 
 50   
    /**
 51   
     * Constructor for the BeanContextListPanel object
 52   
     *
 53   
     * @param beancontext  Description of Parameter
 54   
     * @param s            Description of Parameter
 55   
     */
 56  0
    public BeanContextListPanel(BeanContext beancontext, String s)
 57   
    {
 58  0
       super(1);
 59  0
       if (s != null)
 60   
       {
 61  0
          setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), s));
 62   
       }
 63  0
       list = new BeanContextListView(beancontext);
 64  0
       JScrollPane jscrollpane = new JScrollPane(list);
 65  0
       jscrollpane.setMinimumSize(new Dimension(200, 300));
 66  0
       jscrollpane.setPreferredSize(new Dimension(200, 300));
 67  0
       final JPanel dummyMsg = new JPanel();
 68  0
       dummyMsg.add(new JLabel("", 0));
 69  0
       setLeftComponent(jscrollpane);
 70  0
       setRightComponent(dummyMsg);
 71  0
       list.addListSelectionListener(
 72   
          new ListSelectionListener()
 73   
          {
 74   
 
 75  0
             public void valueChanged(ListSelectionEvent e)
 76   
             {
 77  0
                if (e.getValueIsAdjusting())
 78   
                {
 79  0
                   return;
 80   
                }
 81  0
                final int index = list.getSelectedIndex();
 82  0
                final ListModel model = list.getModel();
 83  0
                SwingUtilities.invokeLater(
 84   
                   new Runnable()
 85   
                   {
 86   
 
 87  0
                      public void run()
 88   
                      {
 89  0
                         try
 90   
                         {
 91  0
                            Object obj = ((BeanContextListView.ContextElement) model.getElementAt(index)).getUserObject();
 92  0
                            if (obj instanceof BeanContextChildComponentProxy)
 93   
                            {
 94  0
                               BeanContextChildComponentProxy beancontextchildcomponentproxy = (BeanContextChildComponentProxy) obj;
 95  0
                               setRightComponent(beancontextchildcomponentproxy.getComponent());
 96   
                            }
 97   
                            else
 98  0
                               if (obj instanceof BeanContextContainerProxy)
 99   
                            {
 100  0
                               BeanContextContainerProxy beancontextcontainerproxy = (BeanContextContainerProxy) obj;
 101  0
                               setRightComponent(beancontextcontainerproxy.getContainer());
 102   
                            }
 103  0
                            validate();
 104   
                         }
 105   
                         catch (Exception _ex)
 106   
                         {
 107   
                         }
 108   
                      }
 109   
 
 110   
                   });
 111   
             }
 112   
 
 113   
          });
 114  0
       list.getModel().addListDataListener(
 115   
          new ListDataListener()
 116   
          {
 117   
 
 118  0
             public void contentsChanged(ListDataEvent e)
 119   
             {
 120  0
                list.clearSelection();
 121  0
                setRightComponent(dummyMsg);
 122  0
                validate();
 123   
             }
 124   
 
 125   
 
 126  0
             public void intervalAdded(ListDataEvent e)
 127   
             {
 128  0
                list.clearSelection();
 129  0
                setRightComponent(dummyMsg);
 130  0
                validate();
 131   
             }
 132   
 
 133   
 
 134  0
             public void intervalRemoved(ListDataEvent e)
 135   
             {
 136  0
                list.clearSelection();
 137  0
                setRightComponent(dummyMsg);
 138  0
                validate();
 139   
             }
 140   
          });
 141   
    }
 142   
 }
 143   
 
 144