Search in sources :

Example 6 with FileEditorManagerEvent

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

the class LineEndingsManager method updateStatusBar.

private void updateStatusBar() {
    ApplicationManager.getApplication().invokeLater(() -> {
        IdeFrame frame = WindowManager.getInstance().getIdeFrame(myProject);
        StatusBar statusBar = frame != null ? frame.getStatusBar() : null;
        StatusBarWidget widget = statusBar != null ? statusBar.getWidget("LineSeparator") : null;
        if (widget instanceof LineSeparatorPanel) {
            FileEditorManagerEvent event = new FileEditorManagerEvent(FileEditorManager.getInstance(myProject), null, null, null, null);
            ((LineSeparatorPanel) widget).selectionChanged(event);
        }
    });
}
Also used : StatusBarWidget(com.intellij.openapi.wm.StatusBarWidget) LineSeparatorPanel(com.intellij.openapi.wm.impl.status.LineSeparatorPanel) FileEditorManagerEvent(com.intellij.openapi.fileEditor.FileEditorManagerEvent) IdeFrame(com.intellij.openapi.wm.IdeFrame) StatusBar(com.intellij.openapi.wm.StatusBar)

Example 7 with FileEditorManagerEvent

use of com.intellij.openapi.fileEditor.FileEditorManagerEvent in project android by JetBrains.

the class FloatingToolWindowManagerTest method testSwitchingBetweenTwoEditorsWithDifferentFloatingToolWindows.

@Test
@SuppressWarnings("unchecked")
public void testSwitchingBetweenTwoEditorsWithDifferentFloatingToolWindows() {
    when(myKeyboardFocusManager.getFocusOwner()).thenReturn(myWorkBench1, myWorkBench2);
    myListener.fileOpened(myEditorManager, myVirtualFile);
    verify(myFloatingToolWindow1).show(eq(myAttachedToolWindow1));
    myListener.fileOpened(myEditorManager, myVirtualFile);
    verify(myFloatingToolWindow1).hide();
    verify(myFloatingToolWindow2).show(eq(myAttachedToolWindow2));
    FileEditorManagerEvent event1 = new FileEditorManagerEvent(myEditorManager, null, null, null, myFileEditor1);
    FileEditorManagerEvent event2 = new FileEditorManagerEvent(myEditorManager, null, null, null, myFileEditor2);
    myListener.selectionChanged(event1);
    verify(myFloatingToolWindow2).hide();
    verify(myFloatingToolWindow1, times(2)).show(eq(myAttachedToolWindow1));
    myListener.selectionChanged(event2);
    verify(myFloatingToolWindow1, times(2)).hide();
    verify(myFloatingToolWindow2, times(2)).show(eq(myAttachedToolWindow2));
    // Now unregister one of them:
    myManager.unregister(myFileEditor1);
    myListener.selectionChanged(event1);
    verify(myFloatingToolWindow1, times(3)).hide();
    verify(myFloatingToolWindow2, times(2)).hide();
}
Also used : FileEditorManagerEvent(com.intellij.openapi.fileEditor.FileEditorManagerEvent) Test(org.junit.Test)

Example 8 with FileEditorManagerEvent

use of com.intellij.openapi.fileEditor.FileEditorManagerEvent in project intellij-plugins by JetBrains.

the class DartServerHighlightingTest method testServerDataLifecycle.

public void testServerDataLifecycle() throws Exception {
    myFixture.configureByText("firstFile.dart", "class Foo { toString(){ return super.toString(); } }");
    final VirtualFile firstFile = getFile().getVirtualFile();
    final VirtualFile secondFile = myFixture.addFileToProject("secondFile.dart", "class Bar { toString(){ return super.toString(); } }").getVirtualFile();
    final DartAnalysisServerService service = DartAnalysisServerService.getInstance(getProject());
    myFixture.doHighlighting();
    assertNotEmpty(service.getHighlight(firstFile));
    assertNotEmpty(service.getNavigation(firstFile));
    assertNotEmpty(service.getOverrideMembers(firstFile));
    myFixture.openFileInEditor(secondFile);
    // TestFileEditorManager doesn't notify listeners itself;
    // we need any notification to trigger DartAnalysisserverService.updateVisibleFiles()
    final FileEditorManagerEvent event = new FileEditorManagerEvent(FileEditorManager.getInstance(getProject()), firstFile, null, secondFile, null);
    getProject().getMessageBus().syncPublisher(FileEditorManagerListener.FILE_EDITOR_MANAGER).selectionChanged(event);
    myFixture.doHighlighting();
    assertNotEmpty(service.getHighlight(firstFile));
    assertNotEmpty(service.getNavigation(firstFile));
    assertNotEmpty(service.getOverrideMembers(firstFile));
    assertNotEmpty(service.getHighlight(secondFile));
    assertNotEmpty(service.getNavigation(secondFile));
    assertNotEmpty(service.getOverrideMembers(secondFile));
    getProject().getMessageBus().syncPublisher(FileEditorManagerListener.FILE_EDITOR_MANAGER).fileClosed(FileEditorManager.getInstance(getProject()), firstFile);
    assertNotEmpty(service.getHighlight(firstFile));
    assertNotEmpty(service.getNavigation(firstFile));
    assertNotEmpty(service.getOverrideMembers(firstFile));
    assertNotEmpty(service.getHighlight(secondFile));
    assertNotEmpty(service.getNavigation(secondFile));
    assertNotEmpty(service.getOverrideMembers(secondFile));
    FileEditorManager.getInstance(getProject()).closeFile(firstFile);
    getProject().getMessageBus().syncPublisher(FileEditorManagerListener.FILE_EDITOR_MANAGER).fileClosed(FileEditorManager.getInstance(getProject()), firstFile);
    assertEmpty(service.getHighlight(firstFile));
    assertEmpty(service.getNavigation(firstFile));
    assertEmpty(service.getOverrideMembers(firstFile));
    assertNotEmpty(service.getHighlight(secondFile));
    assertNotEmpty(service.getNavigation(secondFile));
    assertNotEmpty(service.getOverrideMembers(secondFile));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DartAnalysisServerService(com.jetbrains.lang.dart.analyzer.DartAnalysisServerService) FileEditorManagerEvent(com.intellij.openapi.fileEditor.FileEditorManagerEvent)

Example 9 with FileEditorManagerEvent

use of com.intellij.openapi.fileEditor.FileEditorManagerEvent in project intellij-plugins by StepicOrg.

the class StudyBasePluginConfigurator method getFileEditorManagerListener.

@NotNull
@Override
public FileEditorManagerListener getFileEditorManagerListener(@NotNull Project project) {
    return new FileEditorManagerAdapter() {

        @Override
        public void selectionChanged(@NotNull FileEditorManagerEvent event) {
            VirtualFile file = event.getNewFile();
            if (file == null) {
                return;
            }
            StudyNode stepNode = StudyUtils.getStudyNode(project, file);
            if (stepNode != null) {
                StepikProjectManager.setSelected(project, stepNode);
            }
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditorManagerAdapter(com.intellij.openapi.fileEditor.FileEditorManagerAdapter) FileEditorManagerEvent(com.intellij.openapi.fileEditor.FileEditorManagerEvent) NotNull(org.jetbrains.annotations.NotNull) StudyNode(org.stepik.core.courseFormat.StudyNode) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FileEditorManagerEvent (com.intellij.openapi.fileEditor.FileEditorManagerEvent)9 FileEditorManagerListener (com.intellij.openapi.fileEditor.FileEditorManagerListener)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 NotNull (org.jetbrains.annotations.NotNull)3 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)2 Disposable (com.intellij.openapi.Disposable)1 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1 SelectionModel (com.intellij.openapi.editor.SelectionModel)1 EditorEventMulticasterEx (com.intellij.openapi.editor.ex.EditorEventMulticasterEx)1 FocusChangeListener (com.intellij.openapi.editor.ex.FocusChangeListener)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManagerAdapter (com.intellij.openapi.fileEditor.FileEditorManagerAdapter)1 TextRange (com.intellij.openapi.util.TextRange)1 IdeFrame (com.intellij.openapi.wm.IdeFrame)1 StatusBar (com.intellij.openapi.wm.StatusBar)1 StatusBarWidget (com.intellij.openapi.wm.StatusBarWidget)1 LineSeparatorPanel (com.intellij.openapi.wm.impl.status.LineSeparatorPanel)1 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)1 Task (com.jetbrains.edu.learning.courseFormat.Task)1