Exemplo n.º 1
0
  @Nullable
  private CopyPasteFilesData getData(DataContext dataContext) {
    Transferable content = CopyPasteManagerEx.getInstanceEx().getContents();
    if (content == null) return null;

    CopyPasteFilesData files = null;
    if (content.isDataFlavorSupported(VirtualFileTransferable.VIRTUAL_FILE_DATA_FLAVOR)) {
      try {
        files =
            getData(
                (String[])
                    content.getTransferData(VirtualFileTransferable.VIRTUAL_FILE_DATA_FLAVOR));

        if (files == null || !files.hasAnythingToDo()) {
          return null;
        }

      } catch (UnsupportedFlavorException e) {
        LOG.error("Exception", e);
        return null;
      } catch (IOException e) {
        LOG.error("Exception", e);
        return null;
      }
    }

    return files;
  }
Exemplo n.º 2
0
 private void paste(@NotNull CopyPasteFilesData data, @NotNull VirtualFile basedir) {
   for (VirtualFile f : data.getFiles()) {
     try {
       if (!FileTypeManager.getInstance().isFileIgnored(f.getName())) {
         if (!data.isCut()) {
           f.copy(this, basedir, f.getName());
         } else {
           f.move(this, basedir);
         }
       }
     } catch (IOException e) {
       LOG.error("Error while pasting " + f + "\n", e);
     }
   }
 }