de.matthiasmann.twl.model
Class SimpleListSelectionModel<T>

java.lang.Object
  extended by de.matthiasmann.twl.model.HasCallback
      extended by de.matthiasmann.twl.model.SimpleListSelectionModel<T>
Type Parameters:
T - the data type of the list model
All Implemented Interfaces:
IntegerModel, ListSelectionModel<T>, WithRunnableCallback

public class SimpleListSelectionModel<T>
extends HasCallback
implements ListSelectionModel<T>

A simple list selection model


Field Summary
 
Fields inherited from interface de.matthiasmann.twl.model.ListSelectionModel
NO_SELECTION
 
Constructor Summary
SimpleListSelectionModel(ListModel<T> listModel)
           
 
Method Summary
 ListModel<T> getListModel()
           
 int getMaxValue()
           
 int getMinValue()
           
 T getSelectedEntry()
          Returns the selected entry in the list or null if nothing is selected.
 int getValue()
           
 boolean setSelectedEntry(T entry)
          Selects the specified entry or nothing if the entry was not found.
 boolean setSelectedEntry(T entry, int defaultIndex)
          Selects the specified entry or the default index if the entry was not found
 void setValue(int value)
           
 
Methods inherited from class de.matthiasmann.twl.model.HasCallback
addCallback, doCallback, hasCallbacks, removeCallback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.matthiasmann.twl.utils.WithRunnableCallback
addCallback, removeCallback
 

Constructor Detail

SimpleListSelectionModel

public SimpleListSelectionModel(ListModel<T> listModel)
Method Detail

getListModel

public ListModel<T> getListModel()
Specified by:
getListModel in interface ListSelectionModel<T>

getSelectedEntry

public T getSelectedEntry()
Description copied from interface: ListSelectionModel
Returns the selected entry in the list or null if nothing is selected.

Specified by:
getSelectedEntry in interface ListSelectionModel<T>
Returns:
the selected entry or null.

setSelectedEntry

public boolean setSelectedEntry(T entry)
Description copied from interface: ListSelectionModel
Selects the specified entry or nothing if the entry was not found. This method behaves like setSelectedEntry(entry, NO_SELECTION)

Specified by:
setSelectedEntry in interface ListSelectionModel<T>
Parameters:
entry - the entry to select - can be null.
Returns:
true if the entry was found
See Also:
ListSelectionModel.setSelectedEntry(java.lang.Object, int), ListSelectionModel.NO_SELECTION

setSelectedEntry

public boolean setSelectedEntry(T entry,
                                int defaultIndex)
Description copied from interface: ListSelectionModel
Selects the specified entry or the default index if the entry was not found

Specified by:
setSelectedEntry in interface ListSelectionModel<T>
Parameters:
entry - the entry to select - can be null.
defaultIndex - the index to select when the entry was not found
Returns:
true if the entry was found
See Also:
ListSelectionModel.NO_SELECTION

getMaxValue

public int getMaxValue()
Specified by:
getMaxValue in interface IntegerModel

getMinValue

public int getMinValue()
Specified by:
getMinValue in interface IntegerModel

getValue

public int getValue()
Specified by:
getValue in interface IntegerModel

setValue

public void setValue(int value)
Specified by:
setValue in interface IntegerModel