Exemplo n.º 1
0
  public void drop(DropTargetDropEvent dtde) {
    if ((dtde.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) == 0) {
      dtde.rejectDrop();
      return;
    }
    dtde.acceptDrop(DnDConstants.ACTION_COPY);
    Vector<RowContainer> oldvec = this.filevector;

    Transferable transferable = dtde.getTransferable();
    try {
      java.util.List<File> filelist =
          (java.util.List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
      for (File f : filelist) {
        filevector.add(new RowContainer(f));

        model.fireTableDataChanged();
        System.out.println(f.toString());
      }
    } catch (IOException ex) {
      ex.printStackTrace();
    } catch (UnsupportedFlavorException ex) {
      ex.printStackTrace();
    }
    dtde.dropComplete(true);
    File[] filar = new File[filevector.size()];
    for (int i = 0; i < filevector.size(); i++) {
      filar[i] = filevector.get(i).getFile();
    }
    super.firePropertyChange("filevector", null, filar);
  }
Exemplo n.º 2
0
 public boolean isDropAcceptable(DropTargetDropEvent event) { // usually, you
   // check the
   // available
   // data flavors
   // here
   // in this program, we accept all flavors
   return (event.getDropAction() & DnDConstants.ACTION_COPY_OR_MOVE) != 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);
 }
Exemplo n.º 4
0
  private void acceptDrop(DropTargetDropEvent dtde) {
    int dragaction = dtde.getDropAction();

    if (dragaction != 0) {
      dtde.acceptDrop(dragaction);
    } else {
      dtde.acceptDrop(ALL_ACTIONS);
    }
  }
 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;
 }