]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/function/FieldListModel.java
Version 11, August 2010
[GpsPrune.git] / tim / prune / function / FieldListModel.java
1 package tim.prune.function;
2
3 import java.util.ArrayList;
4 import javax.swing.AbstractListModel;
5 import tim.prune.data.Field;
6
7 /**
8  * Class to act as a list model for the delete field values function
9  */
10 public class FieldListModel extends AbstractListModel
11 {
12         /** ArrayList containing fields */
13         private ArrayList<Field> _fields = new ArrayList<Field>();
14
15
16         /**
17          * Add a field to the list
18          * @param inField field object to add
19          */
20         public void addField(Field inField)
21         {
22                 if (inField != null) {_fields.add(inField);}
23         }
24
25         /**
26          * @return number of elements in list
27          */
28         public int getSize()
29         {
30                 return _fields.size();
31         }
32
33         /**
34          * @param inRow row number
35          * @return String for specified row
36          */
37         public Object getElementAt(int inRow)
38         {
39                 if (inRow < 0 || inRow >= getSize()) {return null;}
40                 return _fields.get(inRow).getName();
41         }
42
43         /**
44          * @param inRow row number
45          * @return specified Field object
46          */
47         public Field getField(int inRow)
48         {
49                 if (inRow < 0 || inRow >= getSize()) {return null;}
50                 return _fields.get(inRow);
51         }
52 }