use of java.awt.dnd.DropTargetContext in project jna by java-native-access.
the class DropHandler method describe.
private void describe(String type, DropTargetEvent e) {
if (false) {
String msg = "drop: " + type;
if (e instanceof DropTargetDragEvent) {
DropTargetContext dtc = e.getDropTargetContext();
DropTarget dt = dtc.getDropTarget();
DropTargetDragEvent ev = (DropTargetDragEvent) e;
msg += ": src=" + DragHandler.actionString(ev.getSourceActions()) + " tgt=" + DragHandler.actionString(dt.getDefaultActions()) + " act=" + DragHandler.actionString(ev.getDropAction());
} else if (e instanceof DropTargetDropEvent) {
DropTargetContext dtc = e.getDropTargetContext();
DropTarget dt = dtc.getDropTarget();
DropTargetDropEvent ev = (DropTargetDropEvent) e;
msg += ": src=" + DragHandler.actionString(ev.getSourceActions()) + " tgt=" + DragHandler.actionString(dt.getDefaultActions()) + " act=" + DragHandler.actionString(ev.getDropAction());
}
if (!msg.equals(lastAction)) {
System.out.println(lastAction = msg);
}
}
}
use of java.awt.dnd.DropTargetContext in project android by JetBrains.
the class LayoutTestUtilities method dragDrop.
public static void dragDrop(InteractionManager manager, int x1, int y1, int x2, int y2, Transferable transferable) {
Object listener = manager.getListener();
assertTrue(listener instanceof DropTargetListener);
DropTargetListener dropListener = (DropTargetListener) listener;
int frames = 5;
double x = x1;
double y = y1;
double xSlope = (x2 - x) / frames;
double ySlope = (y2 - y) / frames;
DropTargetContext context = createDropTargetContext();
dropListener.dragEnter(new DropTargetDragEventBuilder(context, (int) x, (int) y, transferable).build());
for (int i = 0; i < frames + 1; i++) {
dropListener.dragOver(new DropTargetDragEventBuilder(context, (int) x, (int) y, transferable).build());
x += xSlope;
y += ySlope;
}
DropTargetDropEvent dropEvent = new DropTargetDropEventBuilder(context, (int) x, (int) y, transferable).build();
dropListener.drop(dropEvent);
verify(dropEvent, times(1)).acceptDrop(anyInt());
verify(dropEvent, times(1)).dropComplete(true);
}
use of java.awt.dnd.DropTargetContext in project jdk8u_jdk by JetBrains.
the class SunDropTargetContextPeer method processMotionMessage.
/**
*
*/
protected void processMotionMessage(SunDropTargetEvent event, boolean operationChanged) {
Component c = (Component) event.getSource();
Point hots = event.getPoint();
int id = event.getID();
DropTarget dt = c.getDropTarget();
DropTargetContext dtc = null;
if (c.isShowing() && (dt != null) && dt.isActive()) {
if (currentDT != dt) {
if (currentDTC != null) {
currentDTC.removeNotify();
}
currentDT = dt;
currentDTC = null;
}
dtc = currentDT.getDropTargetContext();
if (dtc != currentDTC) {
if (currentDTC != null) {
currentDTC.removeNotify();
}
currentDTC = dtc;
currentDTC.addNotify(this);
}
currentA = currentDT.getDefaultActions();
try {
DropTargetDragEvent dtde = new DropTargetDragEvent(dtc, hots, currentDA, currentSA);
DropTargetListener dtl = (DropTargetListener) dt;
if (operationChanged) {
dtl.dropActionChanged(dtde);
} else {
dtl.dragOver(dtde);
}
if (dragRejected) {
currentDA = DnDConstants.ACTION_NONE;
}
} catch (Exception e) {
e.printStackTrace();
currentDA = DnDConstants.ACTION_NONE;
}
} else {
currentDA = DnDConstants.ACTION_NONE;
}
}
use of java.awt.dnd.DropTargetContext in project jdk8u_jdk by JetBrains.
the class SunDropTargetContextPeer method processDropMessage.
/**
*
*/
protected void processDropMessage(SunDropTargetEvent event) {
Component c = (Component) event.getSource();
Point hots = event.getPoint();
DropTarget dt = c.getDropTarget();
// drop pending ACK
dropStatus = STATUS_WAIT;
dropComplete = false;
if (c.isShowing() && dt != null && dt.isActive()) {
DropTargetContext dtc = dt.getDropTargetContext();
currentDT = dt;
if (currentDTC != null) {
currentDTC.removeNotify();
}
currentDTC = dtc;
currentDTC.addNotify(this);
currentA = dt.getDefaultActions();
synchronized (_globalLock) {
if ((local = getJVMLocalSourceTransferable()) != null)
setCurrentJVMLocalSourceTransferable(null);
}
dropInProcess = true;
try {
((DropTargetListener) dt).drop(new DropTargetDropEvent(dtc, hots, currentDA, currentSA, local != null));
} finally {
if (dropStatus == STATUS_WAIT) {
rejectDrop();
} else if (dropComplete == false) {
dropComplete(false);
}
dropInProcess = false;
}
} else {
rejectDrop();
}
}
use of java.awt.dnd.DropTargetContext in project jdk8u_jdk by JetBrains.
the class SunDropTargetContextPeer method processExitMessage.
/**
*
*/
protected void processExitMessage(SunDropTargetEvent event) {
Component c = (Component) event.getSource();
DropTarget dt = c.getDropTarget();
DropTargetContext dtc = null;
if (dt == null) {
currentDT = null;
currentT = null;
if (currentDTC != null) {
currentDTC.removeNotify();
}
currentDTC = null;
return;
}
if (dt != currentDT) {
if (currentDTC != null) {
currentDTC.removeNotify();
}
currentDT = dt;
currentDTC = dt.getDropTargetContext();
currentDTC.addNotify(this);
}
dtc = currentDTC;
if (dt.isActive())
try {
((DropTargetListener) dt).dragExit(new DropTargetEvent(dtc));
} catch (Exception e) {
e.printStackTrace();
} finally {
currentA = DnDConstants.ACTION_NONE;
currentSA = DnDConstants.ACTION_NONE;
currentDA = DnDConstants.ACTION_NONE;
currentDT = null;
currentT = null;
currentDTC.removeNotify();
currentDTC = null;
local = null;
dragRejected = false;
}
}
Aggregations