Search in sources :

Example 11 with FileEditorManagerImpl

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

the class HprofEditorFixture method findByFileName.

@NotNull
public static HprofEditorFixture findByFileName(@NotNull Robot robot, @NotNull final IdeFrameFixture frame, @NotNull final String hprofFileName) {
    HprofEditor hprofEditor = GuiQuery.getNonNull(() -> {
        FileEditor[] openEditors = null;
        FileEditorManagerImpl fileEditorManager = (FileEditorManagerImpl) FileEditorManager.getInstance(frame.getProject());
        for (EditorsSplitters splitters : fileEditorManager.getAllSplitters()) {
            for (EditorWindow window : splitters.getWindows()) {
                for (EditorWithProviderComposite editorWithProviderComposite : window.getEditors()) {
                    if (editorWithProviderComposite.getFile().getName().endsWith(hprofFileName)) {
                        if (openEditors != null) {
                            throw new ComponentLookupException(String.format("More than one Hprof editor for file '%s' found", hprofFileName));
                        }
                        openEditors = editorWithProviderComposite.getEditors();
                    }
                }
            }
        }
        if (openEditors == null) {
            throw new ComponentLookupException(String.format("Cannot find any open Hprof editors for file '%s'", hprofFileName));
        }
        HprofEditor targetEditor = null;
        for (FileEditor editor : openEditors) {
            if (editor instanceof HprofEditor) {
                if (targetEditor != null) {
                    throw new ComponentLookupException(String.format("More than one Hprof editor pane for file '%s' found", hprofFileName));
                } else {
                    targetEditor = (HprofEditor) editor;
                }
            }
        }
        return targetEditor;
    });
    return new HprofEditorFixture(robot, frame, hprofEditor);
}
Also used : EditorWithProviderComposite(com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite) HprofEditor(com.android.tools.idea.editors.hprof.HprofEditor) FileEditor(com.intellij.openapi.fileEditor.FileEditor) EditorsSplitters(com.intellij.openapi.fileEditor.impl.EditorsSplitters) FileEditorManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl) ComponentLookupException(org.fest.swing.exception.ComponentLookupException) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FileEditorManagerImpl (com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl)11 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 EditorsSplitters (com.intellij.openapi.fileEditor.impl.EditorsSplitters)3 Project (com.intellij.openapi.project.Project)3 Editor (com.intellij.openapi.editor.Editor)2 FileEditor (com.intellij.openapi.fileEditor.FileEditor)2 XSourcePosition (com.intellij.xdebugger.XSourcePosition)2 NotNull (org.jetbrains.annotations.NotNull)2 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 HprofEditor (com.android.tools.idea.editors.hprof.HprofEditor)1 IntentionActionProvider (com.intellij.codeInsight.intention.IntentionActionProvider)1 IntentionActionWithOptions (com.intellij.codeInsight.intention.IntentionActionWithOptions)1 OpenFileHyperlinkInfo (com.intellij.execution.filters.OpenFileHyperlinkInfo)1 StructureViewComponent (com.intellij.ide.structureView.newStructureView.StructureViewComponent)1 ComponentManagerImpl (com.intellij.openapi.components.impl.ComponentManagerImpl)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 TextEditor (com.intellij.openapi.fileEditor.TextEditor)1 EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)1