Save This Page
Home » openjdk-7 » net.bereza.money » gui » [javadoc | source]
    1   /*
    2    *  Copyright (C) 2000  Bill Bereza
    3    *
    4    *  This program is free software; you can redistribute it and/or modify
    5    *  it under the terms of the GNU General Public License as published by
    6    *  the Free Software Foundation; either version 2 of the License, or
    7    *  (at your option) any later version.
    8    *
    9    *  This program is distributed in the hope that it will be useful,
   10    *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   11    *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12    *  GNU General Public License for more details.
   13    *
   14    *  You should have received a copy of the GNU General Public License
   15    *  along with this program; if not, write to the Free Software
   16    *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   17    *
   18    *  Author: Bill Bereza
   19    *  email : bereza@pobox.com
   20    *  url   : http://www.pobox.com/~bereza/
   21    */
   22   package net.bereza.money.gui;
   23   
   24   import net.bereza.money.db;
   25   import net.bereza.db;
   26   
   27   import java.util;
   28   import java.awt;
   29   import java.awt.event;
   30   import javax.swing;
   31   
   32   /**
   33    * ItemListModel is a DefaultListModel which holds only
   34    * DatabaseItems, and has a Hashtable which tracks items
   35    * by id.
   36    *
   37    * @author $Author: bereza $
   38    * @version $Revision: 1.2 $
   39    * <p>
   40    * $Log: ItemListModel.java,v $
   41    * Revision 1.2  2000/03/30 01:57:34  bereza
   42    * Added copyright header
   43    *
   44    * Revision 1.1  2000/03/29 02:12:30  bereza
   45    * Initial revision
   46    *
   47    * <p>
   48    * 	$Id: ItemListModel.java,v 1.2 2000/03/30 01:57:34 bereza Exp $
   49    */
   50   public class ItemListModel extends DefaultComboBoxModel
   51   {
   52     Hashtable trackingTable;
   53   
   54     /**
   55      * Construct a ItemListModel with a tracking table.
   56      * @param table which will track items by id
   57      */
   58     public ItemListModel(Hashtable table)
   59     {
   60       trackingTable=table;
   61     }
   62   
   63     private void addToTable(Object element)
   64     {
   65       if(element instanceof DatabaseItem)
   66       {
   67         trackingTable.put(new Integer(((DatabaseItem)element).getId()),
   68                           element);
   69       }
   70     }
   71   
   72     /*
   73     public void add(int index, Object element)
   74     {
   75       addToTable(element);
   76       super.add(index, element);
   77     }
   78     */
   79     
   80     public void addElement(Object element)
   81     {
   82       addToTable(element);
   83       super.addElement(element);
   84     }
   85   
   86     /*
   87     public Object set(int index, Object element)
   88     {
   89       addToTable(element);
   90       return super.set(index, element);
   91     }
   92     */
   93   
   94     public void insertElementAt(Object obj, int index)
   95     {
   96       addToTable(obj);
   97       super.insertElementAt(obj, index);
   98     }
   99   
  100     /*
  101     public void setElementAt(Object obj, int index)
  102     {
  103       addToTable(obj);
  104       super.setElementAt(obj, index);
  105     }
  106     */
  107   }
  108   

Save This Page
Home » openjdk-7 » net.bereza.money » gui » [javadoc | source]