Search in sources :

Example 26 with FileEditor

use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.

the class ProjectTreeBuilderTest method testShowClassMembers.

public void testShowClassMembers() throws IncorrectOperationException, IOException {
    myStructure.setShowMembers(true);
    useStandardProviders();
    final PsiClass[] classes = JavaDirectoryService.getInstance().getClasses(getPackageDirectory());
    sortClassesByName(classes);
    PsiClass aClass = classes[1];
    PsiClass innerClass1 = aClass.getInnerClasses()[0];
    PsiClass innerClass12 = innerClass1.getInnerClasses()[0];
    PsiClass innerClass13 = innerClass12.getInnerClasses()[0];
    PsiClass innerClass14 = innerClass13.getInnerClasses()[0];
    PsiClass innerClass15 = innerClass14.getInnerClasses()[0];
    PsiClass innerClass2 = aClass.getInnerClasses()[1];
    PsiClass innerClass21 = innerClass2.getInnerClasses()[0];
    PsiClass innerClass23 = innerClass21.getInnerClasses()[0];
    PsiClass innerClass24 = innerClass23.getInnerClasses()[0];
    PsiField innerClass1Field = innerClass14.getFields()[0];
    PsiField innerClass2Field = innerClass24.getFields()[0];
    final AbstractProjectViewPSIPane pane = myStructure.createPane();
    myStructure.checkNavigateFromSourceBehaviour(innerClass2Field, innerClass2Field.getContainingFile().getVirtualFile(), pane);
    IdeaTestUtil.assertTreeEqual(pane.getTree(), "-Project\n" + " -PsiDirectory: showClassMembers\n" + "  -PsiDirectory: src\n" + "   -PsiDirectory: com\n" + "    -PsiDirectory: package1\n" + "     +Class1\n" + "     -Class2\n" + "      +InnerClass1\n" + "      -InnerClass2\n" + "       -InnerClass22\n" + "        -InnerClass23\n" + "         -InnerClass24\n" + "          +InnerClass25\n" + "          myFieldToSelect:int\n" + "         myInnerClassField:int\n" + "        myInnerClassField:int\n" + "       myInnerClassField:int\n" + "      getValue():int\n" + "      myField1:boolean\n" + "      myField2:boolean\n" + "      myField3:boolean\n" + "      myField4:boolean\n" + getRootFiles() + " +External Libraries\n");
    assertFalse(ProjectViewTestUtil.isExpanded(innerClass15.getFields()[0], pane));
    assertFalse(ProjectViewTestUtil.isExpanded(innerClass1Field, pane));
    assertTrue(ProjectViewTestUtil.isExpanded(innerClass2Field, pane));
    VirtualFile virtualFile = aClass.getContainingFile().getVirtualFile();
    FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
    FileEditor[] fileEditors = fileEditorManager.openFile(virtualFile, false);
    StructureViewComponent structureViewComponent2 = null;
    StructureViewComponent structureViewComponent = null;
    try {
        structureViewComponent = (StructureViewComponent) fileEditors[0].getStructureViewBuilder().createStructureView(fileEditors[0], myProject);
        TreeUtil.collapseAll(structureViewComponent.getTree(), -1);
        structureViewComponent.select(innerClass2Field, true);
        String expected = "-Class2.java\n" + " -Class2\n" + "  +InnerClass1\n" + "  -InnerClass2\n" + "   -InnerClass22\n" + "    -InnerClass23\n" + "     -InnerClass24\n" + "      +InnerClass25\n" + "      myFieldToSelect: int\n" + "     myInnerClassField: int\n" + "    myInnerClassField: int\n" + "   myInnerClassField: int\n" + "  getValue(): int\n" + "  myField1: boolean\n" + "  myField2: boolean\n" + "  myField3: boolean\n" + "  myField4: boolean\n";
        IdeaTestUtil.assertTreeEqual(structureViewComponent.getTree(), expected);
        Disposer.dispose(structureViewComponent);
        final FileEditor fileEditor = fileEditors[0];
        structureViewComponent2 = (StructureViewComponent) fileEditor.getStructureViewBuilder().createStructureView(fileEditor, myProject);
        structureViewComponent2.setActionActive(JavaInheritedMembersNodeProvider.ID, false);
        IdeaTestUtil.assertTreeEqual(structureViewComponent2.getTree(), expected);
    } finally {
        fileEditorManager.closeFile(virtualFile);
        if (structureViewComponent2 != null) {
            Disposer.dispose(structureViewComponent2);
        }
    }
}
Also used : AbstractProjectViewPSIPane(com.intellij.ide.projectView.impl.AbstractProjectViewPSIPane) VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FileEditor(com.intellij.openapi.fileEditor.FileEditor) PsiField(com.intellij.psi.PsiField) PsiClass(com.intellij.psi.PsiClass) StructureViewComponent(com.intellij.ide.structureView.newStructureView.StructureViewComponent)

Example 27 with FileEditor

use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.

the class LoadProjectTest method testLoadProject.

public void testLoadProject() throws Exception {
    VirtualFile src = ProjectRootManager.getInstance(getProject()).getContentSourceRoots()[0];
    VirtualFile a = src.findFileByRelativePath("/x/AClass.java");
    assertNotNull(a);
    PsiFile fileA = getPsiManager().findFile(a);
    assertNotNull(fileA);
    fileA.navigate(true);
    Editor editorA = FileEditorManager.getInstance(getProject()).openTextEditor(new OpenFileDescriptor(getProject(), a), true);
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    assertNotNull(editorA);
    CodeInsightTestFixtureImpl.instantiateAndRun(fileA, editorA, new int[] { Pass.EXTERNAL_TOOLS }, false);
    VirtualFile b = src.findFileByRelativePath("/x/BClass.java");
    assertNotNull(b);
    PsiFile fileB = getPsiManager().findFile(b);
    assertNotNull(fileB);
    fileB.navigate(true);
    Editor editorB = FileEditorManager.getInstance(getProject()).openTextEditor(new OpenFileDescriptor(getProject(), b), true);
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    assertNotNull(editorB);
    CodeInsightTestFixtureImpl.instantiateAndRun(fileB, editorB, new int[] { Pass.EXTERNAL_TOOLS }, false);
    FileEditor[] allEditors = FileEditorManager.getInstance(getProject()).getAllEditors();
    assertEquals(2, allEditors.length);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditor(com.intellij.openapi.fileEditor.FileEditor) PsiFile(com.intellij.psi.PsiFile) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor)

Example 28 with FileEditor

use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.

the class JavaTreeStructureTest method dotest.

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);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FileEditor(com.intellij.openapi.fileEditor.FileEditor) PsiClass(com.intellij.psi.PsiClass) StructureViewComponent(com.intellij.ide.structureView.newStructureView.StructureViewComponent)

Example 29 with FileEditor

use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.

the class CoverageDataManagerImpl method applyInformationToEditor.

private void applyInformationToEditor(FileEditor[] editors, final VirtualFile file) {
    final PsiFile psiFile = doInReadActionIfProjectOpen(() -> PsiManager.getInstance(myProject).findFile(file));
    if (psiFile != null && myCurrentSuitesBundle != null && psiFile.isPhysical()) {
        final CoverageEngine engine = myCurrentSuitesBundle.getCoverageEngine();
        if (!engine.coverageEditorHighlightingApplicableTo(psiFile)) {
            return;
        }
        for (FileEditor editor : editors) {
            if (editor instanceof TextEditor) {
                final Editor textEditor = ((TextEditor) editor).getEditor();
                SrcFileAnnotator annotator;
                synchronized (ANNOTATORS_LOCK) {
                    annotator = myAnnotators.remove(textEditor);
                }
                if (annotator != null) {
                    Disposer.dispose(annotator);
                }
                break;
            }
        }
        for (FileEditor editor : editors) {
            if (editor instanceof TextEditor) {
                final Editor textEditor = ((TextEditor) editor).getEditor();
                SrcFileAnnotator annotator = getAnnotator(textEditor);
                if (annotator == null) {
                    annotator = new SrcFileAnnotator(psiFile, textEditor);
                    synchronized (ANNOTATORS_LOCK) {
                        myAnnotators.put(textEditor, annotator);
                    }
                }
                if (myCurrentSuitesBundle != null && engine.acceptedByFilters(psiFile, myCurrentSuitesBundle)) {
                    annotator.showCoverageInformation(myCurrentSuitesBundle);
                }
            }
        }
    }
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) TextEditor(com.intellij.openapi.fileEditor.TextEditor) PsiFile(com.intellij.psi.PsiFile) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) Editor(com.intellij.openapi.editor.Editor)

Example 30 with FileEditor

use of com.intellij.openapi.fileEditor.FileEditor in project intellij-community by JetBrains.

the class SrcFileAnnotator method showEditorWarningMessage.

private void showEditorWarningMessage(final String message) {
    Editor textEditor = myEditor;
    PsiFile file = myFile;
    ApplicationManager.getApplication().invokeLater(() -> {
        if (textEditor == null || textEditor.isDisposed() || file == null)
            return;
        final FileEditorManager fileEditorManager = FileEditorManager.getInstance(myProject);
        final VirtualFile vFile = file.getVirtualFile();
        assert vFile != null;
        Map<FileEditor, EditorNotificationPanel> map = file.getCopyableUserData(NOTIFICATION_PANELS);
        if (map == null) {
            map = new HashMap<>();
            file.putCopyableUserData(NOTIFICATION_PANELS, map);
        }
        final FileEditor[] editors = fileEditorManager.getAllEditors(vFile);
        for (final FileEditor editor : editors) {
            if (isCurrentEditor(editor)) {
                final EditorNotificationPanel panel = new EditorNotificationPanel() {

                    {
                        myLabel.setIcon(AllIcons.General.ExclMark);
                        myLabel.setText(message);
                    }
                };
                panel.createActionLabel("Close", () -> fileEditorManager.removeTopComponent(editor, panel));
                map.put(editor, panel);
                fileEditorManager.addTopComponent(editor, panel);
                break;
            }
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FileEditor(com.intellij.openapi.fileEditor.FileEditor) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) PsiFile(com.intellij.psi.PsiFile) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) Editor(com.intellij.openapi.editor.Editor)

Aggregations

FileEditor (com.intellij.openapi.fileEditor.FileEditor)157 VirtualFile (com.intellij.openapi.vfs.VirtualFile)62 TextEditor (com.intellij.openapi.fileEditor.TextEditor)59 Editor (com.intellij.openapi.editor.Editor)43 Project (com.intellij.openapi.project.Project)40 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)37 Nullable (org.jetbrains.annotations.Nullable)21 DataContext (com.intellij.openapi.actionSystem.DataContext)20 PsiFile (com.intellij.psi.PsiFile)19 Document (com.intellij.openapi.editor.Document)15 NotNull (org.jetbrains.annotations.NotNull)14 IpnbFileEditor (org.jetbrains.plugins.ipnb.editor.IpnbFileEditor)14 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)10 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)9 IpnbFilePanel (org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel)8 StructureViewBuilder (com.intellij.ide.structureView.StructureViewBuilder)7 StructureViewComponent (com.intellij.ide.structureView.newStructureView.StructureViewComponent)6 BlobExplorerFileEditor (com.microsoft.intellij.helpers.storage.BlobExplorerFileEditor)6 QueueFileEditor (com.microsoft.intellij.helpers.storage.QueueFileEditor)6 TableFileEditor (com.microsoft.intellij.helpers.storage.TableFileEditor)6