|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.tree.DefaultTreeSelectionModel
public class DefaultTreeSelectionModel
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.
| 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. |
static String |
SELECTION_MODE_PROPERTY
The name of the selection mode property. |
protected int |
selectionMode
The current selection mode. |
| Fields inherited from interface javax.swing.tree.TreeSelectionModel |
|---|
CONTIGUOUS_TREE_SELECTION, DISCONTIGUOUS_TREE_SELECTION, SINGLE_TREE_SELECTION |
| 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 |
|
|
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<javax.swing.tree.DefaultTreeSelectionModel.PathPlaceHolder> 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. |
|
| 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 Object clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedException - should not be thrown hereCloneablepublic String toString()
toString in class ObjectObject.getClass(),
Object.hashCode(),
Class.getName(),
Integer.toHexString(int)public void setRowMapper(RowMapper mapper)
setRowMapper in interface TreeSelectionModelmapper - the RowMapper to setRowMapperpublic RowMapper getRowMapper()
getRowMapper in interface TreeSelectionModelRowMapperpublic void setSelectionMode(int mode)
TreeSelectionModel.SINGLE_TREE_SELECTION, TreeSelectionModel.CONTIGUOUS_TREE_SELECTION and
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION.
setSelectionMode in interface TreeSelectionModelmode - the selection mode to be setgetSelectionMode(),
TreeSelectionModel.SINGLE_TREE_SELECTION,
TreeSelectionModel.CONTIGUOUS_TREE_SELECTION,
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTIONpublic int getSelectionMode()
getSelectionMode in interface TreeSelectionModelsetSelectionMode(int),
TreeSelectionModel.SINGLE_TREE_SELECTION,
TreeSelectionModel.CONTIGUOUS_TREE_SELECTION,
TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTIONpublic void setSelectionPath(TreePath path)
setSelectionPath in interface TreeSelectionModelpath - the path to set as selectionpublic void setSelectionPaths(TreePath[] paths)
setSelectionPaths in interface TreeSelectionModelpaths - the paths to set as selectionpublic void addSelectionPath(TreePath path)
addSelectionPath in interface TreeSelectionModelpath - the path to add to the selectionpublic void addSelectionPaths(TreePath[] paths)
addSelectionPaths in interface TreeSelectionModelpaths - the paths to add to the selectionpublic void removeSelectionPath(TreePath path)
removeSelectionPath in interface TreeSelectionModelpath - the path to removepublic void removeSelectionPaths(TreePath[] paths)
removeSelectionPaths in interface TreeSelectionModelpaths - the paths to removepublic TreePath getSelectionPath()
TreeSelectionModel.SINGLE_TREE_SELECTION.
getSelectionPath in interface TreeSelectionModelpublic TreePath[] getSelectionPaths()
getSelectionPaths in interface TreeSelectionModelpublic int getSelectionCount()
getSelectionCount in interface TreeSelectionModelpublic boolean isPathSelected(TreePath path)
isPathSelected in interface TreeSelectionModelpath - the path to check
true if the path is in the selection,
false otherwisepublic boolean isSelectionEmpty()
isSelectionEmpty in interface TreeSelectionModeltrue if the selection is empty, false
otherwisepublic void clearSelection()
clearSelection in interface TreeSelectionModelpublic void addTreeSelectionListener(TreeSelectionListener listener)
TreeSelectionListener object to this model.
addTreeSelectionListener in interface TreeSelectionModellistener - the listener to addpublic void removeTreeSelectionListener(TreeSelectionListener listener)
TreeSelectionListener object from this model.
removeTreeSelectionListener in interface TreeSelectionModellistener - the listener to removepublic TreeSelectionListener[] getTreeSelectionListeners()
TreeSelectionListener added to this model.
protected void fireValueChanged(TreeSelectionEvent event)
event - the event to fire.public <T extends EventListener> T[] getListeners(Class<T> listenerType)
listenerType - the listener type
public int[] getSelectionRows()
getSelectionRows in interface TreeSelectionModelpublic int getMinSelectionRow()
getMinSelectionRow in interface TreeSelectionModelpublic int getMaxSelectionRow()
getMaxSelectionRow in interface TreeSelectionModelpublic boolean isRowSelected(int row)
isRowSelected in interface TreeSelectionModelrow - 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.public void resetRowSelection()
resetRowSelection in interface TreeSelectionModelpublic int getLeadSelectionRow()
getLeadSelectionRow in interface TreeSelectionModelpublic TreePath getLeadSelectionPath()
getLeadSelectionPath in interface TreeSelectionModelpublic void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener object to this model.
addPropertyChangeListener in interface TreeSelectionModellistener - the listener to add.public void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener object from this model.
removePropertyChangeListener in interface TreeSelectionModellistener - the listener to remove.public PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListener objects.
protected void insureRowContinuity()
TreeSelectionModel.CONTIGUOUS_TREE_SELECTION and the selection isn't contiguous then
the selection is reset to the first set of contguous paths. If the
selectionMode is set to TreeSelectionModel.SINGLE_TREE_SELECTION and the selection
has more than one path, the selection is reset to the contain only the
first path.
protected boolean arePathsContiguous(TreePath[] paths)
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 assignedprotected boolean canPathsBeAdded(TreePath[] paths)
true if:
paths is null or emptyTreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION
paths - the paths to check
true if the paths can be added with respect to the
selectionModeprotected boolean canPathsBeRemoved(TreePath[] paths)
paths - the paths to check
true if the paths can be removed with respect to the
selectionMode
protected void notifyPathChange(Vector<javax.swing.tree.DefaultTreeSelectionModel.PathPlaceHolder> vPaths,
TreePath oldLeadSelection)
vPaths - the vector of the changed patchesoldLeadSelection - the old selection indexprotected void updateLeadIndex()
protected void insureUniqueness()
setSelectionPaths(TreePath[]) and
addSelectionPaths(TreePath[]).
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||