X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Ffunction%2FFieldListModel.java;fp=src%2Ftim%2Fprune%2Ffunction%2FFieldListModel.java;h=b4589d897569e2b4e0b11ffefbe12ced14f1f05d;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/function/FieldListModel.java b/src/tim/prune/function/FieldListModel.java new file mode 100644 index 0000000..b4589d8 --- /dev/null +++ b/src/tim/prune/function/FieldListModel.java @@ -0,0 +1,52 @@ +package tim.prune.function; + +import java.util.ArrayList; +import javax.swing.AbstractListModel; +import tim.prune.data.Field; + +/** + * Class to act as a list model for the delete field values function + */ +public class FieldListModel extends AbstractListModel +{ + /** ArrayList containing fields */ + private ArrayList _fields = new ArrayList(); + + + /** + * Add a field to the list + * @param inField field object to add + */ + public void addField(Field inField) + { + if (inField != null) {_fields.add(inField);} + } + + /** + * @return number of elements in list + */ + public int getSize() + { + return _fields.size(); + } + + /** + * @param inRow row number + * @return String for specified row + */ + public String getElementAt(int inRow) + { + if (inRow < 0 || inRow >= getSize()) {return null;} + return _fields.get(inRow).getName(); + } + + /** + * @param inRow row number + * @return specified Field object + */ + public Field getField(int inRow) + { + if (inRow < 0 || inRow >= getSize()) {return null;} + return _fields.get(inRow); + } +}