@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;
  }
Beispiel #2
0
 @Override
 public void actionPerformed(@NotNull AnActionEvent anActionEvent) {
   CopyPasteManagerEx.getInstance().setContents(new StringSelection(myTextToCopy));
 }