use of com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesHandler in project intellij-community by JetBrains.
the class FileListPasteProvider method performPaste.
@Override
public void performPaste(@NotNull DataContext dataContext) {
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
final IdeView ideView = LangDataKeys.IDE_VIEW.getData(dataContext);
if (project == null || ideView == null)
return;
if (!FileCopyPasteUtil.isFileListFlavorAvailable())
return;
final Transferable contents = CopyPasteManager.getInstance().getContents();
if (contents == null)
return;
final List<File> fileList = FileCopyPasteUtil.getFileList(contents);
if (fileList == null)
return;
if (DumbService.isDumb(project)) {
DumbService.getInstance(project).showDumbModeNotification("Sorry, file copy/paste is not available during indexing");
return;
}
final List<PsiElement> elements = new ArrayList<>();
for (File file : fileList) {
final VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
if (vFile != null) {
final PsiManager instance = PsiManager.getInstance(project);
PsiFileSystemItem item = vFile.isDirectory() ? instance.findDirectory(vFile) : instance.findFile(vFile);
if (item != null) {
elements.add(item);
}
}
}
if (elements.size() > 0) {
final PsiDirectory dir = ideView.getOrChooseDirectory();
if (dir != null) {
final boolean move = LinuxDragAndDropSupport.isMoveOperation(contents);
if (move) {
new MoveFilesOrDirectoriesHandler().doMove(PsiUtilCore.toPsiElementArray(elements), dir);
} else {
new CopyFilesOrDirectoriesHandler().doCopy(PsiUtilCore.toPsiElementArray(elements), dir);
}
}
}
}
Aggregations