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.
Bumping this thread, would be great if someone could give an example
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.
Power Table Tags Dropped.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
. That custom DropTargetListener
has an overridden drop()
function, which actually handles the incoming data.
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
is possible to do the same but from tree view?
my solution is:
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
Becarefull, in Ignition 8.0 : ClientNodeListTransferable doesn't exist anymore.
http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.0-beta/index.html
ok thanks, i must to check and other solution in 8.0
Hi J.abrante
Could you find another solution?
Thank.
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?
You may be able to use this as a starter