public class ComboBoxDataModel extends Object implements ListDataModel
| Constructor and Description |
|---|
ComboBoxDataModel() |
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
String id,
Object item)
This method adds a new item into the specified position.
|
void |
add(Map<String,Object> items)
Adds all the items from the map where each key is an item unique ID and each value is an item itself.
|
void |
add(String id,
Object item)
This method adds a new item in the list.
|
protected void |
addInternally(String id,
Object item)
Adds a new item into the list without firing an event.
|
void |
addListModelListener(ListModelListener listener)
This method registers a list data model listener.
|
void |
clear()
This method clears the list of items.
|
protected void |
fireEvent(ListModelEvent event)
This method fires the specified event and invokes the listeners.
|
Object |
get(int index)
This method returns an item by its index.
|
Object |
get(String id)
This method returns an item by its ID.
|
int |
getCount()
Returns a number of items in the list.
|
protected List<String> |
getItemIds()
Getter for property 'itemIds'.
|
protected Map<String,Object> |
getItems()
Getter for property 'items'.
|
Object |
getSelected()
This method returns a selected item.
|
String |
getSelectedId()
This method gets a selected item ID.
|
int |
getSelectedIndex()
This method gets a selected item index.
|
protected int |
getValidIndex(int invalidIndex)
This method calculates a valid index value taking into account the following rule:
if the index < 0, it returns 0;
if the index > then
getItemIds() size, it returns getItemIds() size. |
boolean |
isEmpty()
This method returns
true if the list of items is empty. |
protected boolean |
isIndexValid(int index)
This method checks whether the specified index is valid.
|
void |
remove(int... indexes)
This method removes items specified by the indexes.
|
void |
remove(String... ids)
This method removes the specified items.
|
protected int |
removeInternally(String id)
This method removes one item without sending any event.
|
void |
removeListModelListener(ListModelListener listener)
This method unregisters the specified listener.
|
void |
setSelectedId(String id)
This method sets a currently selected item specifying it by ID.
|
void |
setSelectedIndex(int index)
This method sets a currently selected item specifying it by the index.
|
public void add(String id, Object item)
add in interface ListDataModelid - an unique ID of the item. If there is an item with the same ID, this method replaces it with
a new value.item - is an item to be placed into the list.public void add(int index,
String id,
Object item)
add in interface ListDataModelindex - is an index value.id - is an item ID.item - is an item.public void add(Map<String,Object> items)
add in interface ListDataModelitems - is a map of items to add all.public Object get(String id)
get in interface ListDataModelid - is an item ID.public Object get(int index)
get in interface ListDataModelindex - is an item index.public void remove(String... ids)
remove in interface ListDataModelids - is a list of item IDs.public void remove(int... indexes)
remove in interface ListDataModelindexes - is a list of item indexes.public String getSelectedId()
getSelectedId in interface ListDataModelpublic int getSelectedIndex()
getSelectedIndex in interface ListDataModelpublic Object getSelected()
getSelected in interface ListDataModelpublic void setSelectedId(String id)
setSelectedId in interface ListDataModelid - is an item ID.public void setSelectedIndex(int index)
setSelectedIndex in interface ListDataModelindex - is an item index.public void clear()
clear in interface ListDataModelpublic boolean isEmpty()
true if the list of items is empty.isEmpty in interface ListDataModelpublic int getCount()
getCount in interface ListDataModelpublic void addListModelListener(ListModelListener listener)
addListModelListener in interface ListDataModellistener - is a listener to be invoked on any event.public void removeListModelListener(ListModelListener listener)
removeListModelListener in interface ListDataModellistener - is a listener to be unregistered.protected void fireEvent(ListModelEvent event)
event - is an event to fire.protected void addInternally(String id, Object item)
id - is an item ID to add.item - is an item itself.protected int removeInternally(String id)
id - is an ID of the item to remove.protected List<String> getItemIds()
protected Map<String,Object> getItems()
protected boolean isIndexValid(int index)
index - is an index value to check.true if the index is valid.protected int getValidIndex(int invalidIndex)
getItemIds() size, it returns getItemIds() size.invalidIndex - is an index.Copyright © 2008–2013. All rights reserved.