/** * The constructor for an empty tabbed panel. * * <p> * * @param tabbedPanelStyle the pre-defined height of the tabbar, can be "small" or "standard" */ public CmsTabbedPanel(CmsTabbedPanelStyle tabbedPanelStyle) { m_tabPanel = new TabLayoutPanel(tabbedPanelStyle.getBarHeight(), Unit.PX); m_panelStyle = tabbedPanelStyle; // All composites must call initWidget() in their constructors. initWidget(m_tabPanel); Element tabRootEl = m_tabPanel.getElement(); // set an additional css class for the parent element of the .gwt-TabLayoutPanelTabs element List<Element> tabBarDivs = CmsDomUtil.getElementsByClass( I_CmsLayoutBundle.INSTANCE.tabbedPanelCss().cmsTabLayoutPanelTabs(), CmsDomUtil.Tag.div, tabRootEl); if (tabBarDivs.size() == 1) { tabBarDivs .get(0) .getParentElement() .setClassName( I_CmsLayoutBundle.INSTANCE.tabbedPanelCss().cmsTabLayoutPanelTabBar() + " " + I_CmsLayoutBundle.INSTANCE.generalCss().cornerAll()); if (m_panelStyle.getTabColorClass() != null) { tabBarDivs.get(0).getParentElement().addClassName(m_panelStyle.getTabColorClass()); } } m_tabPanel.setStyleName(m_panelStyle.getStyleClass()); m_tabPanel.addStyleName(I_CmsLayoutBundle.INSTANCE.tabbedPanelCss().cmsTabLayoutPanel()); m_tabPanel.addStyleName( I_CmsLayoutBundle.INSTANCE.generalCss().cornerAll() + " " + I_CmsLayoutBundle.INSTANCE.generalCss().textMedium()); m_tabPanel.addAttachHandler( new AttachEvent.Handler() { /** * @see * com.google.gwt.event.logical.shared.AttachEvent.Handler#onAttachOrDetach(com.google.gwt.event.logical.shared.AttachEvent) */ public void onAttachOrDetach(AttachEvent event) { setOverflowVisibleToContent(); } }); }
/** * Add a new tab with the provided name and content and additional left margin. * * <p> * * @param tabContent the widget to add as a tab * @param tabName the name of the tab to display in the tabbar */ public void addWithLeftMargin(E tabContent, String tabName) { tabContent.addStyleName(I_CmsLayoutBundle.INSTANCE.generalCss().cornerAll()); m_tabPanel.add(tabContent, tabName); int tabIndex = m_tabPanel.getWidgetIndex(tabContent); Element tabElement = getTabElement(tabIndex); if (tabElement != null) { tabElement.addClassName(I_CmsLayoutBundle.INSTANCE.tabbedPanelCss().tabLeftMargin()); if (!m_panelStyle.equals(CmsTabbedPanelStyle.classicTabs)) { tabElement.addClassName(I_CmsLayoutBundle.INSTANCE.generalCss().buttonCornerAll()); tabElement.addClassName(I_CmsLayoutBundle.INSTANCE.tabbedPanelCss().borderAll()); } } }