# Drag and drop from tag browse tree to power table

**URL:** <https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260>\
**Category:** Ignition\
**Created:** [September 6, 2017, 12:50pm UTC](https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260 "2017-09-06T12:50:49Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mmacerl](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmacerl/32/4024_2.png) [@Mmacerl](https://forum.inductiveautomation.com/u/Mmacerl)\
**Post date:** [September 6, 2017, 12:50pm UTC](https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260/1 "2017-09-06T12:50:49Z")

</div>

I would like to add a support to drag and drop a tag from tag browse tree to the power table. When I would do the mentioned the path of the tag dragged would store to the table (in dropped column). Have anyone done something similar already? Thank you for your help.

---

<div class="post-metadata">

**Author:** ![Kleppe85](https://avatars.discourse-cdn.com/v4/letter/k/c4cdca/32.png) [@Kleppe85](https://forum.inductiveautomation.com/u/Kleppe85)\
**Post date:** [January 12, 2018, 2:30pm UTC](https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260/2 "2018-01-12T14:30:26Z")

</div>

Bumping this thread, would be great if someone could give an example 🙂

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [January 12, 2018, 4:12pm UTC](https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260/3 "2018-01-12T16:12:53Z")

</div>

Here’s a sample window I came up with a while back. Note that is pretty low-level Java Swing stuff - so you’re on your own merits to figure out how it all works. Also, don’t even try and call into support about this.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/d/db84dda2cb9329ba9e25f7b6b3f38b94ae9a0812.png)  
[Power Table Tags Dropped.proj](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/70c831f665ee8ad4a4167c49a595750bf5859a8b.proj) (19.9 KB)

For a _brief_ explanation: The `initialize()` function of the power table fires the `addListener()` custom method, which creates an instance of a custom [`DropTargetListener`](https://docs.oracle.com/javase/7/docs/api/java/awt/dnd/DropTargetListener.html). That custom `DropTargetListener` has an overridden `drop()` function, which actually handles the incoming data.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [January 12, 2018, 10:45pm UTC](https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260/4 "2018-01-12T22:45:39Z")

</div>

You could also just do a Power Table in place of the Tag Browse tree and enable drag and drop between the tables.  
Just query against the sqlth\_te table for records with RETIRED IS NULL

---

<div class="post-metadata">

**Author:** ![j.abrante](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/j.abrante/32/10431_2.png) [@j.abrante](https://forum.inductiveautomation.com/u/j.abrante)\
**Post date:** [August 21, 2019, 8:11pm UTC](https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260/5 "2019-08-21T20:11:33Z")

</div>

is possible to do the same but from tree view?

---

<div class="post-metadata">

**Author:** ![j.abrante](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/j.abrante/32/10431_2.png) [@j.abrante](https://forum.inductiveautomation.com/u/j.abrante)\
**Post date:** [September 10, 2019, 12:38pm UTC](https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260/6 "2019-09-10T12:38:48Z")

</div>

my solution is:  
The in source component you must create the following function.

```auto
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:

```auto
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

---

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [September 12, 2019, 9:42am UTC](https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260/7 "2019-09-12T09:42:34Z")

</div>

> [@j.abrante](#):
>
> ClientNodeListTransferable

Becarefull, in Ignition 8.0 : **ClientNodeListTransferable** doesn't exist anymore.

[http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.0-beta/index.html](http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.0-beta/index.html)

---

<div class="post-metadata">

**Author:** ![j.abrante](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/j.abrante/32/10431_2.png) [@j.abrante](https://forum.inductiveautomation.com/u/j.abrante)\
**Post date:** [September 13, 2019, 1:07pm UTC](https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260/8 "2019-09-13T13:07:54Z")

</div>

> [@mazeyrat](#):
>
> ClientNodeListTransferable

ok thanks, i must to check and other solution in 8.0

---

<div class="post-metadata">

**Author:** ![agavino](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@agavino](https://forum.inductiveautomation.com/u/agavino)\
**Post date:** [May 5, 2021, 11:34am UTC](https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260/9 "2021-05-05T11:34:24Z")

</div>

Hi J.abrante

Could you find another solution?

Thank.

---

<div class="post-metadata">

**Author:** ![j.abrante](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/j.abrante/32/10431_2.png) [@j.abrante](https://forum.inductiveautomation.com/u/j.abrante)\
**Post date:** [May 5, 2021, 12:09pm UTC](https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260/10 "2021-05-05T12:09:51Z")

</div>

Not right now. But during the summer I have to make the conversion from 7.9 to 8.1 so I will have to solve this problem for sure. Let’s stay in touch, the first one who finds the solution publishes it. What do you say?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [May 5, 2021, 12:25pm UTC](https://forum.inductiveautomation.com/t/drag-and-drop-from-tag-browse-tree-to-power-table/15260/11 "2021-05-05T12:25:24Z")

</div>

You may be able to use this as a starter

> [@Drag and drop to list component](http://forum.inductiveautomation.com/t/drag-and-drop-to-list-component/44077/16):
>
> Perhaps you were correct? This turned out to be a bit simpler than I was originally thinking. Not trivial, but not really painful either. Add an extension function to your list component, I called mine addDropListener. Then in the script add the following script: from java.awt.dnd import DropTargetAdapter, DropTarget from com.inductiveautomation.ignition.client.tags.dnd import ListOfQualifiedPath class customDragDropListener(DropTargetAdapter): \_comp = None def \_\_init\_\_(self,comp): D…
