be.ugent.caagt.swirl
Class DefaultGenericSelectionModel<E>

java.lang.Object
  extended by be.ugent.caagt.swirl.DefaultGenericSelectionModel<E>
All Implemented Interfaces:
GenericSelectionModel<E>

public class DefaultGenericSelectionModel<E>
extends java.lang.Object
implements GenericSelectionModel<E>

A default implementation of GenericSelectionModel. Uses equals to check whether the model has been changed whenever a new selection is set.


Field Summary
protected  javax.swing.event.EventListenerList listenerList
          The list of listeners currently registered
 
Constructor Summary
DefaultGenericSelectionModel()
           
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener listener)
          Adds a listener which should be notified of all changes in the model.
 void clearSelection()
          Clears the selection.
protected  void fireStateChanged()
          Notifies all listeners of a state change.
 E getSelection()
          Returns the current selection or null if nothing is currently selected.
 boolean isSelected()
          Check whether an element is currently selected.
 void removeChangeListener(javax.swing.event.ChangeListener listener)
          Removes a listener previously registered with GenericSelectionModel.addChangeListener(javax.swing.event.ChangeListener).
 void setSelection(E element)
          Set the current selection and notify any listeners in case of changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listenerList

protected javax.swing.event.EventListenerList listenerList
The list of listeners currently registered

Constructor Detail

DefaultGenericSelectionModel

public DefaultGenericSelectionModel()
Method Detail

getSelection

public E getSelection()
Description copied from interface: GenericSelectionModel
Returns the current selection or null if nothing is currently selected.

Specified by:
getSelection in interface GenericSelectionModel<E>

setSelection

public void setSelection(E element)
Description copied from interface: GenericSelectionModel
Set the current selection and notify any listeners in case of changes.

Specified by:
setSelection in interface GenericSelectionModel<E>
Parameters:
element - object which represents the selected element, or null if the selection should be cleared

clearSelection

public void clearSelection()
Description copied from interface: GenericSelectionModel
Clears the selection. Short for
    setSelection(null);
 

Specified by:
clearSelection in interface GenericSelectionModel<E>

isSelected

public boolean isSelected()
Description copied from interface: GenericSelectionModel
Check whether an element is currently selected. Short for
    getSelection() != null
 

Specified by:
isSelected in interface GenericSelectionModel<E>

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener listener)
Description copied from interface: GenericSelectionModel
Adds a listener which should be notified of all changes in the model.

Specified by:
addChangeListener in interface GenericSelectionModel<E>

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener listener)
Description copied from interface: GenericSelectionModel
Removes a listener previously registered with GenericSelectionModel.addChangeListener(javax.swing.event.ChangeListener).

Specified by:
removeChangeListener in interface GenericSelectionModel<E>

fireStateChanged

protected void fireStateChanged()
Notifies all listeners of a state change.