sos.reports
Class CompositeReportSelectionModel

java.lang.Object
  |
  +--sos.reports.AbstractReportSelectionModel
        |
        +--sos.reports.CompositeReportSelectionModel
All Implemented Interfaces:
ReportSelectionModel, java.io.Serializable

public class CompositeReportSelectionModel
extends AbstractReportSelectionModel
implements ReportSelectionModel, java.io.Serializable

A report selection model that combines a number of selection models into one. It gives precedence first to the model handling the selection and then to the list of selection models (in the order they were added).

Since:
1.0
See Also:
TierReportSelectionModel, CellReportSelectionModel, TemplateReportSelectionModel

Constructor Summary
CompositeReportSelectionModel()
          Creates an empty CompositeReportSelectionModel.
CompositeReportSelectionModel(java.util.List selectionModels)
          Creates a CompositeReportSelectionModel with the specified array of selection models.
CompositeReportSelectionModel(ReportSelectionModel[] selectionModels)
          Creates a CompositeReportSelectionModel with the specified array of selection models.
 
Method Summary
 void addSelectionModel(ReportSelectionModel selectionModel)
          Appends the specified selection model to this model's collection.
 boolean canSelect(Element element, boolean toggle, boolean extend)
          Returns true if the specified element is selectable given the current selection and the state of toggle and extend.
 void clearSelection()
          Clears the current selection, if any.
 Element getAnchorSelectionElement()
          Returns the element passed to the last successful invocation of select with the extend paramter set to false.
 Element getLeadSelectionElement()
          Returns the element passed to the last successful invocation of select.
 java.util.Set getSelectedElements()
          Returns the set of selected elements.
 boolean isSelected(Element element)
          Returns true if the specified element is selected.
 void removeSelectionModel(ReportSelectionModel selectionModel)
          Removes the specified selection model from this model's collection.
 void reportChanged(ReportEvent event)
          Updates itself (if necessary) as a result of a report modification.
 void select(Element element, boolean toggle, boolean extend)
          Changes the selection.
 void setAnchorSelectionElement(Element element)
          Sets the anchor selection element.
 void setLeadSelectionElement(Element element)
          Sets the lead selection element.
 void setSelectedElements(java.util.Set elements)
          Sets the selection to the report elements in the specified set.
 
Methods inherited from class sos.reports.AbstractReportSelectionModel
addReportSelectionListener, fireSelectionChanged, fireSelectionChanged, fireSelectionChanged, getValueIsAdjusting, removeReportSelectionListener, setValueIsAdjusting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface sos.reports.ReportSelectionModel
addReportSelectionListener, getValueIsAdjusting, removeReportSelectionListener, setValueIsAdjusting
 

Constructor Detail

CompositeReportSelectionModel

public CompositeReportSelectionModel()
Creates an empty CompositeReportSelectionModel. Use addSelectionModel to add selection models.

See Also:
CompositeReportSelectionModel(ReportSelectionModel[]), CompositeReportSelectionModel(List), addSelectionModel(sos.reports.ReportSelectionModel)

CompositeReportSelectionModel

public CompositeReportSelectionModel(ReportSelectionModel[] selectionModels)
Creates a CompositeReportSelectionModel with the specified array of selection models.

Parameters:
selectionModels - initial selection models
Throws:
java.lang.NullPointerException - if selectionModels is null or any element of the array is null
See Also:
CompositeReportSelectionModel(List)

CompositeReportSelectionModel

public CompositeReportSelectionModel(java.util.List selectionModels)
Creates a CompositeReportSelectionModel with the specified array of selection models.

Parameters:
selectionModels - initial selection models
Throws:
java.lang.ClassCastException - if any element of the list is not an instance of ReportSelectionModel
java.lang.NullPointerException - if selectionModels is null
See Also:
CompositeReportSelectionModel(List)
Method Detail

addSelectionModel

public void addSelectionModel(ReportSelectionModel selectionModel)
Appends the specified selection model to this model's collection.

Parameters:
selectionModel - selection model to add to this model's collection
Throws:
java.lang.NullPointerException - if selectionModel is null
See Also:
removeSelectionModel(sos.reports.ReportSelectionModel)

canSelect

public boolean canSelect(Element element,
                         boolean toggle,
                         boolean extend)
Description copied from interface: ReportSelectionModel
Returns true if the specified element is selectable given the current selection and the state of toggle and extend. A subsequent call to select with the same arguments will throw a NotSelectableException if and only if this invocation returns false.

Specified by:
canSelect in interface ReportSelectionModel
Parameters:
element - report element on which the selection change is made
toggle - whether or not the selection should be toggled
extend - whether or not the selection should be extended to include the specified element
Returns:
true if the selection can succeed
See Also:
ReportSelectionModel.select(sos.reports.Element, boolean, boolean)

clearSelection

public void clearSelection()
Description copied from interface: ReportSelectionModel
Clears the current selection, if any. A subsequent call to getSelectedElements will return an empty set.

Specified by:
clearSelection in interface ReportSelectionModel

getAnchorSelectionElement

public Element getAnchorSelectionElement()
Description copied from interface: ReportSelectionModel
Returns the element passed to the last successful invocation of select with the extend paramter set to false.

Specified by:
getAnchorSelectionElement in interface ReportSelectionModel
Returns:
the element passed to the last successful invocation of select with the extend paramter set to false

getLeadSelectionElement

public Element getLeadSelectionElement()
Description copied from interface: ReportSelectionModel
Returns the element passed to the last successful invocation of select.

Specified by:
getLeadSelectionElement in interface ReportSelectionModel
Returns:
the element passed to the last successful invocation of select

getSelectedElements

public java.util.Set getSelectedElements()
Description copied from interface: ReportSelectionModel
Returns the set of selected elements.

Specified by:
getSelectedElements in interface ReportSelectionModel

isSelected

public boolean isSelected(Element element)
Description copied from interface: ReportSelectionModel
Returns true if the specified element is selected.

Specified by:
isSelected in interface ReportSelectionModel
Parameters:
element - report element in question
Returns:
true if element is in the selection

removeSelectionModel

public void removeSelectionModel(ReportSelectionModel selectionModel)
Removes the specified selection model from this model's collection. If selectionModel currently holds the selection, the selection is cleared.

Parameters:
selectionModel - selection model to remove from this model's collection
Throws:
java.lang.NullPointerException - if selectionModel is null
See Also:
addSelectionModel(sos.reports.ReportSelectionModel)

reportChanged

public void reportChanged(ReportEvent event)
Description copied from interface: ReportSelectionModel
Updates itself (if necessary) as a result of a report modification.

Specified by:
reportChanged in interface ReportSelectionModel
Overrides:
reportChanged in class AbstractReportSelectionModel
Parameters:
event - the event describing how the report has changed

select

public void select(Element element,
                   boolean toggle,
                   boolean extend)
            throws NotSelectableException
Description copied from interface: ReportSelectionModel
Changes the selection.

Specified by:
select in interface ReportSelectionModel
Parameters:
element - report element on which the selection change is made
toggle - whether or not the selection should be toggled
extend - whether or not the selection should be extended to include the specified element
Throws:
NotSelectableException - if the action cannot be carried out because one or more of the needed report elements are not selectable
See Also:
ReportSelectionModel.canSelect(sos.reports.Element, boolean, boolean)

setAnchorSelectionElement

public void setAnchorSelectionElement(Element element)
                               throws NotSelectableException
Description copied from interface: ReportSelectionModel
Sets the anchor selection element.

Specified by:
setAnchorSelectionElement in interface ReportSelectionModel
Parameters:
element - report element to use as the anchor
Throws:
NotSelectableException - if element is not selectable
See Also:
ReportSelectionModel.getAnchorSelectionElement()

setLeadSelectionElement

public void setLeadSelectionElement(Element element)
                             throws NotSelectableException
Description copied from interface: ReportSelectionModel
Sets the lead selection element.

Specified by:
setLeadSelectionElement in interface ReportSelectionModel
Parameters:
element - report element to use as the lead anchor
Throws:
NotSelectableException - if element is not selectable
See Also:
ReportSelectionModel.getLeadSelectionElement()

setSelectedElements

public void setSelectedElements(java.util.Set elements)
                         throws NotSelectableException
Description copied from interface: ReportSelectionModel
Sets the selection to the report elements in the specified set.

Specified by:
setSelectedElements in interface ReportSelectionModel
Parameters:
elements - report elements to be selected
Throws:
NotSelectableException - if any element in the set is not selectable


Copyright 2003, 2004 Side of Software (SOS). All rights reserved.