sos.reports
Class TierReportSelectionModel

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

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

A selection model for rows and columns.

By default, selection ranges are allowed. To control multiple selection, use setSelectionMode.

Before moving the selection to a tier, this model invokes isTierSelectable, allowing subclasses to easily customize tier selection. For example, a client who wishes to ignore the first three tiers may customize TierReportSelectionModel as follows:

  TierReportSelectionModel model = new TierReportSelectionModel() {
    protected boolean isTierSelectable( TierElement tierElement )
    {
      if( !super.isTierSelectable( tierElement ))
        return false;

      if( tierElement.getIndex() < 3 )
        return false;

      return true;
    }
  };
 
Warning: TierReportSelectionModel is intended to be used to control the selection within a single table. Clients may see unspecified results if the same selection model is used across multiple tables.

Since:
1.0
See Also:
CellReportSelectionModel

Constructor Summary
TierReportSelectionModel(int tierType)
          Creates an instance of TierReportSelectionModel for the specified tier type.
TierReportSelectionModel(int tierType, boolean headerSelectable, boolean footerSelectable)
          Creates an instance of TierReportSelectionModel for the specified tier type that can select headers and footers as specified.
 
Method Summary
 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.
 int getSelectionMode()
          Returns the tier selection mode.
 int getTierType()
          Returns TableElement.ROW if this selection model selects rows and TableElement.COLUMN if this selection model selects columns.
 boolean isFooterSelectable()
          Returns true if footer tiers can be selected.
 boolean isHeaderSelectable()
          Returns true if header tiers can be selected.
 boolean isSelected(Element element)
          Returns true if the specified element is selected.
protected  boolean isTierSelectable(TierElement tierElement)
          Returns true if the specified tier element is allowed to be selected.
 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 setFooterSelectable(boolean selectable)
          Specifies if footer tiers can be selected.
 void setHeaderSelectable(boolean selectable)
          Specifies if header tiers can be selected.
 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.
 void setSelectionMode(int selectionMode)
          Sets the selection mode.
 
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

TierReportSelectionModel

public TierReportSelectionModel(int tierType)
Creates an instance of TierReportSelectionModel for the specified tier type. By default, the selection mode will be ListSelectionModel.MULTIPLE_INTERVAL_SELECTION and header and footer tiers will not be selectable.

Parameters:
tierType - either TableElement.ROW or TableElement.COLUMN
Throws:
java.lang.IllegalArgumentException - if tierType is not TableElement.ROW or TableElement.COLUMN
See Also:
TierReportSelectionModel(int,boolean,boolean)

TierReportSelectionModel

public TierReportSelectionModel(int tierType,
                                boolean headerSelectable,
                                boolean footerSelectable)
Creates an instance of TierReportSelectionModel for the specified tier type that can select headers and footers as specified. By default, the selection mode will be ListSelectionModel.MULTIPLE_INTERVAL_SELECTION.

Parameters:
tierType - either TableElement.ROW or TableElement.COLUMN
headerSelectable - true if header tiers can be selected
footerSelectable - true if footer tiers can be selected
Throws:
java.lang.IllegalArgumentException - if tierType is not TableElement.ROW or TableElement.COLUMN
Method Detail

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

getSelectionMode

public int getSelectionMode()
Returns the tier selection mode.

Returns:
one of ListSelectionModel.MULTIPLE_INTERVAL_SELECTION, ListSelectionModel.SINGLE_INTERVAL_SELECTION, and ListSelectionModel.SINGLE_SELECTION.
See Also:
setSelectionMode(int)

getTierType

public int getTierType()
Returns TableElement.ROW if this selection model selects rows and TableElement.COLUMN if this selection model selects columns.

Returns:
the type of tiers that is selectable

isFooterSelectable

public boolean isFooterSelectable()
Returns true if footer tiers can be selected.

Returns:
whether or not footer tiers are selectable
See Also:
setFooterSelectable(boolean)

isHeaderSelectable

public boolean isHeaderSelectable()
Returns true if header tiers can be selected.

Returns:
whether or not header tiers are selectable
See Also:
setHeaderSelectable(boolean)

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

isTierSelectable

protected boolean isTierSelectable(TierElement tierElement)
Returns true if the specified tier element is allowed to be selected. This implementation returns true for body tiers, for header tiers if isHeaderSelectable returns false, and for footer tiers if isFooterSelectable return false. Subclasses may override this method to further restrict tier selection.

Parameters:
tierElement - the tier element in consideration
Returns:
true if tierElement is selectable

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()

setFooterSelectable

public void setFooterSelectable(boolean selectable)
Specifies if footer tiers can be selected.

Parameters:
selectable - true if footer tiers are selectable
See Also:
isFooterSelectable()

setHeaderSelectable

public void setHeaderSelectable(boolean selectable)
Specifies if header tiers can be selected.

Parameters:
selectable - true if header tiers are selectable
See Also:
isHeaderSelectable()

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

setSelectionMode

public void setSelectionMode(int selectionMode)
Sets the selection mode.

Parameters:
selectionMode - the ability to select ranges and multiple elements
Throws:
java.lang.IllegalArgumentException - selectionMode is not one of ListSelectionEvent.MULTIPLE_INTERVAL_SELECTION, ListSelectionEvent.SINGLE_INTERVAL_SELECTION, or ListSelectionEvent.SINGLE_SELECTION
See Also:
getSelectionMode()


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