本文整理汇总了Java中com.intellij.ide.dnd.FileCopyPasteUtil.isFileListFlavorAvailable方法的典型用法代码示例。如果您正苦于以下问题:Java FileCopyPasteUtil.isFileListFlavorAvailable方法的具体用法?Java FileCopyPasteUtil.isFileListFlavorAvailable怎么用?Java FileCopyPasteUtil.isFileListFlavorAvailable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.ide.dnd.FileCopyPasteUtil
的用法示例。
在下文中一共展示了FileCopyPasteUtil.isFileListFlavorAvailable方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performPaste
import com.intellij.ide.dnd.FileCopyPasteUtil; //导入方法依赖的package包/类
@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;
final List<PsiElement> elements = new ArrayList<PsiElement>();
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);
}
}
}
}
示例2: performPaste
import com.intellij.ide.dnd.FileCopyPasteUtil; //导入方法依赖的package包/类
@Override
public void performPaste(@Nonnull DataContext dataContext) {
final Project project = dataContext.getData(CommonDataKeys.PROJECT);
final IdeView ideView = dataContext.getData(LangDataKeys.IDE_VIEW);
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;
final List<PsiElement> elements = new ArrayList<PsiElement>();
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);
}
}
}
}
示例3: canHandleDrop
import com.intellij.ide.dnd.FileCopyPasteUtil; //导入方法依赖的package包/类
@Override
public boolean canHandleDrop(final DataFlavor[] transferFlavors) {
return transferFlavors != null && FileCopyPasteUtil.isFileListFlavorAvailable(transferFlavors);
}
示例4: update
import com.intellij.ide.dnd.FileCopyPasteUtil; //导入方法依赖的package包/类
@Override
public boolean update(DnDEvent event) {
event.setDropPossible(false, "");
final Object attached = event.getAttachedObject();
final int dropAction = event.getAction().getActionId();
final DropHandler dropHandler = getDropHandler(dropAction);
final TreeNode[] sourceNodes = getSourceNodes(attached);
final Point point = event.getPoint();
final TreeNode targetNode = getTargetNode(point);
if (targetNode == null ||
(dropAction & DnDConstants.ACTION_COPY_OR_MOVE) == 0 ||
sourceNodes == null && !FileCopyPasteUtil.isFileListFlavorAvailable(event) ||
sourceNodes != null && ArrayUtilRt.find(sourceNodes, targetNode) != -1 ||
sourceNodes != null && !dropHandler.isValidSource(sourceNodes, targetNode)) {
return false;
}
if (sourceNodes != null) {
boolean redundant = true;
for (TreeNode sourceNode : sourceNodes) {
if (!dropHandler.isDropRedundant(sourceNode, targetNode)) {
redundant = false;
break;
}
}
if (redundant) return false;
}
else {
// it seems like it's not possible to obtain dragged items _before_ accepting _drop_ on Macs, so just skip this check
if (!SystemInfo.isMac) {
final PsiFileSystemItem[] psiFiles = getPsiFiles(FileCopyPasteUtil.getFileListFromAttachedObject(attached));
if (psiFiles == null || psiFiles.length == 0) return false;
if (!MoveHandler.isValidTarget(getPsiElement(targetNode), psiFiles)) return false;
}
}
final Rectangle pathBounds = myTree.getPathBounds(myTree.getClosestPathForLocation(point.x, point.y));
if (pathBounds != null && pathBounds.y + pathBounds.height < point.y) return false;
event.setHighlighting(new RelativeRectangle(myTree, pathBounds), DnDEvent.DropTargetHighlightingType.RECTANGLE);
event.setDropPossible(true);
return false;
}
示例5: isPasteEnabled
import com.intellij.ide.dnd.FileCopyPasteUtil; //导入方法依赖的package包/类
@Override
public boolean isPasteEnabled(@NotNull DataContext dataContext) {
return LangDataKeys.IDE_VIEW.getData(dataContext) != null &&
FileCopyPasteUtil.isFileListFlavorAvailable();
}
示例6: canImport
import com.intellij.ide.dnd.FileCopyPasteUtil; //导入方法依赖的package包/类
@Override
public boolean canImport(final TransferSupport support) {
return FileCopyPasteUtil.isFileListFlavorAvailable(support.getDataFlavors());
}
示例7: isPasteEnabled
import com.intellij.ide.dnd.FileCopyPasteUtil; //导入方法依赖的package包/类
@Override
public boolean isPasteEnabled(@Nonnull DataContext dataContext) {
return dataContext.getData(LangDataKeys.IDE_VIEW) != null &&
FileCopyPasteUtil.isFileListFlavorAvailable();
}