|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.tree.DefaultTreeSelectionModel
Implementation of TreeSelectionModel. Listeners are notified whenever the paths in the selection change, not the rows. In order to be able to track row changes you may wish to become a listener for expansion events on the tree and test for changes from there.
resetRowSelection is called from any of the methods that update the selected paths. If you subclass and of these methods to filter what is allowed to be selected, be sure and message resetRowSelection if you do not message super.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.
Field Summary | |
protected SwingPropertyChangeSupport |
changeSupport
Used to messaged registered listeners. |
protected int |
leadIndex
Index of the lead path in selection. |
protected TreePath |
leadPath
Last path that was added. |
protected int |
leadRow
Lead row. |
protected EventListenerList |
listenerList
Event listener list. |
protected DefaultListSelectionModel |
listSelectionModel
Handles maintaining the list selection model. |
protected RowMapper |
rowMapper
Provides a row for a given path. |
protected TreePath[] |
selection
Paths that are currently selected. |
static String |
SELECTION_MODE_PROPERTY
Property name for selectionMode. |
protected int |
selectionMode
Mode for the selection, will be either SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION. |
Fields inherited from interface javax.swing.tree.TreeSelectionModel |
CONTIGUOUS_TREE_SELECTION,
DISCONTIGUOUS_TREE_SELECTION,
SINGLE_TREE_SELECTION |
Constructor Summary | |
DefaultTreeSelectionModel()
Creates a new instance of DefaultTreeSelectionModel that is empty, and having a selection mode of DISCONTIGUOUS_TREE_SELECTION. |
Method Summary | |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. |
void |
addSelectionPath(TreePath path)
Adds path to the current selection. |
void |
addSelectionPaths(TreePath[] paths)
Adds paths to the current selection. |
void |
addTreeSelectionListener(TreeSelectionListener x)
Adds x to the list of listeners that are notified each time the selection changes. |
protected boolean |
arePathsContiguous(TreePath[] paths)
Returns true if the paths are contiguous. |
protected boolean |
canPathsBeAdded(TreePath[] paths)
Returns true if the paths can be added without breaking the continuity of the model. |
protected boolean |
canPathsBeRemoved(TreePath[] paths)
Returns true if the paths can be removed without breaking the continuity of the model. |
void |
clearSelection()
Empties the current selection. |
Object |
clone()
Returns a clone of the reciever with the same selection. |
protected void |
fireValueChanged(TreeSelectionEvent e)
|
TreePath |
getLeadSelectionPath()
Returns the last path that was added. |
int |
getLeadSelectionRow()
Returns the lead selection index. |
int |
getMaxSelectionRow()
Gets the last selected row. |
int |
getMinSelectionRow()
Gets the first selected row. |
RowMapper |
getRowMapper()
Returns the RowMapper instance that is able to map a path to a row. |
int |
getSelectionCount()
Returns the number of paths that are selected. |
int |
getSelectionMode()
Returns the selection mode. |
TreePath |
getSelectionPath()
Returns the first path in the selection. |
TreePath[] |
getSelectionPaths()
Returns the paths in the selection. |
int[] |
getSelectionRows()
Returns all of the currently selected rows. |
protected void |
insureRowContinuity()
Useful for CONTIGUOUS_TREE_SELECTION. |
protected void |
insureUniqueness()
Insures that all the elements in path are unique. |
boolean |
isPathSelected(TreePath path)
Returns true if the path, path, is in the current selection. |
boolean |
isRowSelected(int row)
Returns true if the row identitifed by row is selected. |
boolean |
isSelectionEmpty()
Returns true if the selection is currently empty. |
protected void |
notifyPathChange(Vector changedPaths,
TreePath oldLeadSelection)
Notifies listeners of a change in path. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. |
void |
removeSelectionPath(TreePath path)
Removes path from the selection. |
void |
removeSelectionPaths(TreePath[] paths)
Removes paths from the selection. |
void |
removeTreeSelectionListener(TreeSelectionListener x)
Removes x from the list of listeners that are notified each time the selection changes. |
void |
resetRowSelection()
Recalculates what rows are selected by asking the RowMapper for the row for each path. |
void |
setRowMapper(RowMapper newMapper)
Sets the RowMapper instance. |
void |
setSelectionMode(int mode)
Sets the selection model, which must be one of SINGLE_TREE_SELECTION, CONTIGUOUS_TREE_SELECTION or DISCONTIGUOUS_TREE_SELECTION. |
void |
setSelectionPath(TreePath path)
Sets the selection to path. |
void |
setSelectionPaths(TreePath[] pPaths)
Sets the selection to the paths in paths. |
String |
toString()
Returns a string that displays and identifies this object's properties. |
protected void |
updateLeadIndex()
Updates the leadIndex instance variable. |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final String SELECTION_MODE_PROPERTY
protected SwingPropertyChangeSupport changeSupport
protected TreePath[] selection
protected EventListenerList listenerList
protected transient RowMapper rowMapper
protected DefaultListSelectionModel listSelectionModel
protected int selectionMode
protected TreePath leadPath
protected int leadIndex
protected int leadRow
Constructor Detail |
public DefaultTreeSelectionModel()
Method Detail |
public void setRowMapper(RowMapper newMapper)
public RowMapper getRowMapper()
public void setSelectionMode(int mode)
public int getSelectionMode()
public void setSelectionPath(TreePath path)
path
- new path to selectpublic void setSelectionPaths(TreePath[] pPaths)
paths
- new selection.public void addSelectionPath(TreePath path)
path
- the new path to add to the current selection.public void addSelectionPaths(TreePath[] paths)
path
- the new path to add to the current selection.public void removeSelectionPath(TreePath path)
path
- the path to remove from the selection.public void removeSelectionPaths(TreePath[] paths)
path
- the path to remove from the selection.public TreePath getSelectionPath()
public TreePath[] getSelectionPaths()
public int getSelectionCount()
public boolean isPathSelected(TreePath path)
public boolean isSelectionEmpty()
public void clearSelection()
public void addTreeSelectionListener(TreeSelectionListener x)
x
- the new listener to be added.public void removeTreeSelectionListener(TreeSelectionListener x)
x
- the listener to remove.protected void fireValueChanged(TreeSelectionEvent e)
public int[] getSelectionRows()
public int getMinSelectionRow()
public int getMaxSelectionRow()
public boolean isRowSelected(int row)
public void resetRowSelection()
public int getLeadSelectionRow()
public TreePath getLeadSelectionPath()
public void addPropertyChangeListener(PropertyChangeListener listener)
A PropertyChangeEvent will get fired in response to an explicit setFont, setBackground, or SetForeground on the current component. Note that if the current component is inheriting its foreground, background, or font from its container, then no event will be fired in response to a change in the inherited property.
listener
- The PropertyChangeListener to be addedpublic void removePropertyChangeListener(PropertyChangeListener listener)
listener
- The PropertyChangeListener to be removedprotected void insureRowContinuity()
protected boolean arePathsContiguous(TreePath[] paths)
protected boolean canPathsBeAdded(TreePath[] paths)
protected boolean canPathsBeRemoved(TreePath[] paths)
protected void notifyPathChange(Vector changedPaths, TreePath oldLeadSelection)
protected void updateLeadIndex()
protected void insureUniqueness()
public String toString()
public Object clone() throws CloneNotSupportedException
clone
method.
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |