コード例 #1
0
 private void processDrop(DropData dropData, DropTargetDropEvent dropTargetDropEvent) {
   putEntryAtPoint(dropData.whatToDrop, dropData.whereInTable);
   _widget.addEntry(dropData.whatToDrop);
   _underlyingTable.setRowSelectionInterval(dropData.whereInTable.x, dropData.whereInTable.x);
   _underlyingTable.setColumnSelectionInterval(dropData.whereInTable.y, dropData.whereInTable.y);
   dropTargetDropEvent.acceptDrop(dropTargetDropEvent.getDropAction());
   dropTargetDropEvent.dropComplete(true);
 }
コード例 #2
0
 protected Point getTableLocationForEvent(DropTargetDropEvent dropTargetDropEvent) {
   Point dropTargetPoint = dropTargetDropEvent.getLocation();
   int column = _underlyingTable.columnAtPoint(dropTargetPoint);
   int row = _underlyingTable.rowAtPoint(dropTargetPoint);
   if ((row < 0) || (column < 0)) {
     return null;
   }
   return new Point(row, column);
 }
コード例 #3
0
 public void drop(DropTargetDropEvent dropTargetDropEvent) {
   DropData dropData = convertEventIntoDropData(dropTargetDropEvent);
   if (null == dropData) {
     dropTargetDropEvent.rejectDrop();
   } else {
     int dropAction = dropTargetDropEvent.getDropAction();
     if (DnDConstants.ACTION_MOVE == dropAction) {
       _widget.removeEntry(dropData.whatToDrop);
       processDrop(dropData, dropTargetDropEvent);
     }
     if (DnDConstants.ACTION_COPY == dropAction) {
       dropData.whatToDrop =
           RecursiveCopy.recursivelyCopyInstance(
               dropData.whatToDrop, Constants.RECURSIVE_COPY_DEPTH_FOR_DND);
       processDrop(dropData, dropTargetDropEvent);
     }
   }
   _widget.setIsCurrentlyDragging(false);
   return;
 }
コード例 #4
0
 private DropData convertEventIntoDropData(DropTargetDropEvent dropTargetDropEvent) {
   Transferable transferable = dropTargetDropEvent.getTransferable();
   Point tableLocation = getTableLocationForEvent(dropTargetDropEvent);
   if (null != _underlyingTable.getValueAt(tableLocation.x, tableLocation.y)) {
     return null;
   }
   Instance entry;
   try {
     entry = (Instance) transferable.getTransferData(_flavor);
   } catch (Exception e) {
     return null;
   }
   if ((null == entry) || !entry.hasType(_entryCls)) {
     return null;
   }
   return new DropData(tableLocation, entry);
 }