Search in sources :

Example 1 with EditorsSplitters

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

the class ProjectImpl method distributeProgress.

private void distributeProgress() {
    ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    if (indicator == null)
        return;
    ModuleManager moduleManager = ModuleManager.getInstance(this);
    if (!(moduleManager instanceof ModuleManagerImpl)) {
        return;
    }
    double toDistribute = 1 - indicator.getFraction();
    int modulesCount = ((ModuleManagerImpl) moduleManager).getModulePathsCount();
    EditorsSplitters splitters = ((FileEditorManagerImpl) FileEditorManager.getInstance(this)).getMainSplitters();
    int editors = splitters.getEditorsCount();
    double modulesPart = ourClassesAreLoaded || editors == 0 ? toDistribute : toDistribute * 0.5;
    if (modulesCount != 0) {
        double step = modulesPart / modulesCount;
        ((ModuleManagerImpl) moduleManager).setProgressStep(step);
    }
    if (editors != 0) {
        splitters.setProgressStep(toDistribute - modulesPart / editors);
    }
}
Also used : ModuleManagerImpl(com.intellij.openapi.module.impl.ModuleManagerImpl) EditorsSplitters(com.intellij.openapi.fileEditor.impl.EditorsSplitters) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) FileEditorManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl) ModuleManager(com.intellij.openapi.module.ModuleManager)

Example 2 with EditorsSplitters

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

the class StatusBarUtil method getCurrentFileEditor.

/**
   * Finds the current file editor.
   */
@Nullable
public static FileEditor getCurrentFileEditor(@NotNull Project project, @Nullable StatusBar statusBar) {
    if (statusBar == null) {
        return null;
    }
    DockContainer c = DockManager.getInstance(project).getContainerFor(statusBar.getComponent());
    EditorsSplitters splitters = null;
    if (c instanceof DockableEditorTabbedContainer) {
        splitters = ((DockableEditorTabbedContainer) c).getSplitters();
    }
    if (splitters != null && splitters.getCurrentWindow() != null) {
        EditorWithProviderComposite editor = splitters.getCurrentWindow().getSelectedEditor();
        if (editor != null) {
            return editor.getSelectedEditorWithProvider().getFirst();
        }
    }
    return null;
}
Also used : EditorWithProviderComposite(com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite) DockableEditorTabbedContainer(com.intellij.openapi.fileEditor.impl.DockableEditorTabbedContainer) DockContainer(com.intellij.ui.docking.DockContainer) EditorsSplitters(com.intellij.openapi.fileEditor.impl.EditorsSplitters) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with EditorsSplitters

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

the class ToggleReadOnlyAttributePanel method getCurrentFile.

@Nullable
private VirtualFile getCurrentFile() {
    final Project project = getProject();
    if (project == null)
        return null;
    EditorsSplitters splitters = FileEditorManagerEx.getInstanceEx(project).getSplittersFor(myStatusBar.getComponent());
    return splitters.getCurrentFile();
}
Also used : Project(com.intellij.openapi.project.Project) EditorsSplitters(com.intellij.openapi.fileEditor.impl.EditorsSplitters) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with EditorsSplitters

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

the class ToolWindowManagerImpl method getSplittersToFocus.

private EditorsSplitters getSplittersToFocus() {
    Window activeWindow = myWindowManager.getMostRecentFocusedWindow();
    if (activeWindow instanceof FloatingDecorator) {
        IdeFocusManager ideFocusManager = IdeFocusManager.findInstanceByComponent(activeWindow);
        IdeFrame lastFocusedFrame = ideFocusManager.getLastFocusedFrame();
        JComponent frameComponent = lastFocusedFrame != null ? lastFocusedFrame.getComponent() : null;
        Window lastFocusedWindow = frameComponent != null ? SwingUtilities.getWindowAncestor(frameComponent) : null;
        activeWindow = ObjectUtils.notNull(lastFocusedWindow, activeWindow);
    }
    FileEditorManagerEx fem = FileEditorManagerEx.getInstanceEx(myProject);
    EditorsSplitters splitters = activeWindow != null ? fem.getSplittersFor(activeWindow) : null;
    return splitters != null ? splitters : fem.getSplitters();
}
Also used : EditorsSplitters(com.intellij.openapi.fileEditor.impl.EditorsSplitters) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)

Example 5 with EditorsSplitters

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

EditorsSplitters (com.intellij.openapi.fileEditor.impl.EditorsSplitters)8 FileEditorManagerImpl (com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl)3 EditorWithProviderComposite (com.intellij.openapi.fileEditor.impl.EditorWithProviderComposite)2 Nullable (org.jetbrains.annotations.Nullable)2 HprofEditor (com.android.tools.idea.editors.hprof.HprofEditor)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 FileEditorManagerEx (com.intellij.openapi.fileEditor.ex.FileEditorManagerEx)1 DockableEditorTabbedContainer (com.intellij.openapi.fileEditor.impl.DockableEditorTabbedContainer)1 EditorWindow (com.intellij.openapi.fileEditor.impl.EditorWindow)1 ModuleManager (com.intellij.openapi.module.ModuleManager)1 ModuleManagerImpl (com.intellij.openapi.module.impl.ModuleManagerImpl)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 DockContainer (com.intellij.ui.docking.DockContainer)1 ComponentLookupException (org.fest.swing.exception.ComponentLookupException)1 NotNull (org.jetbrains.annotations.NotNull)1