psdi.webclient.applet.wfcanvas.diagram.dnd

Class DnDHandler

  • java.lang.Object
    • psdi.webclient.applet.wfcanvas.diagram.dnd.DnDHandler
  • All Implemented Interfaces:
    java.awt.dnd.peer.DragSourceContextPeer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener


    public class DnDHandler
    extends java.lang.Object
    implements java.awt.dnd.peer.DragSourceContextPeer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
    This class is written to substitue for the native system drag and drop handler. The native version doesn't work within the Java plugin. This version add a listener to the component starting the drag and then generates the correct drag and drop events for the the listeners. The class is created in the class WorkflowDragSource which is a subclass of DragSource with a new startDrag call which creates this a the peer for the DragSourceContext
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      protected java.util.Hashtable actionTable 
      protected java.awt.Component comp 
      protected java.util.Hashtable contextTable 
      protected java.awt.Cursor cursor 
      protected java.awt.dnd.DropTargetContext dropContext 
      protected java.awt.dnd.DragSourceContext dsc 
      protected java.awt.Cursor oldCursor 
      protected java.awt.Component over 
      protected java.awt.Component root 
    • Constructor Summary

      Constructors 
      Constructor and Description
      DnDHandler(java.awt.dnd.DragGestureEvent trigger)
      Constructs a DnDHandler using the drag gesture trigger
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      static java.awt.dnd.DragSource createDragSource()
      This creates the appropriate drag source.
      static java.awt.dnd.DropTarget createDropTarget(java.awt.Component c, java.awt.dnd.DropTargetListener dtl)
      This creates the appropriate drop target.
      java.awt.Cursor getCursor()
      Returns the current cursor
      protected int getDropAction(java.awt.event.MouseEvent e)
      Returns the correct drop action based on the event
      protected java.awt.Component getDropTarget(java.awt.event.MouseEvent e)
      Gets the drop target component from the mouse event
      void mouseClicked(java.awt.event.MouseEvent e)
      Called when the mouse has been pressed and released
      void mouseDragged(java.awt.event.MouseEvent e)
      Called when the mouse is being dragged
      void mouseEntered(java.awt.event.MouseEvent e)
      Called when the mouse has entered the component
      void mouseExited(java.awt.event.MouseEvent e)
      Called when the mouse leaves the component
      void mouseMoved(java.awt.event.MouseEvent e)
      Called when the mouse has moved
      void mousePressed(java.awt.event.MouseEvent e)
      Called when the mouse is pressed.
      void mouseReleased(java.awt.event.MouseEvent e)
      Called when the mouse is released.
      void setCursor(java.awt.Cursor cursor)
      Sets the current cursor
      void startDrag(java.awt.dnd.DragSourceContext dsc, java.awt.Cursor cursor, java.awt.Image dragImage, java.awt.Point imageOffset)
      Starts the drag operation for a drag context
      void transferablesFlavorsChanged()
      Called if the transferable data flavors change
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • cursor

        protected java.awt.Cursor cursor
      • oldCursor

        protected java.awt.Cursor oldCursor
      • dsc

        protected java.awt.dnd.DragSourceContext dsc
      • comp

        protected java.awt.Component comp
      • over

        protected java.awt.Component over
      • actionTable

        protected java.util.Hashtable actionTable
      • contextTable

        protected java.util.Hashtable contextTable
      • root

        protected java.awt.Component root
      • dropContext

        protected java.awt.dnd.DropTargetContext dropContext
    • Constructor Detail

      • DnDHandler

        public DnDHandler(java.awt.dnd.DragGestureEvent trigger)
        Constructs a DnDHandler using the drag gesture trigger
        Parameters:
        trigger - The DragGestureEvent
    • Method Detail

      • startDrag

        public void startDrag(java.awt.dnd.DragSourceContext dsc,
                              java.awt.Cursor cursor,
                              java.awt.Image dragImage,
                              java.awt.Point imageOffset)
                       throws java.awt.dnd.InvalidDnDOperationException
        Starts the drag operation for a drag context
        Specified by:
        startDrag in interface java.awt.dnd.peer.DragSourceContextPeer
        Parameters:
        dsc - The DragSourceContext
        cursor - The initial cursor
        dragImage - The image to be show during dragging
        imageOffset - The offset of the image from the cursor
        Throws:
        java.awt.dnd.InvalidDnDOperationException
      • getCursor

        public java.awt.Cursor getCursor()
        Returns the current cursor
        Specified by:
        getCursor in interface java.awt.dnd.peer.DragSourceContextPeer
        Returns:
        The cursor
      • setCursor

        public void setCursor(java.awt.Cursor cursor)
                       throws java.awt.dnd.InvalidDnDOperationException
        Sets the current cursor
        Specified by:
        setCursor in interface java.awt.dnd.peer.DragSourceContextPeer
        Parameters:
        cursor - The current cursor
        Throws:
        java.awt.dnd.InvalidDnDOperationException
      • transferablesFlavorsChanged

        public void transferablesFlavorsChanged()
        Called if the transferable data flavors change
        Specified by:
        transferablesFlavorsChanged in interface java.awt.dnd.peer.DragSourceContextPeer
      • getDropTarget

        protected java.awt.Component getDropTarget(java.awt.event.MouseEvent e)
        Gets the drop target component from the mouse event
        Parameters:
        e - The mouse event
        Returns:
        The component the mouse is over
      • getDropAction

        protected int getDropAction(java.awt.event.MouseEvent e)
        Returns the correct drop action based on the event
        Parameters:
        e - The mouse event
        Returns:
        The drop action
      • mouseClicked

        public void mouseClicked(java.awt.event.MouseEvent e)
        Called when the mouse has been pressed and released
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
        Parameters:
        e - The mouse event
      • mouseEntered

        public void mouseEntered(java.awt.event.MouseEvent e)
        Called when the mouse has entered the component
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
        Parameters:
        e - The mouse event
      • mouseExited

        public void mouseExited(java.awt.event.MouseEvent e)
        Called when the mouse leaves the component
        Specified by:
        mouseExited in interface java.awt.event.MouseListener
        Parameters:
        e - The mouse event
      • mousePressed

        public void mousePressed(java.awt.event.MouseEvent e)
        Called when the mouse is pressed.
        Specified by:
        mousePressed in interface java.awt.event.MouseListener
        Parameters:
        e - The mouse event
      • mouseReleased

        public void mouseReleased(java.awt.event.MouseEvent e)
        Called when the mouse is released.
        Specified by:
        mouseReleased in interface java.awt.event.MouseListener
        Parameters:
        e - The mouse event
      • mouseDragged

        public void mouseDragged(java.awt.event.MouseEvent e)
        Called when the mouse is being dragged
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
        Parameters:
        e - The mouse event
      • mouseMoved

        public void mouseMoved(java.awt.event.MouseEvent e)
        Called when the mouse has moved
        Specified by:
        mouseMoved in interface java.awt.event.MouseMotionListener
        Parameters:
        e - The mouse event
      • createDragSource

        public static java.awt.dnd.DragSource createDragSource()
        This creates the appropriate drag source. If the native DnD works ok then it is a standard DragSource otherwise it is our own version
      • createDropTarget

        public static java.awt.dnd.DropTarget createDropTarget(java.awt.Component c,
                                                               java.awt.dnd.DropTargetListener dtl)
        This creates the appropriate drop target. If the native DnD works ok then it is a standard DropTarget otherwise it is our own version
        Parameters:
        c - the component which is the drop target
        dtl - The drop raget listener