|
SPT Core API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnextapp.echo.app.list.AbstractListModel
com.sptci.echo.list.ListModel<D>
D - The class name of the model object backing this list model.public class ListModel<D extends Serializable>
A ListModel used to display a collection
of model objects in list components.
The following shows sample use of this model:
import com.sptci.echo.list.ListModel;
import com.sptci.echo.list.SelectField;
...
final Collection<Data> data = new ArrayList<Data>();
// populate data collection with Data instances and Data has a field
// named name.
final ListModel<Data> model = new ListModel<Data>( data, "name" );
final SelectField<ListModel<Data>> select = new SelectField<ListModel<Data>>();
select.setModel( model );
© Copyright 2008 Sans Pareil Technologies, Inc.
| Field Summary | |
|---|---|
protected List<D> |
data
A list used to represent the data held in this model |
protected String |
field
The name of the field in the backing model object whose value is to to be displayed in the list. |
protected Map<String,Integer> |
nameMap
A map used to quickly fetch index of value object by name. |
| Constructor Summary | |
|---|---|
protected |
ListModel()
Default constructor. |
|
ListModel(Collection<D> data,
String field)
Create a new model with the specified collection of data backing this model. |
| Method Summary | |
|---|---|
void |
add(D model)
Add the specified value object to the list model. |
void |
addAll(Collection<D> data)
Add the specified collection of objects to the model. |
Object |
get(int index)
Returns the value at the specified index in the list. |
List<D> |
getData()
Return a read-only view of the data in data. |
D |
getObject(int index)
Returns the object at the specified index in the list. |
protected String |
getValue(D model)
Return the value from the model object that is to be displayed in the list. |
protected String |
getValue(int index)
Return the value from the model object that is to be displayed at the specified index in the list. |
int |
indexByName(String name)
Return the index of the specified name. |
void |
remove(D model)
Remove the specified model object from the list model. |
void |
setData(List<D> data)
Set the data in data. |
int |
size()
Return the size of the model. |
| Methods inherited from class nextapp.echo.app.list.AbstractListModel |
|---|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getEventListenerList, removeListDataListener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected List<D extends Serializable> data
protected Map<String,Integer> nameMap
protected String field
| Constructor Detail |
|---|
protected ListModel()
public ListModel(Collection<D> data,
String field)
data - The collection of objects to represent.field - The field in the model object whose value is to be
displayed in the list component.| Method Detail |
|---|
protected String getValue(int index)
index - The index for which the value is to be fetched.
getValue(java.io.Serializable)protected String getValue(D model)
model - The model object from which the display value is to be
retrieved.
public Object get(int index)
index - The index in data from which the value is to
be retrieved.
getValue(int)public D getObject(int index)
index - The index in data from which the objec5 is to
be retrieved.
public int size()
data.public int indexByName(String name)
name - The name (value) displayed in the list component.
data at which the corresponding model
object exists.public void addAll(Collection<D> data)
data - The collection of objects to add to data.public void add(D model)
data and nameMap.
model - The model object that is to be added to this list model.public void remove(D model)
nameMap accordingly.
model - The object to be removed.public List<D> getData()
data.
public void setData(List<D> data)
data. Updates the associated maps.
data - The new collection of model objects to display.addAll(java.util.Collection)
|
SPT Core API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||