forked from Coded/SIPRP
git-svn-id: https://svn.coded.pt/svn/SIPRP@1384 bb69d46d-e84e-40c8-a05a-06db0d633741
parent
479bc67797
commit
3008aa623c
Binary file not shown.
@ -1,59 +0,0 @@
|
||||
package leaf.ui;
|
||||
|
||||
import java.awt.Insets;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
|
||||
public abstract class DraggableLeafTree extends LeafTree
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public DraggableLeafTree( TreeModel model )
|
||||
{
|
||||
super(model);
|
||||
setDragEnabled( true );
|
||||
setAutoscrolls( true );
|
||||
setDropTarget();
|
||||
}
|
||||
|
||||
public abstract void setDropTarget( );
|
||||
|
||||
public void autoscroll( Point cursorLocation )
|
||||
{
|
||||
Insets insets = getAutoscrollInsets();
|
||||
Rectangle outer = getVisibleRect();
|
||||
Rectangle inner = new Rectangle( outer.x + insets.left, outer.y + insets.top, outer.width - ( insets.left+insets.right ), outer.height - ( insets.top+insets.bottom ) );
|
||||
|
||||
if ( !inner.contains(cursorLocation ) )
|
||||
{
|
||||
Rectangle scrollRect = new Rectangle( cursorLocation.x - insets.left, cursorLocation.y - insets.top, insets.left + insets.right, insets.top + insets.bottom );
|
||||
scrollRectToVisible(scrollRect);
|
||||
}
|
||||
}
|
||||
|
||||
public Insets getAutoscrollInsets()
|
||||
{
|
||||
return new Insets( 20, 20, 20, 20 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Object getSelectedObject()
|
||||
{
|
||||
DefaultMutableTreeNode node = getSelectedNode();
|
||||
return node == null ? null : node.getUserObject();
|
||||
}
|
||||
|
||||
public DefaultMutableTreeNode getSelectedNode()
|
||||
{
|
||||
TreePath path = getSelectionPath();
|
||||
return path == null ? null : (DefaultMutableTreeNode) path.getLastPathComponent();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue