org.barracudamvc.core.comp
Class DefaultListSelectionModel

java.lang.Object
  extended by org.barracudamvc.core.comp.DefaultListSelectionModel
All Implemented Interfaces:
Serializable, Cloneable, ListSelectionModel, Model

public class DefaultListSelectionModel
extends Object
implements ListSelectionModel, Cloneable, Serializable

Default data model implementation for list selections.

See Also:
Serialized Form

Field Summary
protected  List listeners
           
 
Fields inherited from interface org.barracudamvc.core.comp.ListSelectionModel
MULTIPLE_INTERVAL_SELECTION, SINGLE_INTERVAL_SELECTION, SINGLE_SELECTION
 
Constructor Summary
DefaultListSelectionModel()
           
 
Method Summary
 void addModelListener(ModelListener ml)
          Add a listener to the template that's notified each time a change to the data model occurs.
 void addSelectionInterval(int index0, int index1)
          Change the selection to be the set union of the current selection and the indices between index0 and index1 inclusive.
 void clearSelection()
          Change the selection to the empty set.
 Object clone()
          Returns a clone of this selection model with the same selection.
 void fireModelChanged()
          Forwards the given notification event to all TemplateModelListeners that registered themselves as listeners for this template model.
 int getMaxSelectionIndex()
          Returns the last selected index or -1 if the selection is empty.
 int getMinSelectionIndex()
          Returns the first selected index or -1 if the selection is empty.
 int getSelectionMode()
          Returns the selection mode.
 boolean isSelectedIndex(int index)
          Returns true if the specified index is selected.
 boolean isSelectionEmpty()
          Returns true if no indices are selected.
 void removeModelListener(ModelListener ml)
          Remove a listener
 void removeSelectionInterval(int index0, int index1)
          Change the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive.
 void setSelectionInterval(int index0, int index1)
          Change the selection to be between index0 and index1 inclusive.
 void setSelectionMode(int selectionMode)
          Sets the selection mode.
 String toString()
          Returns a string that displays and identifies this object's properties.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

listeners

protected List listeners
Constructor Detail

DefaultListSelectionModel

public DefaultListSelectionModel()
Method Detail

addModelListener

public void addModelListener(ModelListener ml)
Add a listener to the template that's notified each time a change to the data model occurs.

Specified by:
addModelListener in interface Model
Parameters:
ml - the TemplateModelListener

removeModelListener

public void removeModelListener(ModelListener ml)
Remove a listener

Specified by:
removeModelListener in interface Model
Parameters:
ml - the TemplateModelListener

fireModelChanged

public void fireModelChanged()
Forwards the given notification event to all TemplateModelListeners that registered themselves as listeners for this template model.


setSelectionMode

public void setSelectionMode(int selectionMode)
Sets the selection mode. The default is SINGLE_SELECTION.

Specified by:
setSelectionMode in interface ListSelectionModel
Parameters:
selectionMode - one of three values:
  • SINGLE_SELECTION
  • SINGLE_INTERVAL_SELECTION
  • MULTIPLE_INTERVAL_SELECTION
Throws:
IllegalArgumentException - if selectionMode is not one of the legal values shown above
See Also:
setSelectionMode(int)

getSelectionMode

public int getSelectionMode()
Returns the selection mode.

Specified by:
getSelectionMode in interface ListSelectionModel
Returns:
one of the these values:
  • SINGLE_SELECTION
  • SINGLE_INTERVAL_SELECTION
  • MULTIPLE_INTERVAL_SELECTION
See Also:
getSelectionMode()

setSelectionInterval

public void setSelectionInterval(int index0,
                                 int index1)
Change the selection to be between index0 and index1 inclusive. If this represents a change to the current selection, then notify each ListSelectionListener. Note that index0 doesn't have to be less than or equal to index1.

Specified by:
setSelectionInterval in interface ListSelectionModel
Parameters:
index0 - one end of the interval.
index1 - other end of the interval

addSelectionInterval

public void addSelectionInterval(int index0,
                                 int index1)
Change the selection to be the set union of the current selection and the indices between index0 and index1 inclusive. If this represents a change to the current selection, then notify each ListSelectionListener. Note that index0 doesn't have to be less than or equal to index1.

Specified by:
addSelectionInterval in interface ListSelectionModel
Parameters:
index0 - one end of the interval.
index1 - other end of the interval

removeSelectionInterval

public void removeSelectionInterval(int index0,
                                    int index1)
Change the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive. If this represents a change to the current selection, then notify each ListSelectionListener. Note that index0 doesn't have to be less than or equal to index1.

Specified by:
removeSelectionInterval in interface ListSelectionModel
Parameters:
index0 - one end of the interval.
index1 - other end of the interval

getMinSelectionIndex

public int getMinSelectionIndex()
Returns the first selected index or -1 if the selection is empty.

Specified by:
getMinSelectionIndex in interface ListSelectionModel

getMaxSelectionIndex

public int getMaxSelectionIndex()
Returns the last selected index or -1 if the selection is empty.

Specified by:
getMaxSelectionIndex in interface ListSelectionModel

isSelectedIndex

public boolean isSelectedIndex(int index)
Returns true if the specified index is selected.

Specified by:
isSelectedIndex in interface ListSelectionModel

isSelectionEmpty

public boolean isSelectionEmpty()
Returns true if no indices are selected.

Specified by:
isSelectionEmpty in interface ListSelectionModel

clearSelection

public void clearSelection()
Change the selection to the empty set. If this represents a change to the current selection then notify each ListSelectionListener.

Specified by:
clearSelection in interface ListSelectionModel

toString

public String toString()
Returns a string that displays and identifies this object's properties.

Overrides:
toString in class Object
Returns:
a String representation of this object

clone

public Object clone()
             throws CloneNotSupportedException
Returns a clone of this selection model with the same selection. listenerLists are not duplicated.

Overrides:
clone in class Object
Throws:
CloneNotSupportedException - if the selection model does not both (a) implement the Cloneable interface and (b) define a clone method.


Copyright © 2006 BarracudaMVC.org All Rights Reserved.