use of com.intellij.ui.content.impl.TabbedContentImpl 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);
}
Aggregations