当前位置: 首页>>代码示例>>Java>>正文


Java CopyHandler.canCopy方法代码示例

本文整理汇总了Java中com.intellij.refactoring.copy.CopyHandler.canCopy方法的典型用法代码示例。如果您正苦于以下问题:Java CopyHandler.canCopy方法的具体用法?Java CopyHandler.canCopy怎么用?Java CopyHandler.canCopy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.refactoring.copy.CopyHandler的用法示例。


在下文中一共展示了CopyHandler.canCopy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateForEditor

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
protected void updateForEditor(DataContext dataContext, Presentation presentation) {
  Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
  if (editor == null) {
    presentation.setVisible(false);
    return;
  }

  Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return;

  }
  PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());

  PsiElement element = getTargetElement(editor, project);
  boolean result = element != null && CopyHandler.canCopy(new PsiElement[]{element});

  if (!result && file != null) {
    result = CopyHandler.canCopy(new PsiElement[]{file});
  }

  presentation.setEnabled(result);
  presentation.setVisible(true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CopyElementAction.java

示例2: updateForEditor

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
protected void updateForEditor(DataContext dataContext, Presentation presentation) {
  Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
  if (editor == null) {
    presentation.setVisible(false);
    return;
  }

  Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return;

  }
  PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());

  PsiElement element = getTargetElement(editor, project);
  boolean result = element != null && CopyHandler.canCopy(new PsiElement[]{element});

  if (!result && file != null) {
    result = CopyHandler.canCopy(new PsiElement[]{file});
  }

  presentation.setEnabled(result);
  presentation.setVisible(true);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:CopyElementAction.java

示例3: updateForEditor

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
protected void updateForEditor(DataContext dataContext, Presentation presentation) {
  Editor editor = dataContext.getData(PlatformDataKeys.EDITOR);
  if (editor == null) {
    presentation.setVisible(false);
    return;
  }

  Project project = dataContext.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;

  }
  PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());

  PsiElement element = getTargetElement(editor, project);
  boolean result = element != null && CopyHandler.canCopy(new PsiElement[]{element});

  if (!result && file != null) {
    result = CopyHandler.canCopy(new PsiElement[]{file});
  }

  presentation.setEnabled(result);
  presentation.setVisible(true);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:CopyElementAction.java

示例4: actionPerformed

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return;
  }

  CommandProcessor.getInstance().executeCommand(project, new Runnable() {
    @Override
    public void run() {
      PsiDocumentManager.getInstance(project).commitAllDocuments();
    }}, "", null
  );
  final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
  PsiElement[] elements;

  PsiDirectory defaultTargetDirectory;
  if (editor != null) {
    PsiElement aElement = getTargetElement(editor, project);
    PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
    if (file == null) return;
    elements = new PsiElement[]{aElement};
    if (aElement == null || !CopyHandler.canCopy(elements)) {
      elements = new PsiElement[]{file};
    }
    defaultTargetDirectory = file.getContainingDirectory();
  } else {
    PsiElement element = LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext);
    defaultTargetDirectory = element instanceof PsiDirectory ? (PsiDirectory)element : null;
    elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext);
  }
  doCopy(elements, defaultTargetDirectory);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:CopyElementAction.java

示例5: canDrop

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
@Override
protected boolean canDrop(@NotNull final TreeNode[] sourceNodes, @Nullable final TreeNode targetNode) {
  final PsiElement[] sourceElements = getPsiElements(sourceNodes);
  final PsiElement targetElement = getPsiElement(targetNode);
  if (targetElement == null) return false;
  final PsiFile containingFile = targetElement.getContainingFile();
  final boolean isTargetAcceptable = targetElement instanceof PsiDirectoryContainer ||
                                     targetElement instanceof PsiDirectory ||
                                     (containingFile != null && containingFile.getContainingDirectory() != null);
  return isTargetAcceptable && CopyHandler.canCopy(sourceElements);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ProjectViewDropTarget.java

示例6: actionPerformed

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = PlatformDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    return;
  }

  CommandProcessor.getInstance().executeCommand(project, new Runnable() {
    @Override
    public void run() {
      PsiDocumentManager.getInstance(project).commitAllDocuments();
    }}, "", null
  );
  final Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
  PsiElement[] elements;

  PsiDirectory defaultTargetDirectory;
  if (editor != null) {
    PsiElement aElement = getTargetElement(editor, project);
    PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
    if (file == null) return;
    elements = new PsiElement[]{aElement};
    if (aElement == null || !CopyHandler.canCopy(elements)) {
      elements = new PsiElement[]{file};
    }
    defaultTargetDirectory = file.getContainingDirectory();
  } else {
    PsiElement element = LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext);
    defaultTargetDirectory = element instanceof PsiDirectory ? (PsiDirectory)element : null;
    elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext);
  }
  doCopy(elements, defaultTargetDirectory);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:35,代码来源:CopyElementAction.java

示例7: actionPerformed

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = dataContext.getData(CommonDataKeys.PROJECT);
  if (project == null) {
    return;
  }

  CommandProcessor.getInstance().executeCommand(project, new Runnable() {
    @Override
    public void run() {
      PsiDocumentManager.getInstance(project).commitAllDocuments();
    }
  }, "", null);
  final Editor editor = dataContext.getData(PlatformDataKeys.EDITOR);
  PsiElement[] elements;

  PsiDirectory defaultTargetDirectory;
  if (editor != null) {
    PsiElement aElement = getTargetElement(editor, project);
    PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
    if (file == null) return;
    elements = new PsiElement[]{aElement};
    if (aElement == null || !CopyHandler.canCopy(elements)) {
      elements = new PsiElement[]{file};
    }
    defaultTargetDirectory = file.getContainingDirectory();
  }
  else {
    PsiElement element = dataContext.getData(LangDataKeys.TARGET_PSI_ELEMENT);
    defaultTargetDirectory = element instanceof PsiDirectory ? (PsiDirectory)element : null;
    elements = dataContext.getData(LangDataKeys.PSI_ELEMENT_ARRAY);
  }
  doCopy(elements, defaultTargetDirectory);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:36,代码来源:CopyElementAction.java

示例8: canDrop

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
@Override
protected boolean canDrop(@Nonnull final TreeNode[] sourceNodes, @Nullable final TreeNode targetNode) {
  final PsiElement[] sourceElements = getPsiElements(sourceNodes);
  final PsiElement targetElement = getPsiElement(targetNode);
  if (targetElement == null) return false;
  final PsiFile containingFile = targetElement.getContainingFile();
  final boolean isTargetAcceptable = targetElement instanceof PsiDirectoryContainer ||
                                     targetElement instanceof PsiDirectory ||
                                     (containingFile != null && containingFile.getContainingDirectory() != null);
  return isTargetAcceptable && CopyHandler.canCopy(sourceElements);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:12,代码来源:ProjectViewDropTarget.java

示例9: isCopyEnabled

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
@Override
public boolean isCopyEnabled(@NotNull DataContext dataContext) {
  PsiElement[] elements = getValidSelectedElements();
  return CopyHandler.canCopy(elements) || PsiCopyPasteManager.asFileList(elements) != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:CopyPasteDelegator.java

示例10: isCopyEnabled

import com.intellij.refactoring.copy.CopyHandler; //导入方法依赖的package包/类
@Override
public boolean isCopyEnabled(@Nonnull DataContext dataContext) {
  PsiElement[] elements = getValidSelectedElements();
  return CopyHandler.canCopy(elements) || PsiCopyPasteManager.asFileList(elements) != null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:6,代码来源:CopyPasteDelegator.java


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