Esempio n. 1
0
  public void drop(DropTargetDropEvent dtde) {
    dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
    if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
      try {
        content =
            (java.util.List) dtde.getTransferable().getTransferData(DataFlavor.javaFileListFlavor);
        repaint();
      } catch (UnsupportedFlavorException e) {
        e.printStackTrace();
      } catch (IOException e) {
        e.printStackTrace();
      }
      dtde.dropComplete(true);

      boolean listsAreEqual = true;

      for (int i = 0; i < content.size(); i++) {
        if (!FileListTransferable.files[i].getName().equals(content.get(i).getName())) {
          listsAreEqual = false;
        }
      }

      if (listsAreEqual) {
        System.err.println(InterprocessMessages.EXECUTION_IS_SUCCESSFULL);
        System.exit(0);
      }
    }
    dtde.rejectDrop();
    System.err.println(InterprocessMessages.FILES_ON_TARGET_ARE_CORRUPTED);
    System.exit(1);
  }
Esempio n. 2
0
    public void drop(DropTargetDropEvent event) {
      if (!isDropAcceptable(event)) {
        event.rejectDrop();
        return;
      }

      event.acceptDrop(DnDConstants.ACTION_COPY);

      Transferable transferable = event.getTransferable();

      MessageCollection messages = new MessageCollection();
      try {
        List<File> files = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);

        for (File file : files) {
          try {
            ResourceLocator locator = new ResourceLocator(file.getAbsolutePath());
            IGV.getInstance().load(locator, panel);
          } catch (DataLoadException de) {
            messages.append(de.getMessage());
          }
        }
        String obj = transferable.getTransferData(DataFlavor.stringFlavor).toString();
        if (HttpUtils.isRemoteURL(obj)) {
          IGV.getInstance().load(new ResourceLocator(obj), panel);
        }
        if (messages != null && !messages.isEmpty()) {
          log.error(messages.getFormattedMessage());
          MessageUtils.showMessage(messages.getFormattedMessage());
        }
      } catch (Exception e) {
        String obj = null;
        try {
          obj = transferable.getTransferData(DataFlavor.stringFlavor).toString();
          if (HttpUtils.isRemoteURL(obj)) {
            IGV.getInstance().load(new ResourceLocator(obj), panel);
          }
        } catch (Exception e1) {
          log.error(e1);
          if (messages != null && !messages.isEmpty()) {
            MessageUtils.showMessage(messages.getFormattedMessage());
          }
        }
      }
      IGV.getMainFrame().repaint();
      event.dropComplete(true);
    }
 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;
 }
Esempio n. 4
0
 @Override
 public void drop(DropTargetDropEvent dtde) {
   try {
     if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
       dtde.acceptDrop(DnDConstants.ACTION_COPY);
       Transferable t = dtde.getTransferable();
       List list = (List) t.getTransferData(DataFlavor.javaFileListFlavor);
       for (Object o : list) {
         if (o instanceof File) {
           File f = (File) o;
           System.out.println(f.getAbsolutePath());
         }
       }
       dtde.dropComplete(true);
       return;
     }
   } catch (UnsupportedFlavorException | IOException ex) {
     ex.printStackTrace();
   }
   dtde.rejectDrop();
 }
    public void drop(DropTargetDropEvent e) {
      if (dragSource != null) {
        e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
        Point p = e.getLocation();
        int targetRow = rowAtPoint(p);

        Object edge =
            graph.insertEdge(
                null,
                null,
                null,
                dragSource.cell,
                JTableRenderer.this.cell,
                "sourceRow=" + sourceRow + ";targetRow=" + targetRow);
        graph.setSelectionCell(edge);

        // System.out.println("clearing drag source");
        dragSource = null;
        e.dropComplete(true);
      } else {
        e.rejectDrop();
      }
    }
Esempio n. 6
0
  public void drop(DropTargetDropEvent dtde) {
    Transferable t = dtde.getTransferable();
    StringBuffer dropData = null;
    DataFlavor dtf;

    JConfig.log().logVerboseDebug("Dropping!");

    if (t.getTransferDataFlavors().length == 0) {
      Clipboard sysClip = Toolkit.getDefaultToolkit().getSystemClipboard();
      Transferable t2 = sysClip.getContents(null);
      DataFlavor[] dfa2;
      int j;

      JConfig.log().logDebug("Dropped 0 data flavors, trying clipboard.");
      dfa2 = null;

      if (t2 != null) {
        JConfig.log().logVerboseDebug("t2 is not null: " + t2);
        dfa2 = t2.getTransferDataFlavors();
        JConfig.log().logVerboseDebug("Back from getTransferDataFlavors()!");
      } else {
        JConfig.log().logVerboseDebug("t2 is null!");
      }

      if (JConfig.queryConfiguration("debug.uber", "false").equals("true")) {
        if (dfa2 != null) {
          if (dfa2.length == 0) {
            JConfig.log().logVerboseDebug("Length is still zero!");
          }
          for (j = 0; j < dfa2.length; j++) {
            JConfig.log()
                .logVerboseDebug("Flavah " + j + " == " + dfa2[j].getHumanPresentableName());
            JConfig.log().logVerboseDebug("Flavah/mime " + j + " == " + dfa2[j].getMimeType());
          }
        } else {
          JConfig.log().logVerboseDebug("Flavahs supported: none!\n");
        }
      }
    }

    if (JConfig.queryConfiguration("debug.uber", "false").equals("true") && JConfig.debugging)
      dumpFlavorsOld(t);

    dtf = testAllFlavors(t);
    if (dtf != null) {
      JConfig.log().logVerboseDebug("Accepting!");
      acceptDrop(dtde);

      dropData = getTransferData(t);
      dtde.dropComplete(true);
      dtde.getDropTargetContext().dropComplete(true);
      if (dropData != null) {
        if (handler != null) {
          handler.receiveDropString(dropData);
        }
      }
    } else {
      JConfig.log().logVerboseDebug("Rejecting!");
      dtde.rejectDrop();
      handler.receiveDropString(dropData);
    }
  }