diff options
author | Leif Åstrand <leif@vaadin.com> | 2013-05-21 15:06:21 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-05-28 08:02:46 +0000 |
commit | 4c2b86d7d191cdb012f382e5478abf9b3b5b32f1 (patch) | |
tree | 73d1facbbc856b3144a6a290ac83ae6e7dba4f33 /client | |
parent | 4d7f190b7f36a10b16e74b1dab8ed0a274841ae1 (diff) | |
download | vaadin-framework-4c2b86d7d191cdb012f382e5478abf9b3b5b32f1.tar.gz vaadin-framework-4c2b86d7d191cdb012f382e5478abf9b3b5b32f1.zip |
Stop using PlaceHolder widgets in VTabsheet (#11026)
Vaadin 7.0 disabled rendering of tabs that are not shown, but the place
holder mechanism was still retained. Now it is removed.
Change-Id: Ic15b7f56852816d73916ef78f5997eb5e40f9cab
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/ui/VTabsheet.java | 82 |
1 files changed, 20 insertions, 62 deletions
diff --git a/client/src/com/vaadin/client/ui/VTabsheet.java b/client/src/com/vaadin/client/ui/VTabsheet.java index ea1cb282a6..fe29e2ebc0 100644 --- a/client/src/com/vaadin/client/ui/VTabsheet.java +++ b/client/src/com/vaadin/client/ui/VTabsheet.java @@ -860,57 +860,17 @@ public class VTabsheet extends VTabsheetBase implements Focusable, */ tab.recalculateCaptionWidth(); - UIDL tabContentUIDL = null; - ComponentConnector tabContentPaintable = null; - Widget tabContentWidget = null; - if (tabUidl.getChildCount() > 0) { - tabContentUIDL = tabUidl.getChildUIDL(0); - tabContentPaintable = client.getPaintable(tabContentUIDL); - tabContentWidget = tabContentPaintable.getWidget(); - } - - if (tabContentPaintable != null) { - /* This is a tab with content information */ - - int oldIndex = tp.getWidgetIndex(tabContentWidget); - 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(tabContentWidget, 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); + renderContent(tabUidl.getChildUIDL(0)); tb.selectTab(index); - } else { - if (tabContentUIDL != null) { - // updating a drawn child on hidden tab - if (tp.getWidgetIndex(tabContentWidget) < 0) { - tp.insert(tabContentWidget, index); - } - } else if (tp.getWidgetCount() <= index) { - tp.add(new PlaceHolder()); - } } } + /** + * @deprecated as of 7.1, VTabsheet only keeps the active tab in the DOM + * without any place holders. + */ + @Deprecated public class PlaceHolder extends VLabel { public PlaceHolder() { super(""); @@ -920,17 +880,20 @@ public class VTabsheet extends VTabsheetBase implements Focusable, private void renderContent(final UIDL contentUIDL) { final ComponentConnector content = client.getPaintable(contentUIDL); Widget newWidget = content.getWidget(); - if (tp.getWidgetCount() > activeTabIndex) { - Widget old = tp.getWidget(activeTabIndex); - if (old != newWidget) { - tp.remove(activeTabIndex); - tp.insert(content.getWidget(), activeTabIndex); - } - } else { - tp.add(content.getWidget()); + + assert tp.getWidgetCount() <= 1; + + if (tp.getWidgetCount() == 0) { + tp.add(newWidget); + } else if (tp.getWidget(0) != newWidget) { + tp.remove(0); + tp.add(newWidget); } - tp.showWidget(activeTabIndex); + assert tp.getWidgetCount() <= 1; + + // There's never any other index than 0, but maintaining API for now + tp.showWidget(0); VTabsheet.this.iLayout(); updateOpenTabSize(); @@ -1114,13 +1077,8 @@ public class VTabsheet extends VTabsheetBase implements Focusable, @Override public void removeTab(int index) { tb.removeTab(index); - /* - * This must be checked because renderTab automatically removes the - * active tab content when it changes - */ - if (tp.getWidgetCount() > index) { - tp.remove(index); - } + + // Removing content from tp is handled by the connector } @Override |