Hi, I am trying to drag and drop from tree view to list
example image
Script i am using in tree view in mouse pressed
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
def addDrag(self):
class MyDragGestureListener(DragGestureListener):
def __init__(self,selectedPath):
DragGestureListener.__init__(self)
def dragGestureRecognized(self,DragGestureEvent):
transferable = StringSelection("");
myDragDrop.startDrag(DragGestureEvent, DragSource.DefaultCopyDrop, transferable, myDragSourceListener)
class MyDragSourceListener(DragSourceListener):
def __init__(self,selectedPath):
DragSourceListener.__init__(self)
class MyDragDrop(DragSource):
def __init__(self,selectedPath):
DragSource.__init__(self)
self.selectedPath = selectedPath
myDragGestureListener = MyDragGestureListener(event.source)
myDragSourceListener = MyDragSourceListener(event.source)
myDragDrop = MyDragDrop(event.source)
myDragDrop.createDefaultDragGestureRecognizer(event.source,DnDConstants.ACTION_COPY_OR_MOVE, myDragGestureListener)
example screen shot
when i drag i am getting this error
Exception in thread "AWT-EventQueue-0" java.awt.dnd.InvalidDnDOperationException: Drag and drop in progress
at java.desktop/sun.awt.dnd.SunDragSourceContextPeer.setDragDropInProgress(Unknown Source)
at java.desktop/java.awt.dnd.DragSource.startDrag(Unknown Source)
at java.desktop/java.awt.dnd.DragSource.startDrag(Unknown Source)
at java.base/jdk.internal.reflect.GeneratedMethodAccessor256.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java:190)
at org.python.core.PyObject.__call__(PyObject.java:422)
at org.python.core.PyMethod.__call__(PyMethod.java:187)
at org.python.pycode._pyx136.dragGestureRecognized$3(<event:mousePressed>:14)
at org.python.pycode._pyx136.call_function(<event:mousePressed>)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyBaseCode.call(PyBaseCode.java:306)
at org.python.core.PyBaseCode.call(PyBaseCode.java:197)
at org.python.core.PyFunction.__call__(PyFunction.java:485)
at org.python.core.PyMethod.instancemethod___call__(PyMethod.java:237)
at org.python.core.PyMethod.__call__(PyMethod.java:228)
at org.python.core.PyMethod.__call__(PyMethod.java:218)
at org.python.core.PyMethod.__call__(PyMethod.java:213)
at org.python.core.PyObject._jcallexc(PyObject.java:3565)
at org.python.core.PyObject._jcall(PyObject.java:3598)
at org.python.proxies.__builtin__$MyDragGestureListener$58.dragGestureRecognized(Unknown Source)
at java.desktop/java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(Unknown Source)
at java.desktop/sun.awt.windows.WMouseDragGestureRecognizer.mouseDragged(Unknown Source)
at com.inductiveautomation.factorypmi.application.components.util.EventDelegateDispatcher$MouseEventDispatcher.mouseDragged(EventDelegateDispatcher.java:145)
at java.desktop/java.awt.AWTEventMulticaster.mouseDragged(Unknown Source)
at java.desktop/java.awt.AWTEventMulticaster.mouseDragged(Unknown Source)
at java.desktop/java.awt.Component.processMouseMotionEvent(Unknown Source)
at java.desktop/javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Container.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-0" NotImplementedError: 'MyDragSourceListener' object does not implement abstract method 'dragEnter' from 'java.awt.dnd.DragSourceListener'
Exception in thread "AWT-EventQueue-0" NotImplementedError: 'MyDragSourceListener' object does not implement abstract method 'dragOver' from 'java.awt.dnd.DragSourceListener'
Exception in thread "AWT-EventQueue-0" NotImplementedError: 'MyDragSourceListener' object does not implement abstract method 'dragOver' from 'java.awt.dnd.DragSourceListener'
Exception in thread "AWT-EventQueue-0" NotImplementedError: 'MyDragSourceListener' object does not implement abstract method 'dragOver' from 'java.awt.dnd.DragSourceListener'
Exception in thread "AWT-EventQueue-0" NotImplementedError: 'MyDragSourceListener' object does not implement abstract method 'dragDropEnd' from 'java.awt.dnd.DragSourceListener'
can anyone please correct my script please