|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.northwestern.at.utils.swing.XDropTarget edu.northwestern.at.utils.swing.TreeDropTargetOnItem
public abstract class TreeDropTargetOnItem
An abstract base class for JTree drop targets where the targets are the nodes.
This base class is appropriate for use in situations where drops are on nodes rather than between them.
As the user moves the mouse over the tree, the node under the mouse is hilighted by outlining it and painting over it with translucent green. Only "valid" target nodes are hilighted. The concrete subclass must implement the targetIsValid method to make the decision about which nodes are valid targets.
The concrete subclass must also implement the acceptDrop method to accept or reject a drop on a node.
This class implements "hovering". If the user pauses over a node for two seconds, the node is toggled - it is expanded if it was collapsed, and it is collapsed if it was expanded.
Thanks to the superclass XDropTarget
trees also autoscroll
during drags.
Nested Class Summary | |
---|---|
class |
TreeDropTargetOnItem.MyRenderer
The renderer interceptor. |
Field Summary | |
---|---|
protected int |
hilightRow
The current hilighted row, or -1 if none. |
protected javax.swing.Timer |
hoverTimer
The hover timer. |
protected boolean |
targetIsValid
True if the current target is valid and should be hilighted. |
protected javax.swing.tree.TreePath |
targetPath
The current target path, or null if none. |
protected javax.swing.JTree |
tree
The tree. |
Constructor Summary | |
---|---|
TreeDropTargetOnItem(javax.swing.JTree tree,
javax.swing.JScrollPane scrollPane)
Constructs a new tree drop target. |
Method Summary | |
---|---|
abstract void |
acceptDrop(javax.swing.tree.TreePath path,
java.awt.dnd.DropTargetDropEvent dtde)
Accepts a drop on a target. |
void |
dragExit(java.awt.dnd.DropTargetEvent dte)
Handles drag exit events. |
void |
dragOver(java.awt.dnd.DropTargetDragEvent dtde)
Handles drag over events. |
void |
drop(java.awt.dnd.DropTargetDropEvent dtde)
Handles drop events. |
int |
getScrollIncrement(boolean up)
Gets the scroll increment for autoscrolling. |
protected void |
repaintTarget()
Repaints the target node. |
void |
stopDrag()
Stops a drag. |
abstract boolean |
targetIsValid(javax.swing.tree.TreePath path,
java.util.List flavors)
Returns true if a target node is valid. |
Methods inherited from class edu.northwestern.at.utils.swing.XDropTarget |
---|
dragEnter, dropActionChanged, setGhost, stopCurrentTarget |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected javax.swing.JTree tree
protected javax.swing.tree.TreePath targetPath
protected boolean targetIsValid
protected int hilightRow
protected javax.swing.Timer hoverTimer
This timer fires if the user hovers over a node for two seconds. It toggles the node, expanding it if it was collapsed, and collapsing it if it was expanded.
Constructor Detail |
---|
public TreeDropTargetOnItem(javax.swing.JTree tree, javax.swing.JScrollPane scrollPane)
tree
- The tree.scrollPane
- The scroll pane if the tree is scrollable,
else null. Method Detail |
---|
protected void repaintTarget()
public int getScrollIncrement(boolean up)
getScrollIncrement
in class XDropTarget
up
- True if scrolling up, false if scrolling down. public void stopDrag()
stopDrag
in class XDropTarget
public void dragExit(java.awt.dnd.DropTargetEvent dte)
dragExit
in interface java.awt.dnd.DropTargetListener
dragExit
in class XDropTarget
dte
- The event. public void dragOver(java.awt.dnd.DropTargetDragEvent dtde)
dragOver
in interface java.awt.dnd.DropTargetListener
dragOver
in class XDropTarget
dtde
- The event. public void drop(java.awt.dnd.DropTargetDropEvent dtde)
drop
in interface java.awt.dnd.DropTargetListener
drop
in class XDropTarget
dtde
- The event. public abstract boolean targetIsValid(javax.swing.tree.TreePath path, java.util.List flavors)
path
- The target path.flavors
- A list of the data flavors in the drag source.
public abstract void acceptDrop(javax.swing.tree.TreePath path, java.awt.dnd.DropTargetDropEvent dtde)
path
- The target path on which the drop occurred.dtde
- The drop target drop event.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |