Search in sources :

Example 6 with EditorWithProviderComposite

use of com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite 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

EditorWithProviderComposite (com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite)6 EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)4 Nullable (org.jetbrains.annotations.Nullable)3 EditorsSplitters (com.intellij.openapi.fileEditor.impl.EditorsSplitters)2 HprofEditor (com.android.tools.idea.editors.hprof.HprofEditor)1 Document (com.intellij.openapi.editor.Document)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManagerEx (com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)1 DockableEditorTabbedContainer (com.intellij.openapi.fileEditor.impl.DockableEditorTabbedContainer)1 EditorComposite (com.intellij.openapi.fileEditor.impl.EditorComposite)1 FileEditorManagerImpl (com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl)1 Pair (com.intellij.openapi.util.Pair)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 DockContainer (com.intellij.ui.docking.DockContainer)1 HashSet (com.intellij.util.containers.HashSet)1 ComponentLookupException (org.fest.swing.exception.ComponentLookupException)1 NotNull (org.jetbrains.annotations.NotNull)1