javax.swing.tree
public class DefaultTreeSelectionModel extends Object implements Cloneable, Serializable, TreeSelectionModel
Field Summary | |
---|---|
protected SwingPropertyChangeSupport | changeSupport
Our Swing property change support. |
protected int | leadIndex
The index of the last added path. |
protected TreePath | leadPath
The path that has been added last. |
protected int | leadRow
The row of the last added path according to the RowMapper. |
protected EventListenerList | listenerList
Our TreeSelectionListeners. |
protected DefaultListSelectionModel | listSelectionModel
The current listSelectionModel. |
protected RowMapper | rowMapper
The current RowMapper. |
protected TreePath[] | selection
The current selection. |
protected int | selectionMode
The current selection mode. |
static String | SELECTION_MODE_PROPERTY
The name of the selection mode property. |
Constructor Summary | |
---|---|
DefaultTreeSelectionModel()
Constructs a new DefaultTreeSelectionModel. |
Method Summary | |
---|---|
void | addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener object to this model.
|
void | addSelectionPath(TreePath path)
Adds a path to the list of selected paths. |
void | addSelectionPaths(TreePath[] paths)
Adds the paths to the list of selected paths. |
void | addTreeSelectionListener(TreeSelectionListener listener)
Adds a TreeSelectionListener object to this model.
|
protected boolean | arePathsContiguous(TreePath[] paths)
Returns true if the paths are contiguous (take subsequent
rows in the diplayed tree view. |
protected boolean | canPathsBeAdded(TreePath[] paths)
Checks if the paths can be added. |
protected boolean | canPathsBeRemoved(TreePath[] paths)
Checks if the paths can be removed without breaking the continuity of the
selection according to selectionMode.
|
void | clearSelection()
Removes all paths from the selection. |
Object | clone()
Creates a clone of this DefaultTreeSelectionModel with the same selection.
|
protected void | fireValueChanged(TreeSelectionEvent event)
fireValueChanged
|
TreePath | getLeadSelectionPath()
getLeadSelectionPath
|
int | getLeadSelectionRow()
getLeadSelectionRow
|
<T extends EventListener> T[] | getListeners(Class<T> listenerType)
Returns all added listeners of a special type.
|
int | getMaxSelectionRow()
Returns the largest row index from the selection.
|
int | getMinSelectionRow()
Returns the smallest row index from the selection.
|
PropertyChangeListener[] | getPropertyChangeListeners()
Returns all added PropertyChangeListener objects.
|
RowMapper | getRowMapper()
Returns the RowMapper that is currently used to map between paths and their
rows.
|
int | getSelectionCount()
Returns the number of paths in the selection.
|
int | getSelectionMode()
Returns the current selection mode.
|
TreePath | getSelectionPath()
Returns the first path in the selection. |
TreePath[] | getSelectionPaths()
Returns the complete selection.
|
int[] | getSelectionRows()
Returns the currently selected rows.
|
TreeSelectionListener[] | getTreeSelectionListeners()
Returns all TreeSelectionListener added to this model.
|
protected void | insureRowContinuity()
Makes sure the currently selected paths are valid according to the current
selectionMode. |
protected void | insureUniqueness()
This method exists due historical reasons and returns without action
(unless overridden). |
boolean | isPathSelected(TreePath path)
Checks if a given path is in the selection.
|
boolean | isRowSelected(int row)
Checks if a particular row is selected.
|
boolean | isSelectionEmpty()
Checks if the selection is empty.
|
protected void | notifyPathChange(Vector vPaths, TreePath oldLeadSelection)
Notify the installed listeners that the given patches have changed. |
void | removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener object from this model.
|
void | removeSelectionPath(TreePath path)
Removes the path from the selection. |
void | removeSelectionPaths(TreePath[] paths)
Removes the paths from the selection. |
void | removeTreeSelectionListener(TreeSelectionListener listener)
Removes a TreeSelectionListener object from this model.
|
void | resetRowSelection()
Updates the mappings from TreePaths to row indices. |
void | setRowMapper(RowMapper mapper)
Sets the RowMapper that should be used to map between paths and their rows.
|
void | setSelectionMode(int mode)
Sets the current selection mode. |
void | setSelectionPath(TreePath path)
Sets this path as the only selection. |
void | setSelectionPaths(TreePath[] paths)
Sets the paths as selection. |
String | toString()
Returns a string that shows this object's properties.
|
protected void | updateLeadIndex()
Updates the lead selection row number after changing the lead selection
path. |
PropertyChangeListener
object to this model.
Parameters: listener the listener to add.
Parameters: path the path to add to the selection
Parameters: paths the paths to add to the selection
TreeSelectionListener
object to this model.
Parameters: listener the listener to add
true
if the paths are contiguous (take subsequent
rows in the diplayed tree view. The method returns true
if
we have no RowMapper assigned.
Parameters: paths the paths to check for continuity
Returns: true
if the paths are contiguous or we have no
RowMapper assigned
true
if:
paths
is null
or emptyParameters: paths the paths to check
Returns: true
if the paths can be added with respect to the
selectionMode
Parameters: paths the paths to check
Returns: true
if the paths can be removed with respect to the
selectionMode
Returns: a copy of this DefaultTreeSelectionModel
Throws: CloneNotSupportedException should not be thrown here
Parameters: event the event to fire.
Returns: TreePath
Returns: int
Parameters: listenerType the listener type
Returns: an array of listeners
Since: 1.3
Returns: the largest row index from the selection
Returns: the smallest row index from the selection
PropertyChangeListener
objects.
Returns: an array of listeners.
Since: 1.4
Returns: the current RowMapper
See Also: RowMapper
Returns: the number of paths in the selection
Returns: the current selection mode
See Also: DefaultTreeSelectionModel DefaultTreeSelectionModel DefaultTreeSelectionModel DefaultTreeSelectionModel
Returns: the first path in the selection
Returns: the complete selection
Returns: the currently selected rows
TreeSelectionListener
added to this model.
Returns: an array of listeners
Since: 1.4
Parameters: path the path to check
Returns: true
if the path is in the selection,
false
otherwise
Parameters: row the index of the row to check
Returns: true
if the row is in this selection,
false
otherwise
Throws: NullPointerException if the row mapper is not set (can only happen if the user has plugged in the custom incorrect TreeUI implementation.
Returns: true
if the selection is empty, false
otherwise
Parameters: vPaths the vector of the changed patches oldLeadSelection the old selection index
PropertyChangeListener
object from this model.
Parameters: listener the listener to remove.
Parameters: path the path to remove
Parameters: paths the paths to remove
TreeSelectionListener
object from this model.
Parameters: listener the listener to remove
Parameters: mapper the RowMapper to set
See Also: RowMapper
Parameters: mode the selection mode to be set
See Also: DefaultTreeSelectionModel DefaultTreeSelectionModel DefaultTreeSelectionModel DefaultTreeSelectionModel
Parameters: path the path to set as selection
Parameters: paths the paths to set as selection
Returns: a string that shows this object's properties