本文整理汇总了Java中com.intellij.openapi.fileEditor.ex.FileEditorManagerEx.getData方法的典型用法代码示例。如果您正苦于以下问题:Java FileEditorManagerEx.getData方法的具体用法?Java FileEditorManagerEx.getData怎么用?Java FileEditorManagerEx.getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.fileEditor.ex.FileEditorManagerEx
的用法示例。
在下文中一共展示了FileEditorManagerEx.getData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getData
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
@Override
public Object getData(@NonNls String dataId) {
if (myProject.isDisposed()) {
throw new RuntimeException("TestDataProvider is already disposed for " + myProject + "\n" +
"If you closed a project in test, please reset IdeaTestApplication.setDataProvider.");
}
if (PlatformDataKeys.PROJECT.is(dataId)) {
return myProject;
}
else if (PlatformDataKeys.EDITOR.is(dataId) || OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId)) {
return FileEditorManager.getInstance(myProject).getSelectedTextEditor();
}
else {
Editor editor = (Editor)getData(PlatformDataKeys.EDITOR.getName());
if (editor != null) {
FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(myProject);
Object managerData = manager.getData(dataId, editor, manager.getSelectedFiles()[0]);
if (managerData != null) {
return managerData;
}
JComponent component = editor.getContentComponent();
if (component instanceof EditorComponentImpl) {
return ((EditorComponentImpl)component).getData(dataId);
}
}
return null;
}
}
示例2: getData
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
@Override
public Object getData(@Nonnull Key<?> dataId) {
if (myProject.isDisposed()) {
throw new RuntimeException("TestDataProvider is already disposed for " + myProject + "\n" +
"If you closed a project in test, please reset IdeaTestApplication.setDataProvider.");
}
if (CommonDataKeys.PROJECT == dataId) {
return myProject;
}
else if (PlatformDataKeys.EDITOR == dataId || OpenFileDescriptor.NAVIGATE_IN_EDITOR == dataId) {
return FileEditorManager.getInstance(myProject).getSelectedTextEditor();
}
else {
Editor editor = (Editor)getData(PlatformDataKeys.EDITOR);
if (editor != null) {
FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(myProject);
Object managerData = manager.getData(dataId, editor, editor.getCaretModel().getCurrentCaret());
if (managerData != null) {
return managerData;
}
JComponent component = editor.getContentComponent();
if (component instanceof EditorComponentImpl) {
return ((EditorComponentImpl)component).getData(dataId);
}
}
return null;
}
}
示例3: getData
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
@Override
@Nullable
public Object getData(@NonNls String dataId) {
if (CommonDataKeys.PROJECT.is(dataId)) {
return myProject;
}
else if (CommonDataKeys.EDITOR.is(dataId) || OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId)) {
if (myProject == null) return null;
return FileEditorManager.getInstance(myProject).getSelectedTextEditor();
}
else {
Editor editor = (Editor)getData(CommonDataKeys.EDITOR.getName());
if (editor != null) {
FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(myProject);
return manager.getData(dataId, editor, editor.getCaretModel().getCurrentCaret());
}
else if (LangDataKeys.IDE_VIEW.is(dataId)) {
VirtualFile[] contentRoots = ProjectRootManager.getInstance(myProject).getContentRoots();
final PsiDirectory psiDirectory = PsiManager.getInstance(myProject).findDirectory(contentRoots[0]);
if (contentRoots.length > 0) {
return new IdeView() {
@Override
public void selectElement(PsiElement element) {
}
@NotNull
@Override
public PsiDirectory[] getDirectories() {
return new PsiDirectory[] {psiDirectory};
}
@Override
public PsiDirectory getOrChooseDirectory() {
return psiDirectory;
}
};
}
}
return null;
}
}
示例4: getData
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
@Override
@Nullable
public Object getData(@NonNls String dataId) {
if (PlatformDataKeys.PROJECT.is(dataId)) {
return myProject;
}
else if (PlatformDataKeys.EDITOR.is(dataId) || OpenFileDescriptor.NAVIGATE_IN_EDITOR.is(dataId)) {
if (myProject == null) return null;
return FileEditorManager.getInstance(myProject).getSelectedTextEditor();
}
else {
Editor editor = (Editor)getData(PlatformDataKeys.EDITOR.getName());
if (editor != null) {
FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(myProject);
return manager.getData(dataId, editor, manager.getSelectedFiles()[0]);
}
else if (LangDataKeys.IDE_VIEW.is(dataId)) {
VirtualFile[] contentRoots = ProjectRootManager.getInstance(myProject).getContentRoots();
final PsiDirectory psiDirectory = PsiManager.getInstance(myProject).findDirectory(contentRoots[0]);
if (contentRoots.length > 0) {
return new IdeView() {
@Override
public void selectElement(PsiElement element) {
}
@Override
public PsiDirectory[] getDirectories() {
return new PsiDirectory[] {psiDirectory};
}
@Override
public PsiDirectory getOrChooseDirectory() {
return psiDirectory;
}
};
}
}
return null;
}
}
示例5: getData
import com.intellij.openapi.fileEditor.ex.FileEditorManagerEx; //导入方法依赖的package包/类
@Override
@Nullable
public Object getData(@Nonnull @NonNls Key<?> dataId) {
if (CommonDataKeys.PROJECT == dataId) {
return myProject;
}
else if (PlatformDataKeys.EDITOR == dataId || OpenFileDescriptor.NAVIGATE_IN_EDITOR == dataId) {
if (myProject == null) return null;
return FileEditorManager.getInstance(myProject).getSelectedTextEditor();
}
else {
Editor editor = (Editor)getData(PlatformDataKeys.EDITOR);
if (editor != null) {
FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(myProject);
return manager.getData(dataId, editor, editor.getCaretModel().getCurrentCaret());
}
else if (LangDataKeys.IDE_VIEW == dataId) {
VirtualFile[] contentRoots = ProjectRootManager.getInstance(myProject).getContentRoots();
final PsiDirectory psiDirectory = PsiManager.getInstance(myProject).findDirectory(contentRoots[0]);
if (contentRoots.length > 0) {
return new IdeView() {
@Override
public void selectElement(PsiElement element) {
}
@Override
public PsiDirectory[] getDirectories() {
return new PsiDirectory[] {psiDirectory};
}
@Override
public PsiDirectory getOrChooseDirectory() {
return psiDirectory;
}
};
}
}
return null;
}
}