|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sos.reports.AbstractReportSelectionModel | +--sos.reports.CellReportSelectionModel
A selection model for table cells and cell contents. It behaves
exactly like cell selection in javax.swing.JTable
.
This selection model can handle the selection of either the cell elements themselves or their content elements, depending on the flag passed to the constructor. Also, this model controls whether or not cells (or cell contents) are selectable if they fall in a header or footer row or column.
By default, selection ranges are allowed. To control multiple selection, use
setSelectionMode
.
Before moving the selection to a cell, this model invokes isCellSelectable
,
allowing subclasses to easily customize cell selection.
For example, a client who wishes to ignore cells in the first three columns
may customize CellReportSelectionModel
as follows:
CellReportSelectionModel model = new CellReportSelectionModel() { protected boolean isCellSelectable( CellElement cellElement ) { if( !super.isTierSelectable( cellElement )) return false; if( cellElement.getFirstTier( TableElement.COLUMN ).getIndex() < 3 ) return false; return true; } };Warning:
CellReportSelectionModel
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.
TierReportSelectionModel
,
CellElement.getContent()
Constructor Summary | |
CellReportSelectionModel()
Creates an instance of CellReportSelectionModel
where the cell contents are selectable and headers and
footers are not selectable. |
|
CellReportSelectionModel(boolean contentSelectable)
Creates an instance of CellReportSelectionModel
where the cell contents are selectable if specified and headers and
footers are not selectable. |
|
CellReportSelectionModel(boolean contentSelectable,
boolean headerRowSelectable,
boolean headerColumnSelectable,
boolean footerRowSelectable,
boolean footerColumnSelectable)
Creates an instance of CellReportSelectionModel
where the cell contents, headers, and footers are selectable if 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(int tierType)
Returns the selection mode for the specified tier type. |
protected boolean |
isCellSelectable(CellElement cellElement)
Returns true if the specified cell element is allowed to be selected. |
boolean |
isFooterSelectable(int tierType)
Returns true if elements residing in footer tiers are selectable. |
boolean |
isHeaderSelectable(int tierType)
Returns true if elements residing in header tiers are selectable. |
boolean |
isSelected(Element element)
Returns true if the specified element is selected. |
void |
select(Element element,
boolean toggle,
boolean extend)
Changes the selection. |
void |
setAnchorSelectionElement(Element element)
Sets the anchor selection element. |
void |
setFooterSelectable(int tierType,
boolean selectable)
Specifies if elements residing in footer tiers are selectable. |
void |
setHeaderSelectable(int tierType,
boolean selectable)
Specifies if elements residing in header tiers are selectable. |
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 tierType,
int selectionMode)
Sets the selection mode for the specified tier type. |
Methods inherited from class sos.reports.AbstractReportSelectionModel |
addReportSelectionListener, fireSelectionChanged, fireSelectionChanged, fireSelectionChanged, getValueIsAdjusting, removeReportSelectionListener, reportChanged, 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, reportChanged, setValueIsAdjusting |
Constructor Detail |
public CellReportSelectionModel()
CellReportSelectionModel
where the cell contents are selectable and headers and
footers are not selectable.
CellReportSelectionModel(boolean,boolean,boolean,boolean,boolean)
public CellReportSelectionModel(boolean contentSelectable)
CellReportSelectionModel
where the cell contents are selectable if specified and headers and
footers are not selectable.
contentSelectable
- true
if the content element of cells
are selectable; false
if the cell element themselves
are selectableCellReportSelectionModel(boolean,boolean,boolean,boolean,boolean)
public CellReportSelectionModel(boolean contentSelectable, boolean headerRowSelectable, boolean headerColumnSelectable, boolean footerRowSelectable, boolean footerColumnSelectable)
CellReportSelectionModel
where the cell contents, headers, and footers are selectable if specified.
By default, the selection modes will
be ListSelectionModel.MULTIPLE_INTERVAL_SELECTION
in both directions.
contentSelectable
- true
if the content element of cells
are selectable; false
if the cell element themselves
are selectableheaderRowSelectable
- true
if elements residing in header rows
are selectableheaderColumnSelectable
- true
if elements residing in header columns
are selectablefooterRowSelectable
- true
if elements residing in footer rows
are selectablefooterColumnSelectable
- true
if elements residing in footer columns
are selectableMethod Detail |
public boolean canSelect(Element element, boolean toggle, boolean extend)
ReportSelectionModel
toggle
and extend
.
A subsequent call to select
with the same arguments will
throw a NotSelectableException
if and only if this invocation returns
false
.
canSelect
in interface ReportSelectionModel
element
- report element on which the selection change is madetoggle
- whether or not the selection should be toggledextend
- whether or not the selection should be extended to include
the specified element
true
if the selection can succeedReportSelectionModel.select(sos.reports.Element, boolean, boolean)
public void clearSelection()
ReportSelectionModel
getSelectedElements
will return an empty set.
clearSelection
in interface ReportSelectionModel
public Element getAnchorSelectionElement()
ReportSelectionModel
select
with the extend
paramter set to false
.
getAnchorSelectionElement
in interface ReportSelectionModel
select
with the extend
paramter set to false
public Element getLeadSelectionElement()
ReportSelectionModel
select
.
getLeadSelectionElement
in interface ReportSelectionModel
select
public java.util.Set getSelectedElements()
ReportSelectionModel
getSelectedElements
in interface ReportSelectionModel
public int getSelectionMode(int tierType)
tierType
- the direction in question. TableElement.ROW
means along the y axis; TableElement.COLUMN
means along
the x axis.
ListSelectionEvent.MULTIPLE_INTERVAL_SELECTION
,
ListSelectionEvent.SINGLE_INTERVAL_SELECTION
,
or ListSelectionEvent.SINGLE_SELECTION
java.lang.IllegalArgumentException
- if tierType
is not TableElement.ROW
or TableElement.COLUMN
setSelectionMode(int, int)
protected boolean isCellSelectable(CellElement cellElement)
true
if the specified cell element is allowed to be selected.
This implementation returns true
for body cells,
for header cells if isHeaderSelectable
returns false
,
and for footer cells if isFooterSelectable
return false
.
Subclasses may override this method to further
restrict cell selection.
cellElement
- the cell element in consideration
true
if cellElement
is selectablepublic boolean isFooterSelectable(int tierType)
true
if elements residing in footer tiers are selectable.
tierType
- the type of tier in question
java.lang.IllegalArgumentException
- if tierType is not TableElement.ROW
or TableElement.COLUMN
setFooterSelectable(int, boolean)
public boolean isHeaderSelectable(int tierType)
true
if elements residing in header tiers are selectable.
tierType
- the type of tier in question
java.lang.IllegalArgumentException
- if tierType is not TableElement.ROW
or TableElement.COLUMN
setHeaderSelectable(int, boolean)
public boolean isSelected(Element element)
ReportSelectionModel
true
if the specified element is selected.
isSelected
in interface ReportSelectionModel
element
- report element in question
true
if element
is in the selectionpublic void select(Element element, boolean toggle, boolean extend) throws NotSelectableException
ReportSelectionModel
select
in interface ReportSelectionModel
element
- report element on which the selection change is madetoggle
- whether or not the selection should be toggledextend
- whether or not the selection should be extended to include
the specified element
NotSelectableException
- if the action cannot be carried out because
one or more of the needed report elements are not selectableReportSelectionModel.canSelect(sos.reports.Element, boolean, boolean)
public void setAnchorSelectionElement(Element element) throws NotSelectableException
ReportSelectionModel
setAnchorSelectionElement
in interface ReportSelectionModel
element
- report element to use as the anchor
NotSelectableException
- if element
is not selectableReportSelectionModel.getAnchorSelectionElement()
public void setFooterSelectable(int tierType, boolean selectable)
tierType
- the type of tier in questionselectable
- true
if cell elements falling in a footer tier
can be selected
java.lang.IllegalArgumentException
- if tierType is not TableElement.ROW
or TableElement.COLUMN
isFooterSelectable(int)
public void setHeaderSelectable(int tierType, boolean selectable)
tierType
- the type of tier in questionselectable
- true
if cell elements falling in a header tier
can be selected
java.lang.IllegalArgumentException
- if tierType is not TableElement.ROW
or TableElement.COLUMN
isHeaderSelectable(int)
public void setLeadSelectionElement(Element element) throws NotSelectableException
ReportSelectionModel
setLeadSelectionElement
in interface ReportSelectionModel
element
- report element to use as the lead anchor
NotSelectableException
- if element
is not selectableReportSelectionModel.getLeadSelectionElement()
public void setSelectedElements(java.util.Set elements) throws NotSelectableException
ReportSelectionModel
setSelectedElements
in interface ReportSelectionModel
elements
- report elements to be selected
NotSelectableException
- if any element in the set is not selectablepublic void setSelectionMode(int tierType, int selectionMode)
tierType
- the direction to set the mode. TableElement.ROW
means along the y axis; TableElement.COLUMN
means along
the x axis.selectionMode
- the ability to select ranges and multiple elements
java.lang.IllegalArgumentException
- if tierType
is not TableElement.ROW
or TableElement.COLUMN
or selectionMode
is not
one of ListSelectionEvent.MULTIPLE_INTERVAL_SELECTION
,
ListSelectionEvent.SINGLE_INTERVAL_SELECTION
,
or ListSelectionEvent.SINGLE_SELECTION
getSelectionMode(int)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |