EchoPoint
1.0

echopoint.model
Class DefaultSingleSelectionModel

java.lang.Object
  extended byechopoint.model.DefaultSingleSelectionModel
All Implemented Interfaces:
java.io.Serializable, SingleSelectionModel

public class DefaultSingleSelectionModel
extends java.lang.Object
implements SingleSelectionModel, java.io.Serializable

A generic implementation of SingleSelectionModel.

This class will perform an optimisation check when the selected index is set and will only fire a ChangeEvent if the index actually changes from the previous value.

See Also:
Serialized Form

Field Summary
protected  nextapp.echo.event.ChangeEvent changeEvent
          Only one ChangeEvent is needed per model instance since the event's only (read-only) state is the source property.
protected  nextapp.echo.event.EventListenerList listenerList
           
 
Constructor Summary
DefaultSingleSelectionModel()
          Initializes selectedIndex to -1
DefaultSingleSelectionModel(int index)
          Initializes selectedIndex to index
 
Method Summary
 void addChangeListener(nextapp.echo.event.ChangeListener l)
          Adds listener as a listener to changes in the model.
 void clearSelection()
          Clears the selection (to -1).
 void fireStateChanged()
          Notifies all listeners that have registered for this event type.
 int getSelectedIndex()
          Returns the model's selection.
 boolean isSelected()
          Returns true if the selection model currently has a selected value.
 void removeChangeListener(nextapp.echo.event.ChangeListener l)
          Removes listener as a listener to changes in the model.
 void setSelectedIndex(int index)
          Sets the model's selected index to index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

changeEvent

protected transient nextapp.echo.event.ChangeEvent changeEvent
Only one ChangeEvent is needed per model instance since the event's only (read-only) state is the source property. The source of events generated here is always "this".


listenerList

protected nextapp.echo.event.EventListenerList listenerList
Constructor Detail

DefaultSingleSelectionModel

public DefaultSingleSelectionModel()
Initializes selectedIndex to -1


DefaultSingleSelectionModel

public DefaultSingleSelectionModel(int index)
Initializes selectedIndex to index

Method Detail

addChangeListener

public void addChangeListener(nextapp.echo.event.ChangeListener l)
Description copied from interface: SingleSelectionModel
Adds listener as a listener to changes in the model.

Specified by:
addChangeListener in interface SingleSelectionModel
Parameters:
l - the ChangeListener to add
See Also:
SingleSelectionModel.addChangeListener(nextapp.echo.event.ChangeListener)

clearSelection

public void clearSelection()
Description copied from interface: SingleSelectionModel
Clears the selection (to -1).

Specified by:
clearSelection in interface SingleSelectionModel
See Also:
SingleSelectionModel.clearSelection()

fireStateChanged

public void fireStateChanged()
Notifies all listeners that have registered for this event type.


getSelectedIndex

public int getSelectedIndex()
Description copied from interface: SingleSelectionModel
Returns the model's selection.

Specified by:
getSelectedIndex in interface SingleSelectionModel
Returns:
the model's selection, or -1 if there is no selection
See Also:
SingleSelectionModel.getSelectedIndex()

isSelected

public boolean isSelected()
Description copied from interface: SingleSelectionModel
Returns true if the selection model currently has a selected value.

Specified by:
isSelected in interface SingleSelectionModel
Returns:
true if a value is currently selected
See Also:
SingleSelectionModel.isSelected()

removeChangeListener

public void removeChangeListener(nextapp.echo.event.ChangeListener l)
Description copied from interface: SingleSelectionModel
Removes listener as a listener to changes in the model.

Specified by:
removeChangeListener in interface SingleSelectionModel
Parameters:
l - the ChangeListener to remove
See Also:
SingleSelectionModel.removeChangeListener(nextapp.echo.event.ChangeListener)

setSelectedIndex

public void setSelectedIndex(int index)
Description copied from interface: SingleSelectionModel
Sets the model's selected index to index.
Notifies any listeners if the model changes

Specified by:
setSelectedIndex in interface SingleSelectionModel
See Also:
SingleSelectionModel.setSelectedIndex(int)

EchoPoint
1.0