Search in sources :

Example 11 with ContentManager

use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.

the class AbstractExternalSystemToolWindowFactory method createToolWindowContent.

@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {
    toolWindow.setTitle(myExternalSystemId.getReadableName());
    ContentManager contentManager = toolWindow.getContentManager();
    final ExternalProjectsViewImpl projectsView = new ExternalProjectsViewImpl(project, (ToolWindowEx) toolWindow, myExternalSystemId);
    ExternalProjectsManager.getInstance(project).registerView(projectsView);
    ContentImpl tasksContent = new ContentImpl(projectsView, ExternalSystemBundle.message("tool.window.title.projects"), true);
    contentManager.addContent(tasksContent);
}
Also used : ContentManager(com.intellij.ui.content.ContentManager) ExternalProjectsViewImpl(com.intellij.openapi.externalSystem.view.ExternalProjectsViewImpl) ContentImpl(com.intellij.ui.content.impl.ContentImpl)

Example 12 with ContentManager

use of com.intellij.ui.content.ContentManager 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 13 with ContentManager

use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.

the class TabNavigationActionBase method update.

public void update(AnActionEvent event) {
    Presentation presentation = event.getPresentation();
    DataContext dataContext = event.getDataContext();
    Project project = CommonDataKeys.PROJECT.getData(dataContext);
    presentation.setEnabled(false);
    if (project == null || project.isDisposed()) {
        return;
    }
    final ToolWindowManager windowManager = ToolWindowManager.getInstance(project);
    if (windowManager.isEditorComponentActive()) {
        final FileEditorManagerEx editorManager = FileEditorManagerEx.getInstanceEx(project);
        EditorWindow currentWindow = EditorWindow.DATA_KEY.getData(dataContext);
        if (currentWindow == null) {
            editorManager.getCurrentWindow();
        }
        if (currentWindow != null) {
            final VirtualFile[] files = currentWindow.getFiles();
            presentation.setEnabled(files.length > 1);
        }
        return;
    }
    ContentManager contentManager = PlatformDataKeys.NONEMPTY_CONTENT_MANAGER.getData(dataContext);
    presentation.setEnabled(contentManager != null && contentManager.getContentCount() > 1 && contentManager.isSingleSelection());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ToolWindowManager(com.intellij.openapi.wm.ToolWindowManager) ContentManager(com.intellij.ui.content.ContentManager) FileEditorManagerEx(com.intellij.openapi.fileEditor.ex.FileEditorManagerEx) EditorWindow(com.intellij.openapi.fileEditor.impl.EditorWindow)

Example 14 with ContentManager

use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.

the class EventLogToolWindowFactory method createContent.

static void createContent(Project project, ToolWindow toolWindow, EventLogConsole console, String title) {
    // update default Event Log tab title
    ContentManager contentManager = toolWindow.getContentManager();
    Content generalContent = contentManager.getContent(0);
    if (generalContent != null && contentManager.getContentCount() == 1) {
        generalContent.setDisplayName("General");
    }
    final Editor editor = console.getConsoleEditor();
    JPanel editorPanel = new JPanel(new AbstractLayoutManager() {

        private int getOffset() {
            return JBUI.scale(4);
        }

        @Override
        public Dimension preferredLayoutSize(Container parent) {
            Dimension size = parent.getComponent(0).getPreferredSize();
            return new Dimension(size.width + getOffset(), size.height);
        }

        @Override
        public void layoutContainer(Container parent) {
            int offset = getOffset();
            parent.getComponent(0).setBounds(offset, 0, parent.getWidth() - offset, parent.getHeight());
        }
    }) {

        @Override
        public Color getBackground() {
            return ((EditorEx) editor).getBackgroundColor();
        }
    };
    editorPanel.add(editor.getComponent());
    SimpleToolWindowPanel panel = new SimpleToolWindowPanel(false, true) {

        @Override
        public Object getData(@NonNls String dataId) {
            return PlatformDataKeys.HELP_ID.is(dataId) ? EventLog.HELP_ID : super.getData(dataId);
        }
    };
    panel.setContent(editorPanel);
    panel.addAncestorListener(new LogShownTracker(project));
    ActionToolbar toolbar = createToolbar(project, editor, console);
    toolbar.setTargetComponent(editor.getContentComponent());
    panel.setToolbar(toolbar.getComponent());
    Content content = ContentFactory.SERVICE.getInstance().createContent(panel, title, false);
    contentManager.addContent(content);
    contentManager.setSelectedContent(content);
}
Also used : NonNls(org.jetbrains.annotations.NonNls) EditorEx(com.intellij.openapi.editor.ex.EditorEx) ContentManager(com.intellij.ui.content.ContentManager) AbstractLayoutManager(com.intellij.util.ui.AbstractLayoutManager) SimpleToolWindowPanel(com.intellij.openapi.ui.SimpleToolWindowPanel) Content(com.intellij.ui.content.Content) Editor(com.intellij.openapi.editor.Editor)

Example 15 with ContentManager

use of com.intellij.ui.content.ContentManager in project intellij-community by JetBrains.

the class TabbedContentImpl method split.

@Override
public void split() {
    List<Pair<String, JComponent>> copy = new ArrayList<Pair<String, JComponent>>(myTabs);
    int selectedTab = ContentUtilEx.getSelectedTab(this);
    ContentManager manager = getManager();
    String prefix = getTitlePrefix();
    manager.removeContent(this, false);
    PropertiesComponent.getInstance().setValue(SPLIT_PROPERTY_PREFIX + prefix, Boolean.TRUE.toString());
    for (int i = 0; i < copy.size(); i++) {
        final boolean select = i == selectedTab;
        final JComponent component = copy.get(i).second;
        final String tabName = copy.get(i).first;
        ContentUtilEx.addTabbedContent(manager, component, prefix, tabName, select);
    }
    Disposer.dispose(this);
}
Also used : ArrayList(java.util.ArrayList) ContentManager(com.intellij.ui.content.ContentManager) Pair(com.intellij.openapi.util.Pair)

Aggregations

ContentManager (com.intellij.ui.content.ContentManager)53 Content (com.intellij.ui.content.Content)41 ToolWindow (com.intellij.openapi.wm.ToolWindow)14 Project (com.intellij.openapi.project.Project)6 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)4 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)4 ChangesViewContentManager (com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager)3 ToolWindowEx (com.intellij.openapi.wm.ex.ToolWindowEx)3 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)3 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)3 ContentFactory (com.intellij.ui.content.ContentFactory)3 ConsoleView (com.intellij.execution.ui.ConsoleView)2 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)2 HierarchyBrowserBase (com.intellij.ide.hierarchy.HierarchyBrowserBase)2 Disposable (com.intellij.openapi.Disposable)2 SimpleToolWindowPanel (com.intellij.openapi.ui.SimpleToolWindowPanel)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 TabInfo (com.intellij.ui.tabs.TabInfo)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2