Search in sources :

Example 46 with ToolWindow

use of com.intellij.openapi.wm.ToolWindow in project intellij-community by JetBrains.

the class ChooseByNameBase method isDescendingFromTemporarilyFocusableToolWindow.

private boolean isDescendingFromTemporarilyFocusableToolWindow(@Nullable Component component) {
    if (component == null || myProject == null || myProject.isDisposed())
        return false;
    ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(myProject);
    ToolWindow toolWindow = toolWindowManager.getToolWindow(toolWindowManager.getActiveToolWindowId());
    JComponent toolWindowComponent = toolWindow != null ? toolWindow.getComponent() : null;
    return toolWindowComponent != null && toolWindowComponent.getClientProperty(TEMPORARILY_FOCUSABLE_COMPONENT_KEY) != null && SwingUtilities.isDescendingFrom(component, toolWindowComponent);
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager)

Example 47 with ToolWindow

use of com.intellij.openapi.wm.ToolWindow 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)

Example 48 with ToolWindow

use of com.intellij.openapi.wm.ToolWindow in project intellij-community by JetBrains.

the class PsiPackageImplementationHelperImpl method navigate.

@Override
public void navigate(@NotNull final PsiPackage psiPackage, final boolean requestFocus) {
    final Project project = psiPackage.getProject();
    ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.PROJECT_VIEW);
    window.activate(null);
    window.getActivation().doWhenDone(() -> {
        final ProjectView projectView = ProjectView.getInstance(project);
        PsiDirectory[] directories = suggestMostAppropriateDirectories(psiPackage);
        if (directories.length == 0)
            return;
        projectView.select(directories[0], directories[0].getVirtualFile(), requestFocus);
    });
}
Also used : Project(com.intellij.openapi.project.Project) ToolWindow(com.intellij.openapi.wm.ToolWindow) ProjectView(com.intellij.ide.projectView.ProjectView)

Example 49 with ToolWindow

use of com.intellij.openapi.wm.ToolWindow in project intellij-community by JetBrains.

the class PredefinedSearchScopeProviderImpl method addHierarchyScope.

private static void addHierarchyScope(@NotNull Project project, Collection<SearchScope> result) {
    final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.HIERARCHY);
    if (toolWindow == null) {
        return;
    }
    final ContentManager contentManager = toolWindow.getContentManager();
    final Content content = contentManager.getSelectedContent();
    if (content == null) {
        return;
    }
    final String name = content.getDisplayName();
    final JComponent component = content.getComponent();
    if (!(component instanceof HierarchyBrowserBase)) {
        return;
    }
    final HierarchyBrowserBase hierarchyBrowserBase = (HierarchyBrowserBase) component;
    final PsiElement[] elements = hierarchyBrowserBase.getAvailableElements();
    if (elements.length > 0) {
        result.add(new LocalSearchScope(elements, "Hierarchy '" + name + "' (visible nodes only)"));
    }
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) ContentManager(com.intellij.ui.content.ContentManager) HierarchyBrowserBase(com.intellij.ide.hierarchy.HierarchyBrowserBase) PsiElement(com.intellij.psi.PsiElement)

Example 50 with ToolWindow

use of com.intellij.openapi.wm.ToolWindow in project intellij-code-outline by sitano.

the class CodeOutlinePlugin method regForProject.

/**
     * Creates a code outline tool window for the given project.
     *
     * @param project the project to register
     */
private synchronized void regForProject(final Project project) {
    final CodeOutlineToolWindow window = new CodeOutlineToolWindow(this, project);
    ToolWindowManager twm = ToolWindowManager.getInstance(project);
    ToolWindowManagerEx twmEx = (ToolWindowManagerEx) twm;
    ToolWindow tw = twm.registerToolWindow(TOOLWINDOW_ID, false, ToolWindowAnchor.RIGHT);
    ContentFactory contentFactory = ServiceManager.getService(ContentFactory.class);
    Content content = contentFactory.createContent(window, "", false);
    tw.getContentManager().addContent(content);
    tw.getContentManager().setSelectedContent(content, false);
    twmEx.addToolWindowManagerListener(window.getToolWindowManagerListener());
}
Also used : ToolWindow(com.intellij.openapi.wm.ToolWindow) Content(com.intellij.ui.content.Content) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ContentFactory(com.intellij.ui.content.ContentFactory) ToolWindowManagerEx(com.intellij.openapi.wm.ex.ToolWindowManagerEx)

Aggregations

ToolWindow (com.intellij.openapi.wm.ToolWindow)124 Content (com.intellij.ui.content.Content)37 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)34 Project (com.intellij.openapi.project.Project)21 ContentManager (com.intellij.ui.content.ContentManager)14 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)13 Nullable (org.jetbrains.annotations.Nullable)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 ConsoleView (com.intellij.execution.ui.ConsoleView)5 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)5 NotNull (org.jetbrains.annotations.NotNull)5 RunContentManager (com.intellij.execution.ui.RunContentManager)4 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)3 ProcessEvent (com.intellij.execution.process.ProcessEvent)3 RunContentDescriptor (com.intellij.execution.ui.RunContentDescriptor)3 ProjectView (com.intellij.ide.projectView.ProjectView)3 Presentation (com.intellij.openapi.actionSystem.Presentation)3 DumbAwareRunnable (com.intellij.openapi.project.DumbAwareRunnable)3 ChangesViewContentManager (com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager)3 ToolWindowEP (com.intellij.openapi.wm.ToolWindowEP)3