be.ugent.caagt.swirl

Interface GenericSelectionModel<E>

Known Implementing Classes:
DefaultGenericSelectionModel<E>

public interface GenericSelectionModel<E>

Model which keeps track of a single element selected from a group. The element is represented by an object type E. Classes that satisfy this interface can be used to implement a GenericSelectionGroup.

Models of this type are used by the MenuBuilder to implement radio button groups.

Method Summary

void
addChangeListener(ChangeListener listener)
Adds a listener which should be notified of all changes in the model.
void
clearSelection()
Clears the selection.
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 addChangeListener(ChangeListener).
void
setSelection(E element)
Set the current selection and notify any listeners in case of changes.

Method Details

addChangeListener

public void addChangeListener(ChangeListener listener)
Adds a listener which should be notified of all changes in the model.

clearSelection

public void clearSelection()
Clears the selection. Short for
    setSelection(null);
 

getSelection

public E getSelection()
Returns the current selection or null if nothing is currently selected.

isSelected

public boolean isSelected()
Check whether an element is currently selected. Short for
    getSelection() != null
 

removeChangeListener

public void removeChangeListener(ChangeListener listener)

setSelection

public void setSelection(E element)
Set the current selection and notify any listeners in case of changes.
Parameters:
element - object which represents the selected element, or null if the selection should be cleared