Search in sources :

Example 41 with Content

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

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

the class PreviewManagerImpl method addContent.

@NotNull
private Content addContent(PreviewInfo info) {
    myHistory.add(info);
    while (myHistory.size() > HISTORY_LIMIT) {
        close(myHistory.remove(0));
    }
    Content content = myContentManager.getFactory().createContent(info.getComponent(), info.getTitle(), false);
    myContentManager.addContent(content, 0);
    checkEmptyState();
    return content;
}
Also used : Content(com.intellij.ui.content.Content) NotNull(org.jetbrains.annotations.NotNull)

Example 43 with Content

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

the class PreviewManagerImpl method close.

private void close(@NotNull PreviewInfo info) {
    Content content = getContent(info);
    if (content != null) {
        myContentManager.removeContent(content, false);
        info.release();
        if (myContentManager.getContents().length == 0) {
            toggleToolWindow(false, null);
        }
        checkEmptyState();
    }
}
Also used : Content(com.intellij.ui.content.Content)

Example 44 with Content

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

the class TabContentLayout method showContentPopup.

@Override
public void showContentPopup(ListPopup listPopup) {
    Content selected = myUi.myManager.getSelectedContent();
    if (selected != null) {
        ContentTabLabel tab = myContent2Tabs.get(selected);
        listPopup.showUnderneathOf(tab);
    } else {
        listPopup.showUnderneathOf(myIdLabel);
    }
}
Also used : Content(com.intellij.ui.content.Content) TabbedContent(com.intellij.ui.content.TabbedContent)

Example 45 with Content

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

the class TabContentLayout method contentAdded.

@Override
public void contentAdded(ContentManagerEvent event) {
    final Content content = event.getContent();
    final ContentTabLabel tab;
    if (content instanceof TabbedContent) {
        tab = new TabbedContentTabLabel((TabbedContent) content, this);
    } else {
        tab = new ContentTabLabel(content, this);
    }
    myTabs.add(event.getIndex(), tab);
    myContent2Tabs.put(content, tab);
    if (content instanceof DnDTarget) {
        DnDTarget target = (DnDTarget) content;
        DnDSupport.createBuilder(tab).setDropHandler(target).setTargetChecker(target).install();
    }
    myCached.clear();
}
Also used : TabbedContent(com.intellij.ui.content.TabbedContent) DnDTarget(com.intellij.ide.dnd.DnDTarget) Content(com.intellij.ui.content.Content) TabbedContent(com.intellij.ui.content.TabbedContent)

Aggregations

Content (com.intellij.ui.content.Content)157 ContentManager (com.intellij.ui.content.ContentManager)42 ToolWindow (com.intellij.openapi.wm.ToolWindow)37 NotNull (org.jetbrains.annotations.NotNull)19 ContentFactory (com.intellij.ui.content.ContentFactory)14 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)13 MessageView (com.intellij.ui.content.MessageView)10 Disposable (com.intellij.openapi.Disposable)8 ToolWindowManager (com.intellij.openapi.wm.ToolWindowManager)8 RunnerLayoutUi (com.intellij.execution.ui.RunnerLayoutUi)7 ToolWindowManagerEx (com.intellij.openapi.wm.ex.ToolWindowManagerEx)7 ConsoleView (com.intellij.execution.ui.ConsoleView)6 SimpleToolWindowPanel (com.intellij.openapi.ui.SimpleToolWindowPanel)6 TabbedContent (com.intellij.ui.content.TabbedContent)6 DefaultActionGroup (com.intellij.openapi.actionSystem.DefaultActionGroup)5 Ref (com.intellij.openapi.util.Ref)5 ExecutionConsole (com.intellij.execution.ui.ExecutionConsole)4 ToolWindowManagerAdapter (com.intellij.openapi.wm.ex.ToolWindowManagerAdapter)4 Assert.assertNotNull (junit.framework.Assert.assertNotNull)4