Search in sources :

Example 1 with TabbedContent

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

the class ContentsUtil method closeContentTab.

public static void closeContentTab(@NotNull ContentManager contentManager, @NotNull Content content) {
    if (content instanceof TabbedContent) {
        TabbedContent tabbedContent = (TabbedContent) content;
        if (tabbedContent.getTabs().size() > 1) {
            JComponent component = tabbedContent.getComponent();
            tabbedContent.removeContent(component);
            contentManager.setSelectedContent(tabbedContent, true, true);
            dispose(component);
            return;
        }
    }
    contentManager.removeContent(content, true);
}
Also used : TabbedContent(com.intellij.ui.content.TabbedContent)

Example 2 with TabbedContent

use of com.intellij.ui.content.TabbedContent 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)

Example 3 with TabbedContent

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

the class ContentUtilEx method addTabbedContent.

public static void addTabbedContent(@NotNull ContentManager manager, @NotNull JComponent contentComponent, @NotNull String groupPrefix, @NotNull String tabName, boolean select, @Nullable Disposable childDisposable) {
    if (PropertiesComponent.getInstance().getBoolean(TabbedContent.SPLIT_PROPERTY_PREFIX + groupPrefix)) {
        final Content content = ContentFactory.SERVICE.getInstance().createContent(contentComponent, getFullName(groupPrefix, tabName), true);
        content.putUserData(Content.TABBED_CONTENT_KEY, Boolean.TRUE);
        content.putUserData(Content.TAB_GROUP_NAME_KEY, groupPrefix);
        for (Content c : manager.getContents()) {
            if (c.getComponent() == contentComponent) {
                if (select) {
                    manager.setSelectedContent(c);
                }
                return;
            }
        }
        addContent(manager, content, select);
        registerDisposable(content, childDisposable, contentComponent);
        return;
    }
    TabbedContent tabbedContent = findTabbedContent(manager, groupPrefix);
    if (tabbedContent == null) {
        final Disposable disposable = Disposer.newDisposable();
        tabbedContent = new TabbedContentImpl(contentComponent, tabName, true, groupPrefix);
        ContentsUtil.addOrReplaceContent(manager, tabbedContent, select);
        Disposer.register(tabbedContent, disposable);
    } else {
        for (Pair<String, JComponent> tab : new ArrayList<>(tabbedContent.getTabs())) {
            if (Comparing.equal(tab.second, contentComponent)) {
                tabbedContent.removeContent(tab.second);
            }
        }
        if (select) {
            manager.setSelectedContent(tabbedContent, true, true);
        }
        tabbedContent.addContent(contentComponent, tabName, true);
    }
    registerDisposable(tabbedContent, childDisposable, contentComponent);
}
Also used : Disposable(com.intellij.openapi.Disposable) TabbedContent(com.intellij.ui.content.TabbedContent) Content(com.intellij.ui.content.Content) TabbedContent(com.intellij.ui.content.TabbedContent) ArrayList(java.util.ArrayList) TabbedContentImpl(com.intellij.ui.content.impl.TabbedContentImpl)

Aggregations

TabbedContent (com.intellij.ui.content.TabbedContent)3 Content (com.intellij.ui.content.Content)2 DnDTarget (com.intellij.ide.dnd.DnDTarget)1 Disposable (com.intellij.openapi.Disposable)1 TabbedContentImpl (com.intellij.ui.content.impl.TabbedContentImpl)1 ArrayList (java.util.ArrayList)1