]> gitweb.fperrin.net Git - GpsPrune.git/blobdiff - src/tim/prune/function/FieldListModel.java
Moved source into separate src directory due to popular request
[GpsPrune.git] / src / tim / prune / function / FieldListModel.java
diff --git a/src/tim/prune/function/FieldListModel.java b/src/tim/prune/function/FieldListModel.java
new file mode 100644 (file)
index 0000000..b4589d8
--- /dev/null
@@ -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<String>
+{
+       /** ArrayList containing fields */
+       private ArrayList<Field> _fields = new ArrayList<Field>();
+
+
+       /**
+        * 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);
+       }
+}