Class TreeDragAndDropWidget


  • public class TreeDragAndDropWidget
    extends RadianceThemingWidget<javax.swing.JTree>
    TreeWrapper is used to handle drag and drop and popup menus in any JTree.
    • Field Detail

      • EMPTY_CLASS_ARRAY

        private static java.lang.Class[] EMPTY_CLASS_ARRAY
        This to avoid excesive creation of objects in invocation.
      • getTransferableMethod

        private static java.lang.reflect.Method getTransferableMethod
        This to avoid excessive reflection to find the "getTransferable" method.
      • EMPTY_OBJECT_ARRAY

        private static java.lang.Object[] EMPTY_OBJECT_ARRAY
        This to avoid excesive creation of objects in invocation.
      • dragSource

        private java.awt.dnd.DragSource dragSource
      • dropTarget

        private java.awt.dnd.DropTarget dropTarget
      • dropNode

        private javax.swing.tree.MutableTreeNode dropNode
      • listeners

        private javax.swing.event.EventListenerList listeners
      • propertyChangeListener

        private java.beans.PropertyChangeListener propertyChangeListener
      • cellRendererChangeListener

        private java.beans.PropertyChangeListener cellRendererChangeListener
      • dragGestureRecognizer

        private java.awt.dnd.DragGestureRecognizer dragGestureRecognizer
    • Constructor Detail

      • TreeDragAndDropWidget

        public TreeDragAndDropWidget()
    • Method Detail

      • installDnDSupport

        private void installDnDSupport()
      • uninstallDnDSupport

        private void uninstallDnDSupport()
      • mayDropHere

        private boolean mayDropHere​(java.lang.String aSourceString,
                                    javax.swing.JTree aTargetTree,
                                    javax.swing.tree.TreePath aPath)
        Invoked to decide if a given String can be dropped in the last path component of the given path.
        Parameters:
        aSourceString - the String being dragged.
        aPath - the path to drop into.
        Returns:
        true to allow the drop operation, false otherwise.
      • mayDropHere

        private boolean mayDropHere​(java.lang.String aSourceString,
                                    javax.swing.JTree aTargetTree,
                                    javax.swing.tree.TreeNode aNode)
        Invoked to decide if a given String can be dropped in the last path component of the given path.
        Parameters:
        aSourceString - the String being dragged.
        aTargetTree - the tree to drop into.
        aNode - the node to drop into.
        Returns:
        true to allow the drop operation, false otherwise.
      • mayDropHere

        private boolean mayDropHere​(javax.swing.JTree aSourceTree,
                                    javax.swing.tree.MutableTreeNode aSourceNode,
                                    javax.swing.tree.TreePath aPath)
        Invoked to decide if draggedNode can be dropped in the last path component of the given path.
        Parameters:
        aSourceTree - the source tree.
        aSourceNode - the source node.
        aPath - the path to drop into.
        Returns:
        true to allow the drop operation, false otherwise.
      • mayDropHere

        private boolean mayDropHere​(javax.swing.JTree aSourceTree,
                                    javax.swing.tree.MutableTreeNode aSourceNode,
                                    javax.swing.tree.TreeNode aNode)
        Invoked to decide if draggedNode can be dropped into aNode.
        Parameters:
        aSourceTree - the source tree.
        aSourceNode - the source node.
        aNode - the node to drop into.
        Returns:
        true to allow the drop operation, false to avoid it.
      • isAncestorOf

        private static boolean isAncestorOf​(javax.swing.tree.TreeNode aPossibleParent,
                                            javax.swing.tree.TreeNode aNode)
        See if aPossibleParent is ancestor of aNode
      • resetDragAndDrop

        private void resetDragAndDrop()