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


Java FileEditorManager.closeFile方法代码示例

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


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

示例1: tearDown

import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
@Override
protected void tearDown() throws Exception {
  try {
    if (myProject != null) {
      FileEditorManager editorManager = FileEditorManager.getInstance(myProject);
      VirtualFile[] openFiles = editorManager.getOpenFiles();
      for (VirtualFile openFile : openFiles) {
        editorManager.closeFile(openFile);
      }
    }
  }
  finally {
    myEditor = null;
    super.tearDown();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CodeInsightTestCase.java

示例2: dotest

import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
private void dotest(CheckAction checkAction) throws Exception {
  final PsiClass psiClass = JavaDirectoryService.getInstance().getClasses(getPackageDirectory("com/package1"))[0];
  final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
  final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
  FileEditor[] fileEditors = fileEditorManager.openFile(virtualFile, false);
  final FileEditor fileEditor = fileEditors[0];
  try {
    final StructureViewComponent structureViewComponent =
      (StructureViewComponent)fileEditor.getStructureViewBuilder().createStructureView(fileEditor, myProject);

    checkAction.testClassStructure(structureViewComponent);
    Disposer.dispose(structureViewComponent);

  }
  finally {
    fileEditorManager.closeFile(virtualFile);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaTreeStructureTest.java

示例3: tearDown

import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
@Override
protected void tearDown() throws Exception {
  try {
    FileEditorManager editorManager = FileEditorManager.getInstance(getProject());
    VirtualFile[] openFiles = editorManager.getOpenFiles();
    for (VirtualFile openFile : openFiles) {
      editorManager.closeFile(openFile);
    }
    deleteVFile();
    myEditor = null;
    myFile = null;
    myVFile = null;
  }
  finally {
    super.tearDown();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:LightPlatformCodeInsightTestCase.java

示例4: dissociate

import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
public static void dissociate(final Collection<ResourceBundle> resourceBundles, final Project project) {
  final FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
  final Set<PsiFileSystemItem> toUpdateInProjectView = new HashSet<PsiFileSystemItem>();
  for (ResourceBundle resourceBundle : resourceBundles) {
    fileEditorManager.closeFile(new ResourceBundleAsVirtualFile(resourceBundle));
    for (final PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) {
      fileEditorManager.closeFile(propertiesFile.getVirtualFile());
      PsiDirectory containingDirectory = propertiesFile.getContainingFile().getContainingDirectory();
      if (containingDirectory != null) {
        toUpdateInProjectView.add(containingDirectory);
      }
    }
    ResourceBundleManager.getInstance(project).dissociateResourceBundle(resourceBundle);
  }
  AbstractProjectViewPane currentProjectViewPane = ProjectView.getInstance(project).getCurrentProjectViewPane();
  if (currentProjectViewPane == null) {
    return;
  }
  AbstractTreeBuilder treeBuilder = currentProjectViewPane.getTreeBuilder();
  if (treeBuilder != null) {
    for (PsiFileSystemItem item : toUpdateInProjectView) {
      treeBuilder.queueUpdateFrom(item, false);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:DissociateResourceBundleAction.java

示例5: updateOpenedTestFiles

import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
private static void updateOpenedTestFiles(@NotNull Project project,
                                          @NotNull VirtualFile taskDir,
                                          int fromTaskNumber,
                                          int toSubtaskNumber) {
  String fromSubtaskTestName = getTestFileName(project, fromTaskNumber);
  String toSubtaskTestName = getTestFileName(project, toSubtaskNumber);
  if (fromSubtaskTestName == null || toSubtaskTestName == null) {
    return;
  }
  VirtualFile fromTest = taskDir.findChild(fromSubtaskTestName);
  VirtualFile toTest = taskDir.findChild(toSubtaskTestName);
  if (fromTest == null || toTest == null) {
    return;
  }
  FileEditorManager editorManager = FileEditorManager.getInstance(project);
  if (editorManager.isFileOpen(fromTest)) {
    VirtualFile[] selectedFiles = editorManager.getSelectedFiles();
    boolean isSelected = ArrayUtil.contains(fromTest, selectedFiles);
    editorManager.closeFile(fromTest);
    editorManager.openFile(toTest, isSelected);
    if (!isSelected) {
      for (VirtualFile file : selectedFiles) {
        editorManager.openFile(file, true);
      }
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:28,代码来源:StudySubtaskUtils.java

示例6: testExpandElementWithExitingName

import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
public void testExpandElementWithExitingName() throws InterruptedException {

    final VirtualFile xmlVirtualFile = getContentRoot().findFileByRelativePath("test.xml");
    final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
    FileEditor[] fileEditors = fileEditorManager.openFile(xmlVirtualFile, false);
    final FileEditor fileEditor = fileEditors[0];
    try {
      final StructureViewComponent structureViewComponent =
        (StructureViewComponent)fileEditor.getStructureViewBuilder().createStructureView(fileEditor, myProject);

      final JTree tree = structureViewComponent.getTree();
      PlatformTestUtil.assertTreeEqual(tree, "-test.xml\n" +
                                             " -test\n" +
                                             "  +level1\n" +
                                             "  +level1\n" +
                                             "  +level1\n" +
                                             "  +level1\n");

      tree.expandPath(tree.getPathForRow(3));

      PlatformTestUtil.waitForAlarm(600);


      PlatformTestUtil.assertTreeEqual(tree,
                                       "-test.xml\n" +
                                       " -test\n" +
                                       "  +level1\n" +
                                       "  -level1\n" +
                                       "   +level2\n" +
                                       "  +level1\n" +
                                       "  +level1\n");

      Disposer.dispose(structureViewComponent);
    }
    finally {
      fileEditorManager.closeFile(xmlVirtualFile);
    }

  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:StructureViewUpdatingTest.java

示例7: testJavaClassStructure

import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
public void testJavaClassStructure() throws Exception {
  final PsiClass psiClass = JavaDirectoryService.getInstance().getClasses(getPackageDirectory("com/package1"))[0];
  final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
  final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
  FileEditor[] fileEditors = fileEditorManager.openFile(virtualFile, false);
  final FileEditor fileEditor = fileEditors[0];
  try {
    final StructureViewComponent structureViewComponent =
      (StructureViewComponent)fileEditor.getStructureViewBuilder().createStructureView(fileEditor, myProject);
    final Document document = PsiDocumentManager.getInstance(myProject).getDocument(psiClass.getContainingFile());
    structureViewComponent.setActionActive(InheritedMembersNodeProvider.ID, true);
    PlatformTestUtil.assertTreeEqual(structureViewComponent.getTree(),
                                     "-Class1.java\n" +
                                     " -Class1\n" +
                                     "  getValue(): int\n" +
                                     "  getClass(): Class<? extends Object>\n" +
                                     "  hashCode(): int\n" +
                                     "  equals(Object): boolean\n" +
                                     "  clone(): Object\n" +
                                     "  toString(): String\n" +
                                     "  notify(): void\n" +
                                     "  notifyAll(): void\n" +
                                     "  wait(long): void\n" +
                                     "  wait(long, int): void\n" +
                                     "  wait(): void\n" +
                                     "  finalize(): void\n" +
                                     "  myField1: boolean\n" +
                                     "  myField2: boolean\n");

    new WriteCommandAction.Simple(getProject()) {
      @Override
      protected void run() throws Throwable {
        final int offset = document.getLineStartOffset(5);
        document.insertString(offset, "    boolean myNewField = false;\n");
      }
    }.execute().throwException();


    PsiDocumentManager.getInstance(myProject).commitDocument(document);

    PlatformTestUtil.waitForAlarm(600);

    //TreeUtil.expand(structureViewComponent.getTree(), 3);

    PlatformTestUtil.assertTreeEqual(structureViewComponent.getTree(), "-Class1.java\n" +
                                                                       " -Class1\n" + "  getValue(): int\n" +
                                                                       "  getClass(): Class<? extends Object>\n" +
                                                                       "  hashCode(): int\n" +
                                                                       "  equals(Object): boolean\n" +
                                                                       "  clone(): Object\n" +
                                                                       "  toString(): String\n" +
                                                                       "  notify(): void\n" +
                                                                       "  notifyAll(): void\n" +
                                                                       "  wait(long): void\n" +
                                                                       "  wait(long, int): void\n" +
                                                                       "  wait(): void\n" +
                                                                       "  finalize(): void\n" +
                                                                       "  myField1: boolean\n" +
                                                                       "  myField2: boolean\n" +
                                                                       "  myNewField: boolean = false\n");

    Disposer.dispose(structureViewComponent);

  }
  finally {
    fileEditorManager.closeFile(virtualFile);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:69,代码来源:StructureViewUpdatingTest.java

示例8: testShowClassMembers

import com.intellij.openapi.fileEditor.FileEditorManager; //导入方法依赖的package包/类
public void testShowClassMembers() throws Exception {
  final PsiClass psiClass = JavaDirectoryService.getInstance().getClasses(getPackageDirectory("com/package1"))[0];
  final VirtualFile virtualFile = psiClass.getContainingFile().getVirtualFile();
  final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
  FileEditor[] fileEditors = fileEditorManager.openFile(virtualFile, false);
  final FileEditor fileEditor = fileEditors[0];
  final StructureViewComponent structureViewComponent =
    (StructureViewComponent)fileEditor.getStructureViewBuilder().createStructureView(fileEditor, myProject);
  try {
    PlatformTestUtil.assertTreeEqual(structureViewComponent.getTree(), "-Class2.java\n" +
                                                                       " -Class2\n" +
                                                                       "  +InnerClass1\n" +
                                                                       "  +InnerClass2\n" +
                                                                       "  getValue(): int\n" +
                                                                       "  myField1: boolean\n" +
                                                                       "  myField2: boolean\n" +
                                                                       "  myField3: boolean\n" +
                                                                       "  myField4: boolean\n");

    final PsiField innerClassField = psiClass.getInnerClasses()[0].getFields()[0];

    structureViewComponent.select(innerClassField, true);

    PlatformTestUtil.assertTreeEqual(structureViewComponent.getTree(), "-Class2.java\n" +
                                                                       " -Class2\n" +
                                                                       "  -InnerClass1\n" +
                                                                       "   +InnerClass12\n" +
                                                                       "   myInnerClassField: int\n" +
                                                                       "  +InnerClass2\n" +
                                                                       "  getValue(): int\n" +
                                                                       "  myField1: boolean\n" +
                                                                       "  myField2: boolean\n" +
                                                                       "  myField3: boolean\n" +
                                                                       "  myField4: boolean\n");

    CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
      @Override
      public void run() {

        WriteCommandAction.runWriteCommandAction(null, new Runnable() {
          @Override
          public void run() {
            try {
              innerClassField.delete();
            }
            catch (IncorrectOperationException e) {
              fail(e.getLocalizedMessage());
            }
          }
        });
      }
    }, null, null);

    PlatformTestUtil.waitForAlarm(600);

    PlatformTestUtil.assertTreeEqual(structureViewComponent.getTree(), "-Class2.java\n" +
                                                                       " -Class2\n" +
                                                                       "  -InnerClass1\n" +
                                                                       "   +InnerClass12\n" +
                                                                       "  +InnerClass2\n" +
                                                                       "  getValue(): int\n" +
                                                                       "  myField1: boolean\n" +
                                                                       "  myField2: boolean\n" +
                                                                       "  myField3: boolean\n" +
                                                                       "  myField4: boolean\n");

  }
  finally {
    Disposer.dispose(structureViewComponent);
    fileEditorManager.closeFile(virtualFile);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:73,代码来源:StructureViewUpdatingTest.java


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