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


Java FileEditorManagerEx.getData方法代码示例

本文整理汇总了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;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:TestDataProvider.java

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

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

示例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;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:42,代码来源:HeavyIdeaTestFixtureImpl.java

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


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