diff options
author | John Ahlroos <john@vaadin.com> | 2013-04-12 10:35:36 +0000 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2013-04-22 14:14:06 +0300 |
commit | 184114b0881a5323139e5cafd6bd7e5c04afd8e2 (patch) | |
tree | 80d686c8b4b4a67c24907eae025aa375674cdedc | |
parent | 747a88c642eb08992467ce88862fb93463d6ea20 (diff) | |
download | vaadin-framework-184114b0881a5323139e5cafd6bd7e5c04afd8e2.tar.gz vaadin-framework-184114b0881a5323139e5cafd6bd7e5c04afd8e2.zip |
Fixed Accordion tab stylenames which never got applied on the tab widgets #11645 (merged from #10605 in 6.8 branch)
Change-Id: I6af93e3846ecedd31cb9afac6321316b122c9df5
3 files changed, 105 insertions, 0 deletions
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(); } diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionTabStylenames.html b/uitest/src/com/vaadin/tests/components/accordion/AccordionTabStylenames.html new file mode 100644 index 0000000000..4870777717 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionTabStylenames.html @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8888/" /> +<title>New Test</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">New Test</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/com.vaadin.tests.components.accordion.AccordionTabStylenames?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsaccordionAccordionTabStylenames::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VAccordion[0]/domChild[0]</td> + <td>v-accordion-item-tab0</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsaccordionAccordionTabStylenames::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VAccordion[0]/domChild[1]</td> + <td>v-accordion-item-tab1</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsaccordionAccordionTabStylenames::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VAccordion[0]/domChild[2]</td> + <td>v-accordion-item-tab2</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentsaccordionAccordionTabStylenames::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VAccordion[0]/domChild[3]</td> + <td>v-accordion-item-tab3</td> +</tr> +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionTabStylenames.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionTabStylenames.java new file mode 100644 index 0000000000..1412ae6289 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionTabStylenames.java @@ -0,0 +1,32 @@ +package com.vaadin.tests.components.accordion; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Accordion; +import com.vaadin.ui.Label; +import com.vaadin.ui.TabSheet.Tab; + +public class AccordionTabStylenames extends TestBase { + + @Override + protected void setup() { + Accordion acc = new Accordion(); + addComponent(acc); + + for (int tabIndex = 0; tabIndex < 5; tabIndex++) { + Tab tab = acc.addTab(new Label("Tab " + tabIndex)); + tab.setCaption("Tab " + tabIndex); + tab.setStyleName("tab" + tabIndex); + } + } + + @Override + protected String getDescription() { + return null; + } + + @Override + protected Integer getTicketNumber() { + return 10605; + } + +} |