org.zkoss.zkplus.databind
Class BindingListModelListModel<E>

java.lang.Object
  extended by org.zkoss.zkplus.databind.BindingListModelListModel<E>
All Implemented Interfaces:
java.io.Serializable, BindingListModel<E>, BindingListModelExt<E>, Selectable<E>, ListModel<E>

public class BindingListModelListModel<E>
extends java.lang.Object
implements BindingListModel<E>, Selectable<E>, java.io.Serializable, BindingListModelExt<E>

This is the BindingListModel as a ListModel to be used with Listbox, Grid, and DataBinder. Add or remove the contents of this model as a ListModel would cause the associated Listbox or Grid to change accordingly.

Since:
5.0.8
Author:
peterkuo
See Also:
Serialized Form

Field Summary
protected  ListModel<E> _model
           
 
Constructor Summary
BindingListModelListModel(ListModel<E> model)
           
BindingListModelListModel(ListModel<E> model, boolean distinct)
           
 
Method Summary
 void addListDataListener(ListDataListener l)
          Adds a listener to the list that's notified each time a change to the data model occurs.
 boolean addToSelection(E obj)
          Add the specified object into selection.
 void clearSelection()
          Change the selection to the empty set.
 E getElementAt(int index)
          Returns the value at the specified index.
 ListModel<E> getInnerModel()
           
 java.util.Set<E> getSelection()
          Returns the current selection.
 int getSize()
          Returns the length of the list.
 int[] indexesOf(java.lang.Object elm)
          Returns indexes of the given object inside a ListModel.
 int indexOf(java.lang.Object obj)
          Returns index of the given object inside a ListModel.
 boolean isDistinct()
          Returns true if all objects inside this ListModel is distinct.
 boolean isMultiple()
          Returns whether the current selection mode is multiple.
 boolean isSelected(java.lang.Object obj)
          Returns whether an object is selected.
 boolean isSelectionEmpty()
          Returns true if the selection is currently empty.
 boolean removeFromSelection(java.lang.Object obj)
          Remove the specified object from selection.
 void removeListDataListener(ListDataListener l)
          Removes a listener from the list that's notified each time a change to the data model occurs.
 void setMultiple(boolean multiple)
          Sets the selection mode to be multiple.
 void setSelection(java.util.Collection<? extends E> selection)
          Replace the current selection with the given set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_model

protected ListModel<E> _model
Constructor Detail

BindingListModelListModel

public BindingListModelListModel(ListModel<E> model)

BindingListModelListModel

public BindingListModelListModel(ListModel<E> model,
                                 boolean distinct)
Method Detail

indexOf

public int indexOf(java.lang.Object obj)
Description copied from interface: BindingListModel
Returns index of the given object inside a ListModel.

Specified by:
indexOf in interface BindingListModel<E>

getElementAt

public E getElementAt(int index)
Description copied from interface: ListModel
Returns the value at the specified index.

Specified by:
getElementAt in interface ListModel<E>

getSize

public int getSize()
Description copied from interface: ListModel
Returns the length of the list.

Specified by:
getSize in interface ListModel<E>

addListDataListener

public void addListDataListener(ListDataListener l)
Description copied from interface: ListModel
Adds a listener to the list that's notified each time a change to the data model occurs.

Specified by:
addListDataListener in interface ListModel<E>

removeListDataListener

public void removeListDataListener(ListDataListener l)
Description copied from interface: ListModel
Removes a listener from the list that's notified each time a change to the data model occurs.

Specified by:
removeListDataListener in interface ListModel<E>

getInnerModel

public ListModel<E> getInnerModel()

getSelection

public java.util.Set<E> getSelection()
Description copied from interface: Selectable
Returns the current selection. It is readonly. Don't modify it directly

Specified by:
getSelection in interface Selectable<E>
Returns:
the current selection.

setSelection

public void setSelection(java.util.Collection<? extends E> selection)
Description copied from interface: Selectable
Replace the current selection with the given set.

If this represents a change to the current selection then notify each ListDataListener, including UI.

Specified by:
setSelection in interface Selectable<E>

isSelected

public boolean isSelected(java.lang.Object obj)
Description copied from interface: Selectable
Returns whether an object is selected.

Specified by:
isSelected in interface Selectable<E>

isSelectionEmpty

public boolean isSelectionEmpty()
Description copied from interface: Selectable
Returns true if the selection is currently empty.

Specified by:
isSelectionEmpty in interface Selectable<E>

addToSelection

public boolean addToSelection(E obj)
Description copied from interface: Selectable
Add the specified object into selection.

If this represents a change to the current selection then notify each ListDataListener, including UI.

Specified by:
addToSelection in interface Selectable<E>
Parameters:
obj - the object to be as selection.
Returns:
true if it is added successfully; false if obj is not part of the data, or was already selected.

removeFromSelection

public boolean removeFromSelection(java.lang.Object obj)
Description copied from interface: Selectable
Remove the specified object from selection.

If this represents a change to the current selection then notify each ListDataListener, including UI.

Specified by:
removeFromSelection in interface Selectable<E>
Parameters:
obj - the object to be remove from selection.
Returns:
whether it is removed successfully

clearSelection

public void clearSelection()
Description copied from interface: Selectable
Change the selection to the empty set.

If this represents a change to the current selection then notify each ListDataListener, including UI.

Specified by:
clearSelection in interface Selectable<E>

setMultiple

public void setMultiple(boolean multiple)
Description copied from interface: Selectable
Sets the selection mode to be multiple.

Specified by:
setMultiple in interface Selectable<E>

isMultiple

public boolean isMultiple()
Description copied from interface: Selectable
Returns whether the current selection mode is multiple.

Specified by:
isMultiple in interface Selectable<E>
See Also:
Selectable.setMultiple(boolean)

indexesOf

public int[] indexesOf(java.lang.Object elm)
Description copied from interface: BindingListModelExt
Returns indexes of the given object inside a ListModel.

Specified by:
indexesOf in interface BindingListModelExt<E>
Parameters:
elm - the specified object
Returns:
indexes that contains the given object; return empty array if none found.

isDistinct

public boolean isDistinct()
Description copied from interface: BindingListModelExt
Returns true if all objects inside this ListModel is distinct. This is for DataBinder performance so there is no need to scan the whole ListModel as long as find one.

Specified by:
isDistinct in interface BindingListModelExt<E>
Returns:
true if all objects inside this ListModel is distinct; otherwise, return false.


Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo