/** * upcall from native code via implemented class (do) */ protected final void dragDropFinished(final boolean success, final int operations, final int x, final int y) { DragSourceEvent event = new DragSourceDropEvent(getDragSourceContext(), operations & sourceActions, success, x, y); EventDispatcher dispatcher = new EventDispatcher(DISPATCH_FINISH, event); SunToolkit.invokeLaterOnAppContext( SunToolkit.targetToAppContext(getComponent()), dispatcher); startSecondaryEventLoop(); setNativeContext(0); dragImage = null; dragImageOffset = null; }
EventDispatcher(int dispatchType, DragSourceEvent event) { switch (dispatchType) { case DISPATCH_ENTER: case DISPATCH_MOTION: case DISPATCH_CHANGED: case DISPATCH_MOUSE_MOVED: if (!(event instanceof DragSourceDragEvent)) { throw new IllegalArgumentException("Event: " + event); } break; case DISPATCH_EXIT: break; case DISPATCH_FINISH: if (!(event instanceof DragSourceDropEvent)) { throw new IllegalArgumentException("Event: " + event); } break; default: throw new IllegalArgumentException("Dispatch type: " + dispatchType); } this.dispatchType = dispatchType; this.event = event; }
public void run() { switch (type) { case DRAG_ENTER: context.dragEnter(newDragSourceDragEvent()); break; case DRAG_OVER: context.dragOver(newDragSourceDragEvent()); break; case DRAG_ACTION_CHANGED: context.dropActionChanged(newDragSourceDragEvent()); break; case DRAG_MOUSE_MOVED: context.dragMouseMoved(newDragSourceDragEvent()); break; case DRAG_EXIT: context.dragExit(new DragSourceEvent(context, x, y)); break; case DRAG_DROP_END: context.dragExit(new DragSourceDropEvent( context, userAction, success, x, y)); break; } }
/** * upcall from native code */ protected final void dragExit(final int x, final int y) { DragSourceEvent event = new DragSourceEvent(getDragSourceContext(), x, y); EventDispatcher dispatcher = new EventDispatcher(DISPATCH_EXIT, event); SunToolkit.invokeLaterOnAppContext( SunToolkit.targetToAppContext(getComponent()), dispatcher); startSecondaryEventLoop(); }