Search in sources :

Example 1 with TwoPaneIdeView

use of com.intellij.ide.TwoPaneIdeView in project intellij-community by JetBrains.

the class CopyHandler method updateSelectionInActiveProjectView.

static void updateSelectionInActiveProjectView(PsiElement newElement, Project project, boolean selectInActivePanel) {
    String id = ToolWindowManager.getInstance(project).getActiveToolWindowId();
    if (id != null) {
        ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(id);
        Content selectedContent = window.getContentManager().getSelectedContent();
        if (selectedContent != null) {
            JComponent component = selectedContent.getComponent();
            if (component instanceof TwoPaneIdeView) {
                ((TwoPaneIdeView) component).selectElement(newElement, selectInActivePanel);
                return;
            }
        }
    }
    if (ToolWindowId.PROJECT_VIEW.equals(id)) {
        ProjectView.getInstance(project).selectPsiElement(newElement, true);
    } else if (ToolWindowId.STRUCTURE_VIEW.equals(id)) {
        VirtualFile virtualFile = newElement.getContainingFile().getVirtualFile();
        FileEditor editor = FileEditorManager.getInstance(newElement.getProject()).getSelectedEditor(virtualFile);
        StructureViewFactoryEx.getInstanceEx(project).getStructureViewWrapper().selectCurrentElement(editor, virtualFile, true);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ToolWindow(com.intellij.openapi.wm.ToolWindow) FileEditor(com.intellij.openapi.fileEditor.FileEditor) Content(com.intellij.ui.content.Content) TwoPaneIdeView(com.intellij.ide.TwoPaneIdeView)

Aggregations

TwoPaneIdeView (com.intellij.ide.TwoPaneIdeView)1 FileEditor (com.intellij.openapi.fileEditor.FileEditor)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 ToolWindow (com.intellij.openapi.wm.ToolWindow)1 Content (com.intellij.ui.content.Content)1