to.etc.domui.component.tbl
Class InstanceSelectionModel<T>

java.lang.Object
  extended by to.etc.domui.component.tbl.AbstractSelectionModel<T>
      extended by to.etc.domui.component.tbl.InstanceSelectionModel<T>
All Implemented Interfaces:
java.lang.Iterable<T>, ISelectionModel<T>

public class InstanceSelectionModel<T>
extends AbstractSelectionModel<T>
implements java.lang.Iterable<T>

This is a selection model that selects simple instances. It allows both single and multiple selections. It collects the selected instances in a set, so the instances should have well-defined equals and hashcode meaning either the Object versions or properly implemented ones.

Author:
Frits Jalvingh Created on Feb 17, 2011

Constructor Summary
InstanceSelectionModel(boolean multiSelect)
           
 
Method Summary
 void clearSelection()
          Clear all selections, then call the listeners to report the change.
 java.util.Set<T> getSelectedSet()
           
 int getSelectionCount()
          Return the #of instances currently selected.
 boolean isMultiSelect()
          T if this model can handle multiple selections.
 boolean isSelected(T rowinstance)
          Return T if this instance is actually selected.
 java.util.Iterator<T> iterator()
           
 void selectAll(ITableModel<T> in)
          This must add all (recoverable) items in the model and add them as selected as efficiently as possible.
 void setInstanceSelected(T rowinstance, boolean on)
          Set or clear an instance's selected state.
 
Methods inherited from class to.etc.domui.component.tbl.AbstractSelectionModel
addListener, callChanged, callSelectionAllChanged, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstanceSelectionModel

public InstanceSelectionModel(boolean multiSelect)
Method Detail

isMultiSelect

public final boolean isMultiSelect()
Description copied from interface: ISelectionModel
T if this model can handle multiple selections.

Specified by:
isMultiSelect in interface ISelectionModel<T>
Returns:

getSelectionCount

public int getSelectionCount()
Description copied from interface: ISelectionModel
Return the #of instances currently selected.

Specified by:
getSelectionCount in interface ISelectionModel<T>
Returns:

isSelected

public boolean isSelected(T rowinstance)
Description copied from interface: ISelectionModel
Return T if this instance is actually selected.

Specified by:
isSelected in interface ISelectionModel<T>
Returns:

setInstanceSelected

public void setInstanceSelected(T rowinstance,
                                boolean on)
                         throws java.lang.Exception
Description copied from interface: ISelectionModel
Set or clear an instance's selected state. When changed the model will call the listeners to report the change.

Specified by:
setInstanceSelected in interface ISelectionModel<T>
Throws:
java.lang.Exception

clearSelection

public void clearSelection()
                    throws java.lang.Exception
Description copied from interface: ISelectionModel
Clear all selections, then call the listeners to report the change.

Specified by:
clearSelection in interface ISelectionModel<T>
Throws:
java.lang.Exception

selectAll

public void selectAll(ITableModel<T> in)
               throws java.lang.Exception
Description copied from interface: ISelectionModel
This must add all (recoverable) items in the model and add them as selected as efficiently as possible. It is NEVER called directly, but always through a ISelectionAllHandler, so that "select all" can be forbidden.

Specified by:
selectAll in interface ISelectionModel<T>
Throws:
java.lang.Exception

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>

getSelectedSet

public java.util.Set<T> getSelectedSet()