/** * Schedules the expand of the given treePath on a tree. * * @param treePath * The treePath to expand * @param tree * The JTree */ private void scheduleExpand(TreePath treePath, JTree tree) { // If the treepath to schedule for expand isn't already scheduled if (treePath != treePathToExpand) { getExpandTreeTimer(tree).stop(); treePathToExpand = treePath; getExpandTreeTimer(tree).start(); } }
public void dragOver(DropTargetDragEvent dtde) { JTree tree = (JTree) dtde.getDropTargetContext().getComponent(); TreeNode targetTreeNode = getNode(dtde); if (targetTreeNode != null) { updatePositionIndicator(dtde); Point p = dtde.getLocation(); TreePath currentPath = tree.getPathForLocation(p.x, p.y); TreePath parentPath = getParentPathForPosition(currentPath); TreeNode parentNode = getNodeForPath(parentPath); TreePath nextSiblingPath = getSiblingPathForPosition(currentPath); TreeNode nextSiblingNode = getNodeForPath(nextSiblingPath); Node potentialParent = getDomNodeFromTreeNode((DefaultMutableTreeNode) parentNode); dtde.acceptDrag(dtde.getDropAction()); updateVisualTipLine(tree, currentPath); scheduleExpand(currentPath, tree);
public void dragOver(DropTargetDragEvent dtde) { JTree tree = (JTree) dtde.getDropTargetContext().getComponent(); TreeNode targetTreeNode = getNode(dtde); if (targetTreeNode != null) { updatePositionIndicator(dtde); Point p = dtde.getLocation(); TreePath currentPath = tree.getPathForLocation(p.x, p.y); TreePath parentPath = getParentPathForPosition(currentPath); TreeNode parentNode = getNodeForPath(parentPath); TreePath nextSiblingPath = getSiblingPathForPosition(currentPath); TreeNode nextSiblingNode = getNodeForPath(nextSiblingPath); Node potentialParent = getDomNodeFromTreeNode((DefaultMutableTreeNode) parentNode); dtde.acceptDrag(dtde.getDropAction()); updateVisualTipLine(tree, currentPath); scheduleExpand(currentPath, tree);
/** * Finds the TreePath that is going to be next sibling to the nodes that * are being dragged. * * @param currentPath * The current path (the items are dragged over this path) * @return sibling TreePath */ private TreePath getSiblingPathForPosition(TreePath currentPath) { TreePath parentPath = getParentPathForPosition(currentPath); TreePath nextSiblingPath = null; if (positionIndicator == AFTER) { TreeNode parentNode = getNodeForPath(parentPath); TreeNode currentNode = getNodeForPath(currentPath); if (parentPath != null && parentNode != null && currentNode != null) { int siblingIndex = parentNode.getIndex(currentNode) + 1; if (parentNode.getChildCount() > siblingIndex) { nextSiblingPath = parentPath.pathByAddingChild (parentNode.getChildAt(siblingIndex)); } } } else if (positionIndicator == BEFORE) { nextSiblingPath = currentPath; } else if (positionIndicator == CURRENT) { nextSiblingPath = null; } return nextSiblingPath; }
JTree tree = (JTree) dtc.getComponent(); setOriginalGlassPane(tree); (DefaultMutableTreeNode) getNodeForPath (getParentPathForPosition(currentPath)); Node dropTargetNode = getDomNodeFromTreeNode(parent); DefaultMutableTreeNode sibling = (DefaultMutableTreeNode) getNodeForPath(getSiblingPathForPosition(currentPath)); Node siblingNode = getDomNodeFromTreeNode(sibling); if (this.transferData != null) {
JTree tree = (JTree) dtc.getComponent(); setOriginalGlassPane(tree); (DefaultMutableTreeNode) getNodeForPath (getParentPathForPosition(currentPath)); Node dropTargetNode = getDomNodeFromTreeNode(parent); DefaultMutableTreeNode sibling = (DefaultMutableTreeNode) getNodeForPath(getSiblingPathForPosition(currentPath)); Node siblingNode = getDomNodeFromTreeNode(sibling); if (this.transferData != null) {
/** * Finds the TreePath that is going to be next sibling to the nodes that * are being dragged. * * @param currentPath * The current path (the items are dragged over this path) * @return sibling TreePath */ private TreePath getSiblingPathForPosition(TreePath currentPath) { TreePath parentPath = getParentPathForPosition(currentPath); TreePath nextSiblingPath = null; if (positionIndicator == AFTER) { TreeNode parentNode = getNodeForPath(parentPath); TreeNode currentNode = getNodeForPath(currentPath); if (parentPath != null && parentNode != null && currentNode != null) { int siblingIndex = parentNode.getIndex(currentNode) + 1; if (parentNode.getChildCount() > siblingIndex) { nextSiblingPath = parentPath.pathByAddingChild (parentNode.getChildAt(siblingIndex)); } } } else if (positionIndicator == BEFORE) { nextSiblingPath = currentPath; } else if (positionIndicator == CURRENT) { nextSiblingPath = null; } return nextSiblingPath; }
/** * Schedules the expand of the given treePath on a tree. * * @param treePath * The treePath to expand * @param tree * The JTree */ private void scheduleExpand(TreePath treePath, JTree tree) { // If the treepath to schedule for expand isn't already scheduled if (treePath != treePathToExpand) { getExpandTreeTimer(tree).stop(); treePathToExpand = treePath; getExpandTreeTimer(tree).start(); } }
/** * Creates the DOMDocumentTree. * * @param root * Root node * @param controller * The tree controller */ public DOMDocumentTree(TreeNode root, DOMDocumentTreeController controller) { super(root); this.controller = controller; new TreeDragSource(this, DnDConstants.ACTION_COPY_OR_MOVE); new DropTarget(this, new TreeDropTargetListener(this)); }
/** * Creates the DOMDocumentTree. * * @param root * Root node * @param controller * The tree controller */ public DOMDocumentTree(TreeNode root, DOMDocumentTreeController controller) { super(root); this.controller = controller; new TreeDragSource(this, DnDConstants.ACTION_COPY_OR_MOVE); new DropTarget(this, new TreeDropTargetListener(this)); }
public void dragExit(DropTargetEvent dte) { setOriginalGlassPane ((JTree) dte.getDropTargetContext().getComponent()); // Set the current dragover path dragOverTreePath = null; }
/** * Constructor. */ public TreeDropTargetListener(DOMDocumentTree tree) { addOnAutoscrollListener(tree); }
public void dragExit(DropTargetEvent dte) { setOriginalGlassPane ((JTree) dte.getDropTargetContext().getComponent()); // Set the current dragover path dragOverTreePath = null; }
/** * Constructor. */ public TreeDropTargetListener(DOMDocumentTree tree) { addOnAutoscrollListener(tree); }