Java Code Examples for java.awt.dnd.DragSourceDropEvent#getDropSuccess()

The following examples show how to use java.awt.dnd.DragSourceDropEvent#getDropSuccess() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultTransferHandler.java    From freecol with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void dragDropEnd(DragSourceDropEvent dsde) {
    DragSourceContext dsc = dsde.getDragSourceContext();
    JComponent c = (JComponent)dsc.getComponent();

    if (dsde.getDropSuccess()) {
        ((DefaultTransferHandler)c.getTransferHandler()).exportDone(c,
            dsc.getTransferable(), dsde.getDropAction());
    } else {
        ((DefaultTransferHandler)c.getTransferHandler()).exportDone(c,
            null, NONE);
    }
    c.setAutoscrolls(scrolls);
}
 
Example 2
Source File: TreePanel.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void dragDropEnd(DragSourceDropEvent event) {
    if (event.getDropSuccess()) {
        if (!mDropReceived) {
            if ((event.getDropAction() & mAllowedRowDragTypes) == DnDConstants.ACTION_MOVE) {
                externalMoveDrop(event.getDragSourceContext().getTransferable());
            }
        }
    }
    setSourceDragColumn(null);
}
 
Example 3
Source File: AbstractPatchedTransferHandler.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * as the operation completes
 */
@Override
public void dragDropEnd(DragSourceDropEvent dsde) {
	DragSourceContext dsc = dsde.getDragSourceContext();
	JComponent c = (JComponent) dsc.getComponent();
	if (dsde.getDropSuccess()) {
		((AbstractPatchedTransferHandler) c.getTransferHandler()).exportDone(c, dsc.getTransferable(),
				dsde.getDropAction());
	} else {
		((AbstractPatchedTransferHandler) c.getTransferHandler()).exportDone(c, dsc.getTransferable(), NONE);
	}
	c.setAutoscrolls(scrolls);
	fireDragEnded();
}
 
Example 4
Source File: AbstractTreeTransferHandler.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
public void dragDropEnd(final DragSourceDropEvent dsde) {
  if (dsde.getDropSuccess() && (dsde.getDropAction() == DnDConstants.ACTION_MOVE)
      && (draggedNodeParent != null)) {
    ((DefaultTreeModel) tree.getModel()).nodeStructureChanged(draggedNodeParent);
  }
}
 
Example 5
Source File: DBTableInternalFrame.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
public void dragDropEnd(DragSourceDropEvent dsde) {
            gestureStarted = false;
            if (dsde.getDropSuccess()) {
                int row = columnsListBox.getSelectedIndex();
//                System.out.println("row = " + row);
                CheckListItem item = (CheckListItem) model.getElementAt(row);
//                System.out.println("item = " + item.getText());
//                item.setSelected(true);
                model.setElementAt(item, row);
            }
        }
 
Example 6
Source File: AbstractTreeTransferHandler.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
public void dragDropEnd(DragSourceDropEvent dsde) {
	if (dsde.getDropSuccess() && dsde.getDropAction()==DnDConstants.ACTION_MOVE && draggedNodeParent != null) {
		((DefaultTreeModel)tree.getModel()).nodeStructureChanged(draggedNodeParent);
		tree.expandPath(new TreePath(draggedNodeParent.getPath()));
		tree.expandPath(new TreePath(draggedNode.getPath()));
	}

}
 
Example 7
Source File: DnDSupport.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void dragDropEnd(DragSourceDropEvent e) {
    if( isButtonDrag ) {
        Component sourceComponent = e.getDragSourceContext().getComponent();
        if( sourceComponent instanceof JButton ) {
            ((JButton)sourceComponent).getModel().setRollover( false );
        }
        sourceComponent.repaint();
        resetDropGesture();
        if( e.getDropSuccess() == false &&
                !isInToolbarPanel( WindowDnDManager.getLocationWorkaround(e) ) )
        {
            //TODO catch ESC key
            removeButton( e.getDragSourceContext().getTransferable() );
        }
    } else if( isToolbarDrag ) {
        Point newLocationOnScreen = null;

        boolean save = false;
        if( null != currentRow ) {
            //the cursor is above some toolbar row, we can proceed with the drop
            newLocationOnScreen = currentRow.drop();
            if( sourceRow != currentRow ) {
                //clean up the row which we dragged from
                sourceRow.dragSuccess();
                config.removeEmptyRows();
            }
            save = true;
        } else if( null != sourceRow ) {
            //cursor is outside the toolbar area, abort the drop
            newLocationOnScreen = sourceRow.dragAbort();
            save = true;
        }
        if( null != dragWindow ) {
            if( null != newLocationOnScreen ) {
                animateDragWindow(newLocationOnScreen);
            } else {
                dragWindow.dispose();
            }
            dragWindow = null;
        }
        config.maybeRemoveLastRow();
        if( save ) {
            config.refresh();
            config.save();
        }
    }
    isButtonDrag = false;
    isToolbarDrag = false;
}
 
Example 8
Source File: DragManager.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void dragDropEnd(DragSourceDropEvent dsde) {
    if (!dsde.getDropSuccess() && activeDragItem != null) {
        activeDragItem.dragAccepted();
    }
    
}
 
Example 9
Source File: Button2DragTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void run() {
    frame = new Frame();

    final DragSourceListener dragSourceListener = new DragSourceAdapter() {
        public void dragDropEnd(DragSourceDropEvent e) {
            dropSuccess = e.getDropSuccess();
            System.err.println("Drop was successful: " + dropSuccess);
        }
    };
    DragGestureListener dragGestureListener = new DragGestureListener() {
        public void dragGestureRecognized(DragGestureEvent dge) {
            dge.startDrag(null, new StringSelection("OK"), dragSourceListener);
        }
    };
    new DragSource().createDefaultDragGestureRecognizer(frame, DnDConstants.ACTION_MOVE,
                                                        dragGestureListener);

    DropTargetAdapter dropTargetListener = new DropTargetAdapter() {
        public void drop(DropTargetDropEvent dtde) {
            dtde.acceptDrop(DnDConstants.ACTION_MOVE);
            dtde.dropComplete(true);
            System.err.println("Drop");
        }
    };
    new DropTarget(frame, dropTargetListener);

    //What would normally go into main() will probably go here.
    //Use System.out.println for diagnostic messages that you want
    //to read after the test is done.
    frame.setUndecorated(true);
    frame.setBounds(100, 100, 200, 200);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    Robot robot = Util.createRobot();

    Util.waitForIdle(robot);

    Point startPoint = frame.getLocationOnScreen();
    Point endPoint = new Point(startPoint);
    startPoint.translate(50, 50);
    endPoint.translate(150, 150);

    Util.drag(robot, startPoint, endPoint, InputEvent.BUTTON2_MASK);

    Util.waitForIdle(robot);
    robot.delay(500);

    if (dropSuccess) {
        System.err.println("test passed");
    } else {
        throw new RuntimeException("test failed: drop was not successful");
    }
}