*/
c.setWidth(c.getRequiredWidth() + "px");
captions.put("" + index, c);
UIDL tabContentUIDL = null;
Paintable tabContent = null;
if (tabUidl.getChildCount() > 0) {
tabContentUIDL = tabUidl.getChildUIDL(0);
tabContent = client.getPaintable(tabContentUIDL);
}
if (tabContent != null) {
/* This is a tab with content information */
int oldIndex = tp.getWidgetIndex((Widget) tabContent);
if (oldIndex != -1 && oldIndex != index) {
/*
* The tab has previously been rendered in another position so
* we must move the cached content to correct position
*/
tp.insert((Widget) tabContent, index);
}
} else {
/* A tab whose content has not yet been loaded */
/*
* Make sure there is a corresponding empty tab in tp. The same
* operation as the moving above but for not-loaded tabs.
*/
if (index < tp.getWidgetCount()) {
Widget oldWidget = tp.getWidget(index);
if (!(oldWidget instanceof PlaceHolder)) {
tp.insert(new PlaceHolder(), index);
}
}
}
if (selected) {
renderContent(tabContentUIDL);
tb.selectTab(index);
} else {
if (tabContentUIDL != null) {
// updating a drawn child on hidden tab
if (tp.getWidgetIndex((Widget) tabContent) < 0) {
tp.insert((Widget) tabContent, index);
}
tabContent.updateFromUIDL(tabContentUIDL, client);
} else if (tp.getWidgetCount() <= index) {
tp.add(new PlaceHolder());
}
}
}