use of java.awt.dnd.DropTarget 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.DropTarget 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.DropTarget in project jdk8u_jdk by JetBrains.
the class CDropTargetContextPeer method processEnterMessage.
/**
* Could be called when DnD enters a heavyweight or synthesized in processMotionMessage
*/
@Override
protected void processEnterMessage(SunDropTargetEvent event) {
Component c = event.getComponent();
DropTarget dt = event.getComponent().getDropTarget();
if (isEventInsideTarget(event) && dt != insideTarget && c.isShowing() && dt != null && dt.isActive()) {
insideTarget = dt;
super.processEnterMessage(event);
}
}
use of java.awt.dnd.DropTarget in project GCViewer by chewiebug.
the class GCModelLoaderControllerImpl method openGCResource.
private void openGCResource(GCResource gcResource, GCModelLoader loader) {
GCDocument document = new GCDocument(gcViewerGui.getPreferences(), gcResource.getResourceName());
document.setDropTarget(new DropTarget(document, DnDConstants.ACTION_COPY, new FileDropTargetListener(this, DropFlavor.ADD)));
document.addInternalFrameListener(new GCViewerGuiInternalFrameController());
gcViewerGui.addDocument(document);
GCDocumentController docController = new GCDocumentController(document);
docController.addGCResource(loader, getViewMenuController());
loader.execute();
}
use of java.awt.dnd.DropTarget in project GCViewer by chewiebug.
the class TestGCModelLoaderController method dropOnDesktopPane.
/**
* Test drag and drop action on GCViewerGui.
*/
@Test
public void dropOnDesktopPane() throws Exception {
// TODO SWINGWORKER: test drag and drop on GCDocument
assertThat("number of gcdocuments before", controller.getGCViewerGui().getDesktopPane().getAllFrames().length, is(0));
List<File> fileList = new ArrayList<File>();
fileList.add(new File(UnittestHelper.getResource(UnittestHelper.FOLDER_OPENJDK, "SampleSun1_6_0G1_MarkStackFull.txt").getPath()));
Transferable tr = Mockito.mock(Transferable.class);
Mockito.when(tr.getTransferData(DataFlavor.javaFileListFlavor)).thenReturn(fileList);
DropTargetDropEvent dte = Mockito.mock(DropTargetDropEvent.class);
Mockito.when(dte.isDataFlavorSupported(DataFlavor.javaFileListFlavor)).thenReturn(true);
Mockito.when(dte.getTransferable()).thenReturn(tr);
DropTarget target = controller.getGCViewerGui().getDesktopPane().getDropTarget();
target.drop(dte);
assertThat("number of gcdocuments after drop", controller.getGCViewerGui().getDesktopPane().getAllFrames().length, is(1));
}
Aggregations