Search in sources :

Example 1 with FileEditorManagerImpl

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

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

the class EditorNotificationActions method collectDescriptorsForEditor.

public static void collectDescriptorsForEditor(@NotNull Editor editor, @NotNull List<HighlightInfo.IntentionActionDescriptor> descriptors) {
    Project project = editor.getProject();
    if (project == null)
        return;
    FileEditorManager fileEditorManager = FileEditorManager.getInstance(project);
    if (!(fileEditorManager instanceof FileEditorManagerImpl))
        return;
    TextEditor fileEditor = TextEditorProvider.getInstance().getTextEditor(editor);
    List<JComponent> components = ((FileEditorManagerImpl) fileEditorManager).getTopComponents(fileEditor);
    for (JComponent component : components) {
        if (component instanceof IntentionActionProvider) {
            IntentionActionWithOptions action = ((IntentionActionProvider) component).getIntentionAction();
            if (action != null) {
                descriptors.add(new HighlightInfo.IntentionActionDescriptor(action, action.getOptions(), null));
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) TextEditor(com.intellij.openapi.fileEditor.TextEditor) FileEditorManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl) IntentionActionWithOptions(com.intellij.codeInsight.intention.IntentionActionWithOptions) IntentionActionProvider(com.intellij.codeInsight.intention.IntentionActionProvider)

Example 3 with FileEditorManagerImpl

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

the class ConfigurationMatcher method selectConfigMatch.

@NotNull
private ConfigMatch selectConfigMatch(@NotNull List<ConfigMatch> matches) {
    List<String> deviceIds = myManager.getStateManager().getProjectState().getDeviceIds();
    Map<String, Integer> idRank = Maps.newHashMapWithExpectedSize(deviceIds.size());
    int rank = 0;
    for (String id : deviceIds) {
        idRank.put(id, rank++);
    }
    // API 11-13: look for a x-large device
    Comparator<ConfigMatch> comparator = null;
    IAndroidTarget projectTarget = myManager.getProjectTarget();
    if (projectTarget != null) {
        int apiLevel = projectTarget.getVersion().getFeatureLevel();
        if (apiLevel >= 11 && apiLevel < 14) {
            // TODO: Maybe check the compatible-screen tag in the manifest to figure out
            // what kind of device should be used for display.
            comparator = new TabletConfigComparator(idRank);
        }
    }
    if (comparator == null) {
        // lets look for a high density device
        comparator = new PhoneConfigComparator(idRank);
    }
    Collections.sort(matches, comparator);
    // Look at the currently active editor to see if it's a layout editor, and if so,
    // look up its configuration and if the configuration is in our match list,
    // use it. This means we "preserve" the current configuration when you open
    // new layouts.
    // TODO: This is running too late for the layout preview; the new editor has
    // already taken over so getSelectedTextEditor() returns self. Perhaps we
    // need to fish in the open editors instead.
    // We use FileEditorManagerImpl instead of FileEditorManager to get access to the lock-free version
    // (also used by DebuggerContextUtil) since the normal method only works from the dispatch thread
    // (grabbing a read lock is not enough).
    FileEditorManager editorManager = FileEditorManager.getInstance(myManager.getProject());
    if (editorManager instanceof FileEditorManagerImpl) {
        // not the case under test fixtures apparently
        Editor activeEditor = ((FileEditorManagerImpl) editorManager).getSelectedTextEditor(true);
        if (activeEditor != null) {
            FileDocumentManager documentManager = FileDocumentManager.getInstance();
            VirtualFile file = documentManager.getFile(activeEditor.getDocument());
            if (file != null && !file.equals(myFile) && file.getFileType() == StdFileTypes.XML && ResourceHelper.getFolderType(myFile) == ResourceHelper.getFolderType(file)) {
                Configuration configuration = myManager.getConfiguration(file);
                FolderConfiguration fullConfig = configuration.getFullConfig();
                for (ConfigMatch match : matches) {
                    if (fullConfig.equals(match.testConfig)) {
                        return match;
                    }
                }
            }
        }
    }
    // the list has been sorted so that the first item is the best config
    return matches.get(0);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditorManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) IAndroidTarget(com.android.sdklib.IAndroidTarget) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) Editor(com.intellij.openapi.editor.Editor) NotNull(org.jetbrains.annotations.NotNull)

Example 4 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)

Example 5 with FileEditorManagerImpl

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

the class EditSourceInNewWindowAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    final FileEditorManager manager = FileEditorManager.getInstance(project);
    ((FileEditorManagerImpl) manager).openFileInNewWindow(getVirtualFiles(e)[0]);
}
Also used : Project(com.intellij.openapi.project.Project) FileEditorManager(com.intellij.openapi.fileEditor.FileEditorManager) FileEditorManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl)

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