import org.argeo.eclipse.ui.Selected;
import org.argeo.jcr.Jcr;
import org.eclipse.swt.SWT;
import org.argeo.eclipse.ui.Selected;
import org.argeo.jcr.Jcr;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
public TabbedArea(Composite parent, int style) {
super(parent, style);
CmsUiUtils.style(parent, bodyStyle);
public TabbedArea(Composite parent, int style) {
super(parent, style);
CmsUiUtils.style(parent, bodyStyle);
headers.setLayoutData(CmsUiUtils.fillWidth());
body = new Composite(this, SWT.NONE);
body.setLayoutData(CmsUiUtils.fillAll());
headers.setLayoutData(CmsUiUtils.fillWidth());
body = new Composite(this, SWT.NONE);
body.setLayoutData(CmsUiUtils.fillAll());
boolean selected = section == currentSection;
Composite sectionHeader = section.createHeader(headers);
CmsUiUtils.style(sectionHeader, selected ? tabSelectedStyle : tabStyle);
boolean selected = section == currentSection;
Composite sectionHeader = section.createHeader(headers);
CmsUiUtils.style(sectionHeader, selected ? tabSelectedStyle : tabStyle);
sectionHeader.setLayout(new GridLayout(headerColumns, false));
sectionHeader.setLayout(CmsUiUtils.noSpaceGridLayout(headerColumns));
Button title = new Button(sectionHeader, SWT.FLAT);
sectionHeader.setLayout(new GridLayout(headerColumns, false));
sectionHeader.setLayout(CmsUiUtils.noSpaceGridLayout(headerColumns));
Button title = new Button(sectionHeader, SWT.FLAT);
title.addSelectionListener((Selected) (e) -> showTab(tabIndex(section.getNode())));
Node node = section.getNode();
title.setText(Jcr.getTitle(node));
title.addSelectionListener((Selected) (e) -> showTab(tabIndex(section.getNode())));
Node node = section.getNode();
title.setText(Jcr.getTitle(node));
- ToolBar toolBar = new ToolBar(sectionHeader, SWT.NONE);
- ToolItem closeItem = new ToolItem(toolBar, SWT.FLAT);
- if (closeIcon != null)
- closeItem.setImage(closeIcon);
- else
- closeItem.setText("X");
- CmsUiUtils.style(closeItem, selected ? tabSelectedStyle : tabStyle);
- closeItem.addSelectionListener((Selected) (e) -> closeTab(section));
+ if (!singleTab) {
+ ToolBar toolBar = new ToolBar(sectionHeader, SWT.NONE);
+ ToolItem closeItem = new ToolItem(toolBar, SWT.FLAT);
+ if (closeIcon != null)
+ closeItem.setImage(closeIcon);
+ else
+ closeItem.setText("X");
+ CmsUiUtils.style(closeItem, selected ? tabSelectedStyle : tabStyle);
+ closeItem.addSelectionListener((Selected) (e) -> closeTab(section));
+ }
build(section, uiProvider, context);
if (sections.size() == 0)
sections.add(section);
refreshTabHeaders();
build(section, uiProvider, context);
if (sections.size() == 0)
sections.add(section);
refreshTabHeaders();
int currentIndex = sections.indexOf(currentSection);
Section previousSection = new Section(body, SWT.NONE, context);
build(previousSection, previousUiProvider, previousNode);
int currentIndex = sections.indexOf(currentSection);
Section previousSection = new Section(body, SWT.NONE, context);
build(previousSection, previousUiProvider, previousNode);
- previousSection.setLayoutData(CmsUiUtils.coverAll());
- sections.add(currentIndex + 1, previousSection);
+ // previousSection.setLayoutData(CmsUiUtils.coverAll());
+ int index = currentIndex + 1;
+ sections.add(index, previousSection);
+ showTab(index);