From 184114b0881a5323139e5cafd6bd7e5c04afd8e2 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Fri, 12 Apr 2013 10:35:36 +0000 Subject: Fixed Accordion tab stylenames which never got applied on the tab widgets #11645 (merged from #10605 in 6.8 branch) Change-Id: I6af93e3846ecedd31cb9afac6321316b122c9df5 --- client/src/com/vaadin/client/ui/VAccordion.java | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'client') diff --git a/client/src/com/vaadin/client/ui/VAccordion.java b/client/src/com/vaadin/client/ui/VAccordion.java index 6c4bd06b6d..f87186fe37 100644 --- a/client/src/com/vaadin/client/ui/VAccordion.java +++ b/client/src/com/vaadin/client/ui/VAccordion.java @@ -34,6 +34,7 @@ import com.vaadin.client.Util; import com.vaadin.client.VCaption; import com.vaadin.client.ui.TouchScrollDelegate.TouchScrollHandler; import com.vaadin.shared.ui.tabsheet.TabsheetBaseConstants; +import com.vaadin.shared.ui.tabsheet.TabsheetConstants; public class VAccordion extends VTabsheetBase { @@ -76,6 +77,9 @@ public class VAccordion extends VTabsheetBase { } item.updateCaption(tabUidl); + item.updateTabStyleName(tabUidl + .getStringAttribute(TabsheetConstants.TAB_STYLE_NAME)); + item.setVisible(!hidden); if (selected) { @@ -290,6 +294,7 @@ public class VAccordion extends VTabsheetBase { private boolean open = false; private Element content = DOM.createDiv(); private Element captionNode = DOM.createDiv(); + private String styleName; public StackItem(UIDL tabUidl) { setElement(DOM.createDiv()); @@ -312,6 +317,7 @@ public class VAccordion extends VTabsheetBase { captionNode.removeClassName(getStylePrimaryName() + "-caption"); setStylePrimaryName(primaryStyleName + "-item"); + updateTabStyleName(getStylePrimaryName()); captionNode.addClassName(getStylePrimaryName() + "-caption"); content.addClassName(getStylePrimaryName() + "-content"); @@ -399,6 +405,32 @@ public class VAccordion extends VTabsheetBase { uidl.getStringAttribute(TabsheetBaseConstants.ATTRIBUTE_TAB_ICON)); } + /** + * Updates a tabs stylename from the child UIDL + * + * @param uidl + * The child uidl of the tab + */ + private void updateTabStyleName(String newStyleName) { + if (newStyleName != null && newStyleName.length() != 0) { + if (!newStyleName.equals(styleName)) { + // If we have a new style name + if (styleName != null && styleName.length() != 0) { + // Remove old style name if present + removeStyleDependentName(styleName); + } + // Set new style name + addStyleDependentName(newStyleName); + styleName = newStyleName; + } + } else if (styleName != null) { + // Remove the set stylename if no stylename is present in the + // uidl + removeStyleDependentName(styleName); + styleName = null; + } + } + public int getWidgetWidth() { return DOM.getFirstChild(content).getOffsetWidth(); } -- cgit v1.2.3