javax.swing.tree
Class DefaultTreeSelectionModel
- Cloneable, Serializable, TreeSelectionModel
The implementation of the default tree selection model. The installed
listeners are notified about the path and not the row changes. If you
specifically need to track the row changes, register the listener for the
expansion events.
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
leadIndex
protected int leadIndex
The index of the last added path.
leadRow
protected int leadRow
The row of the last added path according to the RowMapper.
selectionMode
protected int selectionMode
The current selection mode.
addSelectionPath
public void addSelectionPath(TreePath path)
Adds a path to the list of selected paths. This method checks if the path
is already selected and doesn't add the same path twice. If this changes
the selection the registered TreeSelectionListeners are notified.
The lead path is changed to the added path. This also happen if the
passed path was already selected before.
- addSelectionPath in interface TreeSelectionModel
path
- the path to add to the selection
addSelectionPaths
public void addSelectionPaths(TreePath[] paths)
Adds the paths to the list of selected paths. This method checks if the
paths are already selected and doesn't add the same path twice. If this
changes the selection the registered TreeSelectionListeners are notified.
- addSelectionPaths in interface TreeSelectionModel
paths
- the paths to add to the selection
arePathsContiguous
protected boolean arePathsContiguous(TreePath[] paths)
Returns true
if the paths are contiguous (take subsequent
rows in the diplayed tree view. The method returns true
if
we have no RowMapper assigned.
paths
- the paths to check for continuity
true
if the paths are contiguous or we have no
RowMapper assigned
canPathsBeAdded
protected boolean canPathsBeAdded(TreePath[] paths)
Checks if the paths can be added. This returns
true
if:
paths
- the paths to check
true
if the paths can be added with respect to the
selectionMode
canPathsBeRemoved
protected boolean canPathsBeRemoved(TreePath[] paths)
Checks if the paths can be removed without breaking the continuity of the
selection according to selectionMode.
paths
- the paths to check
true
if the paths can be removed with respect to the
selectionMode
clone
public Object clone()
throws CloneNotSupportedException
Creates a clone of this DefaultTreeSelectionModel with the same selection.
The cloned instance will have the same registered listeners, the listeners
themselves will not be cloned. The selection will be cloned.
- clone in interface Object
- a copy of this DefaultTreeSelectionModel
extends EventListener> T[] getListeners
public extends EventListener> T[] getListeners(Class listenerType)
Returns all added listeners of a special type.
listenerType
- the listener type
isRowSelected
public boolean isRowSelected(int row)
Checks if a particular row is selected.
- isRowSelected in interface TreeSelectionModel
row
- the index of the row to check
true
if the row is in this selection,
false
otherwise
NullPointerException
- if the row mapper is not set (can only happen
if the user has plugged in the custom incorrect TreeUI
implementation.
notifyPathChange
protected void notifyPathChange(Vector<T> vPaths,
TreePath oldLeadSelection)
Notify the installed listeners that the given patches have changed. This
method will call listeners if invoked, but it is not called from the
implementation of this class.
vPaths
- the vector of the changed patchesoldLeadSelection
- the old selection index
setSelectionPaths
public void setSelectionPaths(TreePath[] paths)
Sets the paths as selection. This method checks for duplicates and removes
them. If this changes the selection the registered TreeSelectionListeners
are notified.
- setSelectionPaths in interface TreeSelectionModel
paths
- the paths to set as selection
toString
public String toString()
Returns a string that shows this object's properties.
The returned string lists the selected tree rows, if any.
- toString in interface Object
- a string that shows this object's properties
updateLeadIndex
protected void updateLeadIndex()
Updates the lead selection row number after changing the lead selection
path.
DefaultTreeSelectionModel.java
Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.