< prev index next >

modules/javafx.swing/src/main/java/javafx/embed/swing/FXDnD.java

Print this page

        

*** 42,53 **** import java.awt.dnd.DropTargetDragEvent; import java.awt.dnd.DropTargetDropEvent; import java.awt.dnd.DropTargetListener; import java.awt.dnd.InvalidDnDOperationException; import java.awt.dnd.MouseDragGestureRecognizer; - import java.awt.dnd.peer.DragSourceContextPeer; - import java.awt.dnd.peer.DropTargetContextPeer; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.HashMap; import java.util.Map; import javafx.application.Platform; --- 42,51 ----
*** 56,69 **** import javafx.scene.input.DataFormat; import javafx.scene.input.DragEvent; import javafx.scene.input.Dragboard; import javafx.scene.input.MouseEvent; import javafx.scene.input.TransferMode; - import sun.awt.AWTAccessor; - import sun.awt.dnd.SunDragSourceContextPeer; - import sun.swing.JLightweightFrame; /** * A utility class to connect DnD mechanism of Swing and FX. * It allows Swing content to use the FX machinery for performing DnD. */ --- 54,68 ---- import javafx.scene.input.DataFormat; import javafx.scene.input.DragEvent; import javafx.scene.input.Dragboard; import javafx.scene.input.MouseEvent; import javafx.scene.input.TransferMode; + import jdk.swing.interop.LightweightFrameWrapper; + import jdk.swing.interop.SwingInterOpUtils; + import jdk.swing.interop.DragSourceContextWrapper; + import jdk.swing.interop.DropTargetContextWrapper; /** * A utility class to connect DnD mechanism of Swing and FX. * It allows Swing content to use the FX machinery for performing DnD. */
*** 97,109 **** private ComponentMapper(Map<Component, T> map, int xArg, int yArg) { this.x = xArg; this.y = yArg; ! final JLightweightFrame lwFrame = node.getLightweightFrame(); ! Component c = AWTAccessor.getContainerAccessor().findComponentAt( ! lwFrame, x, y, false); if (c == null) return; synchronized (c.getTreeLock()) { do { object = map.get(c); --- 96,107 ---- private ComponentMapper(Map<Component, T> map, int xArg, int yArg) { this.x = xArg; this.y = yArg; ! final LightweightFrameWrapper lwFrame = node.getLightweightFrame(); ! Component c = lwFrame.findComponentAt(lwFrame, x, y, false); if (c == null) return; synchronized (c.getTreeLock()) { do { object = map.get(c);
*** 112,122 **** if (object != null) { // The object is either a DropTarget or a DragSource, so: //assert c == object.getComponent(); // Translate x, y from lwFrame to component coordinates ! while (c != lwFrame && c != null) { x -= c.getX(); y -= c.getY(); c = c.getParent(); } } --- 110,120 ---- if (object != null) { // The object is either a DropTarget or a DragSource, so: //assert c == object.getComponent(); // Translate x, y from lwFrame to component coordinates ! while ((lwFrame.isCompEqual(c,lwFrame)) && c != null) { x -= c.getX(); y -= c.getY(); c = c.getParent(); } }
*** 195,205 **** appendEvent(new java.awt.event.MouseEvent(getComponent(), java.awt.event.MouseEvent.MOUSE_PRESSED, evTime, modifiers, x, y, 0, false)); // Also, the modifiers here should've actually come from the last known mouse event (last MOVE or DRAG). // But we're OK with using the initial PRESS modifiers for now ! int initialAction = SunDragSourceContextPeer.convertModifiersToDropAction( modifiers, getSourceActions()); fireDragGestureRecognized(initialAction, new java.awt.Point(x, y)); } } --- 193,203 ---- appendEvent(new java.awt.event.MouseEvent(getComponent(), java.awt.event.MouseEvent.MOUSE_PRESSED, evTime, modifiers, x, y, 0, false)); // Also, the modifiers here should've actually come from the last known mouse event (last MOVE or DRAG). // But we're OK with using the initial PRESS modifiers for now ! int initialAction = DragSourceContextWrapper.convertModifiersToDropAction( modifiers, getSourceActions()); fireDragGestureRecognized(initialAction, new java.awt.Point(x, y)); } }
*** 279,289 **** (int)event.getX(), (int)event.getY()); } }; ! private final class FXDragSourceContextPeer extends SunDragSourceContextPeer { private volatile int sourceActions = 0; private final CachingTransferable transferable = new CachingTransferable(); @Override public void startSecondaryEventLoop(){ --- 277,287 ---- (int)event.getX(), (int)event.getY()); } }; ! private final class FXDragSourceContextPeer extends DragSourceContextWrapper { private volatile int sourceActions = 0; private final CachingTransferable transferable = new CachingTransferable(); @Override public void startSecondaryEventLoop(){
*** 335,353 **** } } } }; public <T extends DragGestureRecognizer> T createDragGestureRecognizer( Class<T> abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl) { return (T) new FXDragGestureRecognizer(ds, c, srcActions, dgl); } ! public DragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException { return new FXDragSourceContextPeer(dge); } --- 333,353 ---- } } } }; + //@Override public <T extends DragGestureRecognizer> T createDragGestureRecognizer( Class<T> abstractRecognizerClass, DragSource ds, Component c, int srcActions, DragGestureListener dgl) { return (T) new FXDragGestureRecognizer(ds, c, srcActions, dgl); } ! //@Override ! public DragSourceContextWrapper createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException { return new FXDragSourceContextPeer(dge); }
*** 416,426 **** } activeDTContextPeer = null; }; ! private final class FXDropTargetContextPeer implements DropTargetContextPeer { private int targetActions = DnDConstants.ACTION_NONE; private int currentAction = DnDConstants.ACTION_NONE; private DropTarget dt = null; private DropTargetContext ctx = null; --- 416,426 ---- } activeDTContextPeer = null; }; ! private final class FXDropTargetContextPeer extends DropTargetContextWrapper { private int targetActions = DnDConstants.ACTION_NONE; private int currentAction = DnDConstants.ACTION_NONE; private DropTarget dt = null; private DropTargetContext ctx = null;
*** 467,488 **** DropTarget target = mapper.object != null ? mapper.object : dt; SwingFXUtils.runOnEDTAndWait(FXDnD.this, () -> { if (target != dt) { if (ctx != null) { ! AWTAccessor.getDropTargetContextAccessor().reset(ctx); } ctx = null; currentAction = dropAction = DnDConstants.ACTION_NONE; } if (target != null) { if (ctx == null) { ctx = target.getDropTargetContext(); ! AWTAccessor.getDropTargetContextAccessor() ! .setDropTargetContextPeer(ctx, FXDropTargetContextPeer.this); } DropTargetListener dtl = (DropTargetListener)target; if (DragEvent.DRAG_DROPPED.equals(fxEvType)) { --- 467,488 ---- DropTarget target = mapper.object != null ? mapper.object : dt; SwingFXUtils.runOnEDTAndWait(FXDnD.this, () -> { if (target != dt) { if (ctx != null) { ! DropTargetContextWrapper.reset(ctx); } ctx = null; currentAction = dropAction = DnDConstants.ACTION_NONE; } if (target != null) { if (ctx == null) { ctx = target.getDropTargetContext(); ! DropTargetContextWrapper.setDropTargetContextPeer(ctx, ! new FXDropTargetContextPeer()); } DropTargetListener dtl = (DropTargetListener)target; if (DragEvent.DRAG_DROPPED.equals(fxEvType)) {
< prev index next >