Search in sources :

Example 21 with FileEditor

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

the class LineStatusTracker method installNotification.

@Override
@CalledInAwt
protected void installNotification(@NotNull String text) {
    final FileEditor[] editors = myFileEditorManager.getAllEditors(myVirtualFile);
    for (FileEditor editor : editors) {
        JPanel panel = editor.getUserData(PANEL_KEY);
        if (panel == null) {
            final JPanel newPanel = new EditorNotificationPanel().text(text);
            editor.putUserData(PANEL_KEY, newPanel);
            myFileEditorManager.addTopComponent(editor, newPanel);
        }
    }
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) EditorNotificationPanel(com.intellij.ui.EditorNotificationPanel) CalledInAwt(org.jetbrains.annotations.CalledInAwt)

Example 22 with FileEditor

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

the class LineStatusTracker method destroyNotification.

@Override
@CalledInAwt
protected void destroyNotification() {
    final FileEditor[] editors = myFileEditorManager.getEditors(myVirtualFile);
    for (FileEditor editor : editors) {
        final JPanel panel = editor.getUserData(PANEL_KEY);
        if (panel != null) {
            myFileEditorManager.removeTopComponent(editor, panel);
            editor.putUserData(PANEL_KEY, null);
        }
    }
}
Also used : FileEditor(com.intellij.openapi.fileEditor.FileEditor) CalledInAwt(org.jetbrains.annotations.CalledInAwt)

Example 23 with FileEditor

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

the class XVariablesViewBase method registerInlineEvaluator.

private void registerInlineEvaluator(final XStackFrame stackFrame, final XSourcePosition position, final Project project) {
    final VirtualFile file = position.getFile();
    final FileEditor fileEditor = FileEditorManagerEx.getInstanceEx(project).getSelectedEditor(file);
    if (fileEditor instanceof PsiAwareTextEditorImpl) {
        final Editor editor = ((PsiAwareTextEditorImpl) fileEditor).getEditor();
        removeSelectionListener();
        mySelectionListener = new MySelectionListener(editor, stackFrame, project);
        editor.getSelectionModel().addSelectionListener(mySelectionListener);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditor(com.intellij.openapi.fileEditor.FileEditor) Editor(com.intellij.openapi.editor.Editor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) PsiAwareTextEditorImpl(com.intellij.openapi.fileEditor.impl.text.PsiAwareTextEditorImpl)

Example 24 with FileEditor

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

the class StructureViewUpdatingTest method testExpandElementWithExitingName.

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

Example 25 with FileEditor

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

the class StructureViewUpdatingTest method testShowClassMembers.

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, () -> WriteCommandAction.runWriteCommandAction(null, () -> {
            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);
    }
}
Also used : 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) IncorrectOperationException(com.intellij.util.IncorrectOperationException) StructureViewComponent(com.intellij.ide.structureView.newStructureView.StructureViewComponent)

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