List of usage examples for java.awt.dnd DropTargetDragEvent getLocation
public Point getLocation()
From source file:TreeDragTest.java
private TreeNode getNodeForEvent(DropTargetDragEvent dtde) { Point p = dtde.getLocation(); DropTargetContext dtc = dtde.getDropTargetContext(); JTree tree = (JTree) dtc.getComponent(); TreePath path = tree.getClosestPathForLocation(p.x, p.y); return (TreeNode) path.getLastPathComponent(); }
From source file:org.jas.dnd.MultiLayerDropTargetListener.java
@Override public void dragOver(DropTargetDragEvent dtde) { initializeTransferable(dtde.getTransferable(), false); getDragAction().setLocation(dtde.getLocation()); if (getDragAction().validate(dtde.getLocation())) { dtde.acceptDrag(DnDConstants.ACTION_COPY); } else {//from ww w . j a va2s .c o m dtde.rejectDrag(); } }
From source file:com.mirth.connect.client.ui.components.MirthTree.java
public void dragOver(DropTargetDragEvent dtde) { if (!dtde.isDataFlavorSupported(supportedDropFlavor)) { return;/*from ww w . j a v a 2 s .c om*/ } Point cursorLocationBis = dtde.getLocation(); TreePath destinationPath = getPathForLocation(cursorLocationBis.x, cursorLocationBis.y); if (destinationPath != null) { if (((MirthTreeNode) destinationPath.getLastPathComponent()).isLeaf()) { this.setSelectionPath(destinationPath); } } }
From source file:EditorDropTarget4.java
protected void dragUnderFeedback(DropTargetDragEvent dtde, boolean acceptedDrag) { if (draggingFile) { // When dragging a file, change the background color Color newColor = (dtde != null && acceptedDrag ? feedbackColor : backgroundColor); if (newColor.equals(pane.getBackground()) == false) { changingBackground = true;/*w ww . j a va2 s. c o m*/ pane.setBackground(newColor); changingBackground = false; pane.repaint(); } } else { if (dtde != null && acceptedDrag) { // Dragging text - move the insertion cursor Point location = dtde.getLocation(); pane.getCaret().setVisible(true); pane.setCaretPosition(pane.viewToModel(location)); } else { pane.getCaret().setVisible(false); } } }
From source file:com.qspin.qtaste.ui.TestCaseTree.java
public void dragOver(DropTargetDragEvent dtde) { ////from w w w. ja va 2s . com Point dropPoint = dtde.getLocation(); // int index = locationToIndex (dropPoint); TreePath path = getPathForLocation(dropPoint.x, dropPoint.y); if (path == null) { return; } Object targetNode = path.getLastPathComponent(); if (targetNode instanceof TCTreeNode) { TCTreeNode tcTreeNode = (TCTreeNode) targetNode; if (tcTreeNode.getUserObject() instanceof FileNode) { FileNode fn = (FileNode) tcTreeNode.getUserObject(); if (fn.isTestcaseDir()) { return; } } } }
From source file:com.igormaznitsa.sciareto.ui.editors.MMDEditor.java
protected boolean acceptOrRejectDragging(@Nonnull final DropTargetDragEvent dtde) { final int dropAction = dtde.getDropAction(); boolean result = false; if (this.dragAcceptableType && (dropAction & DnDConstants.ACTION_COPY_OR_MOVE) != 0 && this.mindMapPanel.findTopicUnderPoint(dtde.getLocation()) != null) { result = true;//from w w w. j a v a2 s .c o m } return result; }
From source file:DragDropTreeExample.java
protected void dragUnderFeedback(DropTargetDragEvent dtde, boolean acceptedDrag) { if (dtde != null && acceptedDrag) { Point location = dtde.getLocation(); if (isAcceptableDropLocation(location)) { tree.setSelectionRow(tree.getRowForLocation(location.x, location.y)); } else {//from w w w .ja v a 2s. c o m tree.clearSelection(); } } else { tree.clearSelection(); } }
From source file:FileTreeDropTarget.java
protected boolean acceptOrRejectDrag(DropTargetDragEvent dtde) { int dropAction = dtde.getDropAction(); int sourceActions = dtde.getSourceActions(); boolean acceptedDrag = false; DnDUtils.debugPrintln("\tSource actions are " + DnDUtils.showActions(sourceActions) + ", drop action is " + DnDUtils.showActions(dropAction)); Point location = dtde.getLocation(); boolean acceptableDropLocation = isAcceptableDropLocation(location); // Reject if the object being transferred // or the operations available are not acceptable. if (!acceptableType || (sourceActions & DnDConstants.ACTION_COPY_OR_MOVE) == 0) { DnDUtils.debugPrintln("Drop target rejecting drag"); dtde.rejectDrag();//ww w . ja v a 2s . c o m } else if (!tree.isEditable()) { // Can't drag to a read-only FileTree DnDUtils.debugPrintln("Drop target rejecting drag"); dtde.rejectDrag(); } else if (!acceptableDropLocation) { // Can only drag to writable directory DnDUtils.debugPrintln("Drop target rejecting drag"); dtde.rejectDrag(); } else if ((dropAction & DnDConstants.ACTION_COPY_OR_MOVE) == 0) { // Not offering copy or move - suggest a copy DnDUtils.debugPrintln("Drop target offering COPY"); dtde.acceptDrag(DnDConstants.ACTION_COPY); acceptedDrag = true; } else { // Offering an acceptable operation: accept DnDUtils.debugPrintln("Drop target accepting drag"); dtde.acceptDrag(dropAction); acceptedDrag = true; } return acceptedDrag; }
From source file:DragDropTreeExample.java
protected boolean acceptOrRejectDrag(DropTargetDragEvent dtde) { int dropAction = dtde.getDropAction(); int sourceActions = dtde.getSourceActions(); boolean acceptedDrag = false; DnDUtils.debugPrintln("\tSource actions are " + DnDUtils.showActions(sourceActions) + ", drop action is " + DnDUtils.showActions(dropAction)); Point location = dtde.getLocation(); boolean acceptableDropLocation = isAcceptableDropLocation(location); // Reject if the object being transferred // or the operations available are not acceptable. if (!acceptableType || (sourceActions & DnDConstants.ACTION_COPY_OR_MOVE) == 0) { DnDUtils.debugPrintln("Drop target rejecting drag"); dtde.rejectDrag();//from ww w . j a v a 2 s .c o m } else if (!tree.isEditable()) { // Can't drag to a read-only FileTree DnDUtils.debugPrintln("Drop target rejecting drag"); dtde.rejectDrag(); } else if (!acceptableDropLocation) { // Can only drag to writable directory DnDUtils.debugPrintln("Drop target rejecting drag"); dtde.rejectDrag(); } else if ((dropAction & DnDConstants.ACTION_COPY_OR_MOVE) == 0) { // Not offering copy or move - suggest a copy DnDUtils.debugPrintln("Drop target offering COPY"); dtde.acceptDrag(DnDConstants.ACTION_COPY); acceptedDrag = true; } else { // Offering an acceptable operation: accept DnDUtils.debugPrintln("Drop target accepting drag"); dtde.acceptDrag(dropAction); acceptedDrag = true; } return acceptedDrag; }
From source file:org.nuclos.client.ui.collect.CollectController.java
@Override public void visitDragOver(DropTargetDragEvent dtde) { Point here = dtde.getLocation(); openDetailsPanel(here); }