Search in sources :

Example 6 with FileEditorManagerImpl

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

the class StructureViewWrapperImpl method checkUpdate.

private void checkUpdate() {
    if (myProject.isDisposed())
        return;
    final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    final boolean insideToolwindow = SwingUtilities.isDescendingFrom(myToolWindow.getComponent(), owner);
    if (!myFirstRun && (insideToolwindow || JBPopupFactory.getInstance().isPopupActive())) {
        return;
    }
    final DataContext dataContext = DataManager.getInstance().getDataContext(owner);
    if (dataContext.getData(myKey) == this)
        return;
    if (CommonDataKeys.PROJECT.getData(dataContext) != myProject)
        return;
    final VirtualFile[] files = hasFocus() ? null : CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext);
    if (!myToolWindow.isVisible()) {
        if (files != null && files.length > 0) {
            myFile = files[0];
        }
        return;
    }
    if (files != null && files.length == 1) {
        setFile(files[0]);
    } else if (files != null && files.length > 1) {
        setFile(null);
    } else if (myFirstRun) {
        final FileEditorManagerImpl editorManager = (FileEditorManagerImpl) FileEditorManager.getInstance(myProject);
        final List<Pair<VirtualFile, EditorWindow>> history = editorManager.getSelectionHistory();
        if (!history.isEmpty()) {
            setFile(history.get(0).getFirst());
        }
    }
    myFirstRun = false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FileEditorManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl) StructureViewComponent(com.intellij.ide.structureView.newStructureView.StructureViewComponent) Pair(com.intellij.openapi.util.Pair)

Example 7 with FileEditorManagerImpl

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

the class HeavyFileEditorManagerTestCase method setUp.

public void setUp() throws Exception {
    super.setUp();
    myManager = new FileEditorManagerImpl(getProject(), DockManager.getInstance(getProject()));
    ((ComponentManagerImpl) getProject()).registerComponentInstance(FileEditorManager.class, myManager);
}
Also used : FileEditorManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl) ComponentManagerImpl(com.intellij.openapi.components.impl.ComponentManagerImpl)

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

Example 9 with FileEditorManagerImpl

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

the class FileEditorManagerEx method refreshIcons.

public void refreshIcons() {
    if (this instanceof FileEditorManagerImpl) {
        final FileEditorManagerImpl mgr = (FileEditorManagerImpl) this;
        Set<EditorsSplitters> splitters = mgr.getAllSplitters();
        for (EditorsSplitters each : splitters) {
            for (VirtualFile file : mgr.getOpenFiles()) {
                each.updateFileIcon(file);
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) EditorsSplitters(com.intellij.openapi.fileEditor.impl.EditorsSplitters) FileEditorManagerImpl(com.intellij.openapi.fileEditor.impl.FileEditorManagerImpl)

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

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