本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}