be.ugent.caagt.swirl

Class DefaultGenericSelectionModel<E>

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 EventListenerList
listenerList
The list of listeners currently registered

Constructor Summary

DefaultGenericSelectionModel()

Method Summary

void
addChangeListener(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(ChangeListener listener)
Removes a listener previously registered with GenericSelectionModel.addChangeListener(ChangeListener).
void
setSelection(E element)
Set the current selection and notify any listeners in case of changes.

Field Details

listenerList

protected EventListenerList listenerList
The list of listeners currently registered

Constructor Details

DefaultGenericSelectionModel

public DefaultGenericSelectionModel()

Method Details

addChangeListener

public void addChangeListener(ChangeListener listener)
Adds a listener which should be notified of all changes in the model.
Specified by:
addChangeListener in interface GenericSelectionModel<E>

clearSelection

public void clearSelection()
Clears the selection. Short for
    setSelection(null);
 
Specified by:
clearSelection in interface GenericSelectionModel<E>

fireStateChanged

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

getSelection

public E getSelection()
Returns the current selection or null if nothing is currently selected.
Specified by:
getSelection in interface GenericSelectionModel<E>

isSelected

public boolean isSelected()
Check whether an element is currently selected. Short for
    getSelection() != null
 
Specified by:
isSelected in interface GenericSelectionModel<E>

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Specified by:
removeChangeListener in interface GenericSelectionModel<E>

setSelection

public void setSelection(E element)
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