|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.table.Selection
public abstract class Selection
Defines an abstract base class for representing TableView selections.
Selection anchors a hierarchy of classes that each represent a contiguous range of a particular table element. The hierarchy is divided into two general categories, cell selections and cell vector selections, which are represented by the subclasses CellSelection and CellVectorSelection (abstract class) respectively. Cell vector selections are divided into column selections (ColumnSelection) and row selections (RowSelection).
Selection implements TableElementInterface to allow the range of elements to be treated and manipulated just like a single element. It also allows the range to used as a collection by implementing StaticCollectionInterface.
Subclass note: SelectionChangedEvents should be created whenever the selection changes. These can be sent to all registered listeners via fireContentsChanged().
CellSelection
,
CellVectorSelection
,
ColumnSelection
,
RowSelection
Field Summary |
---|
Fields inherited from interface com.sas.table.TableElementInterface |
---|
REFRESH_ALL, REFRESH_DATA, REFRESH_DATA_STYLE, REFRESH_LABEL, REFRESH_LABEL_STYLE, REFRESH_STYLE |
Constructor Summary | |
---|---|
Selection(TableElement anchor)
Alias for Selection(anchor, anchor) . |
|
Selection(TableElement anchor,
TableElement end)
Constructs a new selection with the given extent. |
Method Summary | |
---|---|
void |
addContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
Add a listener for ContentsChangedEvent. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a listener for PropertyChangeEvent. |
void |
apply(com.sas.util.ApplyInterface action)
Applies an action to every item in the selection. |
java.lang.Object |
clone()
Clones the selection. |
abstract boolean |
contains(java.lang.Object item)
Test for the presence of an item in the selection. |
abstract int |
count()
Returns the number of items in the selection. |
protected void |
fireContentsChanged(com.sas.collection.ContentsChangedEvent event)
Sends ContentsChangedEvent to all registered ContentsChangedEvent listeners. |
protected void |
firePropertyChange(java.beans.PropertyChangeEvent event)
Sends PropertyChangeEvent to all registered PropertyChangeEvent listeners. |
protected void |
firePropertyChange(java.lang.String name,
java.lang.Object oldValue,
java.lang.Object newValue)
Alias for firePropertyChange (new PropertyChangeEvent (this,
name, oldValue, newValue)) . |
java.lang.Object |
getAnchor()
Returns the object that defines the anchored or non-floating end of the selection. |
abstract java.awt.Rectangle |
getDisplayedBounds()
Returns a rectangle that represents the displayed area of the selection in the table view. |
java.lang.Object |
getEnd()
Returns the object that defines the unanchored or floating end of the selection. |
abstract java.util.Enumeration |
getItems()
Returns an enumeration of all the items in the selection. |
TableView |
getTableView()
Returns the table view that contains this selection's items. |
boolean |
isDisplayed()
Determines whether any part of the selection is displayed in the table (i.e. scrolled into view). |
boolean |
isModified()
Determines whether any of the selection's items are modified. |
boolean |
isSelected()
Determines whether any of the selection's items are selected in the table view. |
protected abstract Selection |
newSelection(TableElement anchor,
TableElement end)
Creates a new selection of the same class, but with different items. |
protected void |
onEndChanged(TableElement oldValue,
TableElement newValue)
Called by setEnd() to notify subclasses of a change
to the end. |
void |
refresh(int flags)
Refreshes the selection's items to their state as maintained by the table view's model. |
void |
removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
Remove a listener for ContentsChangedEvent. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a listener for PropertyChangeEvent. |
void |
repaint()
Repaints the selection in the table view. |
void |
setEnd(java.lang.Object newValue)
Specifies the object that defines the unanchored or floating end of the selection. |
Constructor Detail |
---|
public Selection(TableElement anchor)
Selection(anchor, anchor)
.
anchor
- The value to assign the anchor property.public Selection(TableElement anchor, TableElement end)
anchor
- The value to assign the anchor property.end
- The value to assign the end property.getAnchor()
,
getEnd()
Method Detail |
---|
public void addContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
addContentsChangedListener
in interface com.sas.collection.ContentsChangedSource
listener
- The listener to add.removeContentsChangedListener(com.sas.collection.ContentsChangedListener)
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface com.sas.beans.PropertyChangeSource
listener
- The listener to add.removePropertyChangeListener(java.beans.PropertyChangeListener)
public void apply(com.sas.util.ApplyInterface action)
ApplyInterface.ABORT
is returned from
action.apply(item)
.
apply
in interface com.sas.collection.StaticCollectionInterface
action
- An implementation of ApplyInterface.public java.lang.Object clone() throws java.lang.CloneNotSupportedException
return newSelection ((TableElement)getAnchor(),
(TableElement)getEnd());
.
clone
in interface com.sas.collection.StaticCollectionInterface
clone
in interface com.sas.PublicClonable
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if the object could not be cloned.newSelection(com.sas.table.TableElement, com.sas.table.TableElement)
public abstract boolean contains(java.lang.Object item)
contains
in interface com.sas.collection.StaticCollectionInterface
contains
in interface com.sas.models.StaticSelectionInterface
item
- The item to search for.
true
if the selection contains the item and
false
otherwise.public abstract int count()
count
in interface com.sas.util.Countable
public java.lang.Object getAnchor()
getAnchor
in interface com.sas.models.StaticSelectionInterface
public abstract java.awt.Rectangle getDisplayedBounds()
isDisplayed()
public java.lang.Object getEnd()
getEnd
in interface com.sas.models.StaticSelectionInterface
setEnd(java.lang.Object)
public abstract java.util.Enumeration getItems()
getItems
in interface com.sas.util.Enumerable
public TableView getTableView()
getTableView
in interface TableElementInterface
public final boolean isDisplayed()
!getDisplayedBounds().isEmpty()
.
isDisplayed
in interface TableElementInterface
true
if any of the items are displayed,
and false
otherwise.getDisplayedBounds()
public boolean isModified()
isModified
in interface TableElementInterface
true
if any of the items are modified,
and false
otherwise.public boolean isSelected()
isSelected
in interface TableElementInterface
true
if any of the items are selected,
and false
otherwise.public void refresh(int flags)
refresh
in interface TableElementInterface
flags
- Bitmask of REFRESH_*
bitflags.public void repaint()
repaint
in interface TableElementInterface
public void removeContentsChangedListener(com.sas.collection.ContentsChangedListener listener)
removeContentsChangedListener
in interface com.sas.collection.ContentsChangedSource
listener
- The listener to remove.addContentsChangedListener(com.sas.collection.ContentsChangedListener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface com.sas.beans.PropertyChangeSource
listener
- The listener to remove.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void setEnd(java.lang.Object newValue)
onEndChanged()
.
setEnd
in interface com.sas.models.SelectionInterface
newValue
- The new value to assign the end property.
java.lang.NullPointerException
- If newValue is null
.
java.lang.ClassCastException
- If newValue is not a
TableElement.getEnd()
,
onEndChanged(com.sas.table.TableElement, com.sas.table.TableElement)
,
addContentsChangedListener(com.sas.collection.ContentsChangedListener)
protected void fireContentsChanged(com.sas.collection.ContentsChangedEvent event)
event
- The event to send.addContentsChangedListener(com.sas.collection.ContentsChangedListener)
,
firePropertyChange(PropertyChangeEvent)
protected void firePropertyChange(java.beans.PropertyChangeEvent event)
event
- The event to send.addPropertyChangeListener(java.beans.PropertyChangeListener)
,
firePropertyChange(String,Object,Object)
,
fireContentsChanged(com.sas.collection.ContentsChangedEvent)
protected final void firePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
firePropertyChange (new PropertyChangeEvent (this,
name, oldValue, newValue))
.
name
- property name.oldValue
- previous value of the property.newValue
- current value of the property.firePropertyChange(PropertyChangeEvent)
protected abstract Selection newSelection(TableElement anchor, TableElement end)
clone()
.
anchor
- The value to assign the anchor property.end
- The value to assign the end property.
clone()
protected void onEndChanged(TableElement oldValue, TableElement newValue)
setEnd()
to notify subclasses of a change
to the end.
The default implementation fires a generic ContentsChangedEvent.
A subclass can override to provide more details about the change.
Method is not driven if there are no ContentsChanged listeners.
oldValue
- The previous value of end.newValue
- The current value of end.setEnd(java.lang.Object)
,
fireContentsChanged(com.sas.collection.ContentsChangedEvent)
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |