1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 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 final ArrayList<Field> _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);
}
}
|