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);
}
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();
}
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);
}
Aggregations