• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FileCopyPasteUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.ide.dnd.FileCopyPasteUtil的典型用法代码示例。如果您正苦于以下问题:Java FileCopyPasteUtil类的具体用法?Java FileCopyPasteUtil怎么用?Java FileCopyPasteUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileCopyPasteUtil类属于com.intellij.ide.dnd包,在下文中一共展示了FileCopyPasteUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handleDrop

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
@Override
public void handleDrop(@NotNull final Transferable t, @Nullable final Project project, EditorWindow editorWindow) {
  if (project != null) {
    final List<File> fileList = FileCopyPasteUtil.getFileList(t);
    if (fileList != null) {
      openFiles(project, fileList, editorWindow);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:FileDropHandler.java


示例2: 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);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:39,代码来源:FileListPasteProvider.java


示例3: importData

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
@Override
public boolean importData(final TransferSupport support) {
  if (canImport(support)) {
    List<VirtualFile> pomFiles = new ArrayList<VirtualFile>();

    final List<File> fileList = FileCopyPasteUtil.getFileList(support.getTransferable());
    if (fileList == null) return false;

    MavenProjectsManager manager = MavenProjectsManager.getInstance(myProject);

    for (File file : fileList) {
      VirtualFile virtualFile = VfsUtil.findFileByIoFile(file, true);
      if (file.isFile()
          && virtualFile != null
          && MavenActionUtil.isMavenProjectFile(virtualFile)
          && !manager.isManagedFile(virtualFile)) {
        pomFiles.add(virtualFile);
      }
    }

    if (pomFiles.isEmpty()) {
      return false;
    }

    manager.addManagedFilesOrUnignore(pomFiles);

    return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:MavenProjectsNavigatorPanel.java


示例4: getAntFiles

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
private VirtualFile[] getAntFiles(final TransferSupport support) {
  List<VirtualFile> virtualFileList = new ArrayList<VirtualFile>();
  final List<File> fileList = FileCopyPasteUtil.getFileList(support.getTransferable());
  if (fileList != null) {
    for (File file : fileList ) {
      ContainerUtil.addIfNotNull(virtualFileList, VfsUtil.findFileByIoFile(file, true));
    }
  }

  return VfsUtil.toVirtualFileArray(virtualFileList);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:AntExplorer.java


示例5: getProjectPath

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
@Nullable
private static String getProjectPath(final TransferSupport support) {
  if (!FileCopyPasteUtil.isFileListFlavorSupported(support.getDataFlavors())) return null;
  List<File> files = FileCopyPasteUtil.getFileList(support.getTransferable());
  if (files == null) return null;
  File file = ContainerUtil.getFirstItem(files);
  return file != null && isProjectFileOrDir(file) ? file.getAbsolutePath() : null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:DefaultWelcomeScreen.java


示例6: handleDrop

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
public void handleDrop(@NotNull final Transferable t, @Nullable final Project project, EditorWindow editorWindow) {
  if (project == null || !FileCopyPasteUtil.isFileListFlavorSupported(t)) {
    return;
  }

  final List<File> fileList = FileCopyPasteUtil.getFileList(t);
  if (fileList != null) {
    openFiles(project, fileList, editorWindow);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:FileDropHandler.java


示例7: performPaste

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
@Override
public void performPaste(@NotNull DataContext dataContext) {
  final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  final IdeView ideView = LangDataKeys.IDE_VIEW.getData(dataContext);
  if (project == null || ideView == null) 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);
      }
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:FileListPasteProvider.java


示例8: importData

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
@Override
public boolean importData(final TransferSupport support) {
  if (canImport(support)) {
    List<VirtualFile> pomFiles = new ArrayList<VirtualFile>();

    final List<File> fileList = FileCopyPasteUtil.getFileList(support.getTransferable());
    if (fileList == null) return false;

    MavenProjectsManager manager = MavenProjectsManager.getInstance(myProject);

    for (File file : fileList) {
      VirtualFile virtualFile = VfsUtil.findFileByIoFile(file, true);
      if (file.isFile()
          && virtualFile != null
          && MavenActionUtil.isMavenProjectFile(virtualFile)
          && !manager.isManagedFile(virtualFile)) {
        pomFiles.add(virtualFile);
      }
    }

    if (pomFiles.isEmpty()) {
      return false;
    }

    manager.addManagedFiles(pomFiles);

    return true;
  }
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:31,代码来源:MavenProjectsNavigatorPanel.java


示例9: handleDrop

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
@Override
public void handleDrop(@Nonnull final Transferable t, @Nullable final Project project, EditorWindow editorWindow) {
  if (project != null) {
    final List<File> fileList = FileCopyPasteUtil.getFileList(t);
    if (fileList != null) {
      boolean dropResult = ContainerUtil.process(Extensions.getExtensions(CustomFileDropHandler.CUSTOM_DROP_HANDLER_EP, project),
                                                 handler -> !(handler.canHandle(t, myEditor) && handler.handleDrop(t, myEditor, project)));
      if (!dropResult) return;

      openFiles(project, fileList, editorWindow);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:14,代码来源:FileDropHandler.java


示例10: 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);
      }
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:39,代码来源:FileListPasteProvider.java


示例11: canHandleDrop

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
@Override
public boolean canHandleDrop(final DataFlavor[] transferFlavors) {
  return transferFlavors != null && FileCopyPasteUtil.isFileListFlavorAvailable(transferFlavors);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:FileDropHandler.java


示例12: 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:45,代码来源:ProjectViewDropTarget.java


示例13: isPasteEnabled

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
@Override
public boolean isPasteEnabled(@NotNull DataContext dataContext) {
  return LangDataKeys.IDE_VIEW.getData(dataContext) != null &&
         FileCopyPasteUtil.isFileListFlavorAvailable();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:FileListPasteProvider.java


示例14: canImport

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
@Override
public boolean canImport(final TransferSupport support) {
  return FileCopyPasteUtil.isFileListFlavorAvailable(support.getDataFlavors());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MavenProjectsNavigatorPanel.java


示例15: canImport

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
public boolean canImport(final TransferSupport support) {
  return FileCopyPasteUtil.isFileListFlavorSupported(support.getDataFlavors());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:4,代码来源:DefaultWelcomeScreen.java


示例16: canHandleDrop

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
public boolean canHandleDrop(final DataFlavor[] transferFlavors) {
  return transferFlavors != null && FileCopyPasteUtil.isFileListFlavorSupported(transferFlavors);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:4,代码来源:FileDropHandler.java


示例17: 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) {
    return false;
  }
  else if (sourceNodes == null && !FileCopyPasteUtil.isFileListFlavorSupported(event)) {
    return false;
  }
  else if (sourceNodes != null && ArrayUtilRt.find(sourceNodes, targetNode) != -1) {
    return false;
  }
  else if (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));
  event.setHighlighting(new RelativeRectangle(myTree, pathBounds), DnDEvent.DropTargetHighlightingType.RECTANGLE);
  event.setDropPossible(true);
  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:49,代码来源:ProjectViewDropTarget.java


示例18: isPasteEnabled

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
@Override
public boolean isPasteEnabled(@NotNull DataContext dataContext) {
  final Transferable contents = CopyPasteManager.getInstance().getContents();
  final IdeView ideView = LangDataKeys.IDE_VIEW.getData(dataContext);
  return contents != null && FileCopyPasteUtil.isFileListFlavorSupported(contents) && ideView != null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:7,代码来源:FileListPasteProvider.java


示例19: canImport

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
@Override
public boolean canImport(final TransferSupport support) {
  return FileCopyPasteUtil.isFileListFlavorSupported(support.getDataFlavors());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:5,代码来源:MavenProjectsNavigatorPanel.java


示例20: canHandle

import com.intellij.ide.dnd.FileCopyPasteUtil; //导入依赖的package包/类
@Override
public boolean canHandle(@Nonnull Transferable t, Editor editor) {
  List<File> list = FileCopyPasteUtil.getFileList(t);
  if (list == null || list.size() != 1) return false;
  return PatchFileType.isPatchFile(list.get(0));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:7,代码来源:PatchFileDropHandler.java



注:本文中的com.intellij.ide.dnd.FileCopyPasteUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Augmentable类代码示例发布时间:2022-05-22
下一篇:
Java BlockInfo类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap