Drag and drop from tree view

Someone have a example to do a drag and drop a item from tree view to power table? I need to do the same of Tag Browse Tree

My solution
The in source component you must create the following function.

def addDrag(self):
    """
	Arguments:
		self: A reference to the component instance this method is invoked on. This argument
		  is automatic and should not be specified when invoking this method.
	"""
	from java.awt.dnd import DragSource,DragGestureListener
	from java.awt.dnd import DragSourceListener 
	from java.awt.dnd import DnDConstants
	from java.awt.datatransfer import Transferable
	from java.awt.datatransfer import StringSelection
		
		
	class MyDragGestureListener(DragGestureListener):
		def  __init__(self,table):
			DragGestureListener.__init__(self)
			
		def dragGestureRecognized(self,DragGestureEvent): 
		 	transferable = StringSelection("");
			myDragDrop.startDrag(DragGestureEvent, DragSource.DefaultCopyDrop, transferable, myDragSourceListener)
	
	class MyDragSourceListener(DragSourceListener):
		def __init__(self,table):
				DragSourceListener.__init__(self)
		
	class MyDragDrop(DragSource): 
		def __init__(self,table):
			DragSource.__init__(self)
			self.table = table
			
	myDragGestureListener = MyDragGestureListener(self)
	myDragSourceListener = MyDragSourceListener(self)
	myDragDrop =  MyDragDrop(self)
	myDragDrop.createDefaultDragGestureRecognizer(self,DnDConstants.ACTION_COPY_OR_MOVE, myDragGestureListener)
	

If your component have a extension function “initialize” put there “event.source.addDrag()”. but it’s not present you can put in the eventHandrles MousePressed.

In the destination component you have write this code:

def addListener(self):
	"""
	Arguments:
		self: A reference to the component instance this method is invoked on. This argument
		  is automatic and should not be specified when invoking this method.
	"""
	from java.awt.dnd import DropTargetListener, DropTarget
	from com.inductiveautomation.factorypmi.application.components.chart.easychart import ClientNodeListTransferable

	class MyDragDropListener(DropTargetListener):
		def __init__(self, table):
			DropTargetListener.__init__(self)
			self.table = table
			
		def drop(self, e):
			e.acceptDrop(e.getDropAction())			
			print "dropped"

	
	myDragDropListener = MyDragDropListener(self)
	DropTarget(self, myDragDropListener)

In function drop you put the code what do with the information arrive from dop.
If your component have a extension function “initialize” put there “event.source.addListener()”. but it’s not present you can put in the eventHandrles MouseEntered.

this is the solution do for my request

I feel like some basic details are missing from this solution. What else does one need to do to get this to work for, say dragging a selected node string from a tree view to a text field?

In the function “drop”, in your case in the text field, you must write what you want to do with the data you receive.
For example: if you want to take the property “path” from the node you should say:

self.text= [the property path]

I’m sorry I don’t put a working code but I’m not with my computer at hand.
Tomorrow I will try to write a clearer example.