com.tonbeller.wcf.selection
Class AbstractSelectionModel

java.lang.Object
  extended bycom.tonbeller.wcf.selection.AbstractSelectionModel
All Implemented Interfaces:
SelectionModel, SingleSelectionModel

public abstract class AbstractSelectionModel
extends java.lang.Object
implements SelectionModel

simplifies implementation of the SelectionModel

Author:
av

Field Summary
 
Fields inherited from interface com.tonbeller.wcf.selection.SelectionModel
MULTIPLE_SELECTION, MULTIPLE_SELECTION_BUTTON, MULTIPLE_SELECTION_HREF, NO_SELECTION, SINGLE_SELECTION, SINGLE_SELECTION_BUTTON, SINGLE_SELECTION_HREF
 
Constructor Summary
protected AbstractSelectionModel(int mode)
           
 
Method Summary
abstract  void add(java.lang.Object obj)
           
 void addAll(java.util.Collection c)
           
 void addSelectionListener(SelectionChangeListener l)
           
abstract  void clear()
          clears the selection
 boolean contains(java.lang.Object obj)
           
 void fireSelectionChanged(RequestContext context)
          fires a SelectionChangeEvent.
 int getMode()
           
abstract  java.util.Set getSelection()
           
 java.lang.Object getSingleSelection()
          return the only selected object or null if the selection is empty.
 boolean isEmpty()
           
 boolean isSelectable(java.lang.Object item)
          returns true for all objects except Unselectable
abstract  void remove(java.lang.Object obj)
           
 void removeSelectionListener(SelectionChangeListener l)
           
 void setMode(int mode)
           
 void setSingleSelection(java.lang.Object obj)
          sets the only selected element
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractSelectionModel

protected AbstractSelectionModel(int mode)
Method Detail

getSelection

public abstract java.util.Set getSelection()
Specified by:
getSelection in interface SelectionModel

add

public abstract void add(java.lang.Object obj)
Specified by:
add in interface SelectionModel

remove

public abstract void remove(java.lang.Object obj)
Specified by:
remove in interface SelectionModel

clear

public abstract void clear()
Description copied from interface: SingleSelectionModel
clears the selection

Specified by:
clear in interface SingleSelectionModel

getMode

public int getMode()
Specified by:
getMode in interface SelectionModel

setMode

public void setMode(int mode)
Specified by:
setMode in interface SelectionModel

addAll

public void addAll(java.util.Collection c)
Specified by:
addAll in interface SelectionModel

contains

public boolean contains(java.lang.Object obj)
Specified by:
contains in interface SelectionModel

getSingleSelection

public java.lang.Object getSingleSelection()
Description copied from interface: SingleSelectionModel
return the only selected object or null if the selection is empty.

Specified by:
getSingleSelection in interface SingleSelectionModel

setSingleSelection

public void setSingleSelection(java.lang.Object obj)
Description copied from interface: SingleSelectionModel
sets the only selected element

Specified by:
setSingleSelection in interface SingleSelectionModel

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface SingleSelectionModel

isSelectable

public boolean isSelectable(java.lang.Object item)
returns true for all objects except Unselectable

Specified by:
isSelectable in interface SingleSelectionModel
See Also:
Unselectable

fireSelectionChanged

public void fireSelectionChanged(RequestContext context)
Description copied from interface: SingleSelectionModel
fires a SelectionChangeEvent. This is not fired automatically so clients may choose when to notify the listeners (e.g. after a couple of changes have been made).

Specified by:
fireSelectionChanged in interface SingleSelectionModel
Parameters:
context -

addSelectionListener

public void addSelectionListener(SelectionChangeListener l)
Specified by:
addSelectionListener in interface SingleSelectionModel

removeSelectionListener

public void removeSelectionListener(SelectionChangeListener l)
Specified by:
removeSelectionListener in interface SingleSelectionModel