Exemplo n.º 1
0
    @SuppressWarnings("unchecked")
    public void drop(DropTargetDropEvent event) {

      try {
        if (event.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
          Transferable tr = event.getTransferable();
          int action = event.getDropAction();
          event.acceptDrop(action);

          java.util.List<File> files =
              (java.util.List<File>) tr.getTransferData(DataFlavor.javaFileListFlavor);
          for (File f : files) {
            JEXStatics.logManager.log("Copying file " + f, 1, this);
            String newDest = parent.folder.getPath() + File.separator + f.getName();
            FileUtility.copy(f, new File(newDest));
          }
          parent.rebuild();

          event.dropComplete(true);
          JEXStatics.logManager.log("Drop completed...", 1, this);

          return;
        }
        event.rejectDrop();
      } catch (Exception e) {
        e.printStackTrace();
        event.rejectDrop();
      }
    }
Exemplo n.º 2
0
 public void mouseReleased(MouseEvent e) {
   if (e.getClickCount() == 2) {
     JEXStatics.logManager.log("Opening " + f + " in default application", 1, this);
     try {
       FileUtility.openFileDefaultApplication(f.getAbsolutePath());
     } catch (Exception e1) {
       JEXStatics.logManager.log("Cannot open file", 1, this);
     }
   }
 }