List of usage examples for com.google.gwt.user.client.ui TabLayoutPanel getWidgetCount
public int getWidgetCount()
From source file:org.glom.web.client.ui.details.Notebook.java
License:Open Source License
/** * Create a new Notebook widget based on the specified LayoutItemNotebook DTO. * /*ww w. ja v a 2 s. c o m*/ * @param layoutItemNotebook */ public Notebook(final LayoutItemNotebook layoutItemNotebook) { // The height of the TabLayoutPanel needs to be set to make the child widgets visible. The height of the tab bar // also needs to be explicitly set. To work around these constraints, we're setting the tab height based on the // tab text and decorations as set in the CSS. The height of the TabLayoutPanel will be set to be the height of // the tab panel plus the height of the decorated tab content panel plus the height of the tallest child widget. final int tabBarHeight = getDecoratedTabBarHeight(); final int emptyTabContentHeight = getDecoratedEmptyTabContentHeight(); final TabLayoutPanel tabPanel = new TabLayoutPanel(tabBarHeight, Unit.PX); int maxChildHeight = 0; for (final LayoutItem layoutItem : layoutItemNotebook.getItems()) { if (!(layoutItem instanceof LayoutGroup)) { // Ignore non-LayoutGroup items. This is what Glom 1.18 does. continue; } // child groups of Notebooks shouldn't show their titles final Widget child = createChildWidget(layoutItem, false); // update the maximum value of the child height if required final int childHeight = Utils.getWidgetHeight(child); if (childHeight > maxChildHeight) { maxChildHeight = childHeight; } // Use the name if the title is empty. This avoids having tabs with empty labels. tabPanel.add(child, StringUtils.isEmpty(layoutItem.getTitle()) ? layoutItem.getName() : layoutItem.getTitle()); } // Set the first tab as the default tab. tabPanel.selectTab(0); // Add a CSS class name for the first tab. if (tabPanel.getWidgetCount() > 0) { final Element element = tabPanel.getElement().getFirstChildElement().getNextSiblingElement() .getFirstChildElement().getFirstChildElement(); element.addClassName("firstTab"); } // Use the max child height plus the height of the tab bar and the height of an empty content panel. tabPanel.setHeight((tabBarHeight + emptyTabContentHeight + maxChildHeight) + "px"); initWidget(tabPanel); }