summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Englund <marc@vaadin.com>2012-10-11 06:45:32 +0000
committerVaadin Code Review <review@vaadin.com>2012-10-11 06:45:32 +0000
commit0e5fe9d46fbb3c32aa2ceae22f29253c5bf45342 (patch)
treeb1e13f0cfbc14d0bab07bb3dca7b290920cb115c
parentdec9f91a708d5b7b4ec1d6a2faaddf2b64827d3e (diff)
parentf5043ac109b73c1a01e1caa8dc7906d864ad8833 (diff)
downloadvaadin-framework-0e5fe9d46fbb3c32aa2ceae22f29253c5bf45342.tar.gz
vaadin-framework-0e5fe9d46fbb3c32aa2ceae22f29253c5bf45342.zip
Merge "Fixed primary stylename handling in Accordion #9900"
-rw-r--r--client/src/com/vaadin/client/ui/accordion/VAccordion.java34
-rw-r--r--uitest/src/com/vaadin/tests/components/accordion/AccordionPrimaryStylenames.html107
-rw-r--r--uitest/src/com/vaadin/tests/components/accordion/AccordionPrimaryStylenames.java38
3 files changed, 176 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/ui/accordion/VAccordion.java b/client/src/com/vaadin/client/ui/accordion/VAccordion.java
index e906cf3cce..0fbbcf5780 100644
--- a/client/src/com/vaadin/client/ui/accordion/VAccordion.java
+++ b/client/src/com/vaadin/client/ui/accordion/VAccordion.java
@@ -87,6 +87,26 @@ public class VAccordion extends VTabsheetBase {
}
}
+ @Override
+ public void setStylePrimaryName(String style) {
+ updateStyleNames(style);
+ }
+
+ @Override
+ public void setStyleName(String style) {
+ updateStyleNames(style);
+ }
+
+ protected void updateStyleNames(String primaryStyleName) {
+ super.setStyleName(primaryStyleName);
+ for (Widget w : getChildren()) {
+ if (w instanceof StackItem) {
+ StackItem item = (StackItem) w;
+ item.updateStyleNames(primaryStyleName);
+ }
+ }
+ }
+
/**
* This method tries to find out if a tab has been rendered with a different
* index previously. If this is the case it re-orders the children so the
@@ -359,15 +379,23 @@ public class VAccordion extends VTabsheetBase {
DOM.appendChild(getElement(), captionNode);
DOM.appendChild(getElement(), content);
- getElement().addClassName(CLASSNAME + "-item");
- captionNode.addClassName(CLASSNAME + "-item-caption");
- content.addClassName(CLASSNAME + "-item-content");
+ updateStyleNames(VAccordion.this.getStylePrimaryName());
touchScrollHandler.addElement(getContainerElement());
close();
}
+ private void updateStyleNames(String primaryStyleName) {
+ content.removeClassName(getStylePrimaryName() + "-content");
+ captionNode.removeClassName(getStylePrimaryName() + "-caption");
+
+ setStylePrimaryName(primaryStyleName + "-item");
+
+ captionNode.addClassName(getStylePrimaryName() + "-caption");
+ content.addClassName(getStylePrimaryName() + "-content");
+ }
+
@Override
public void onBrowserEvent(Event event) {
onSelectTab(this);
diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionPrimaryStylenames.html b/uitest/src/com/vaadin/tests/components/accordion/AccordionPrimaryStylenames.html
new file mode 100644
index 0000000000..6f888f7467
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionPrimaryStylenames.html
@@ -0,0 +1,107 @@
+<?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.AccordionPrimaryStylenames?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertNotCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]</td>
+ <td>v-accordion</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]</td>
+ <td>my-accordion</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]/domChild[0]</td>
+ <td>my-accordion-item</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]/domChild[0]</td>
+ <td>my-accordion-item-first</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]/domChild[0]</td>
+ <td>my-accordion-item-open</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]/domChild[0]/domChild[0]</td>
+ <td>my-accordion-item-caption</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]/domChild[0]/domChild[1]</td>
+ <td>my-accordion-item-content</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]/domChild[1]</td>
+ <td>my-accordion-item</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertNotCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]</td>
+ <td>my-accordion</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]</td>
+ <td>my-second-accordion</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]/domChild[0]</td>
+ <td>my-second-accordion-item</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]/domChild[0]</td>
+ <td>my-second-accordion-item-first</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]/domChild[0]</td>
+ <td>my-second-accordion-item-open</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]/domChild[0]/domChild[0]</td>
+ <td>my-second-accordion-item-caption</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]/domChild[0]/domChild[1]</td>
+ <td>my-second-accordion-item-content</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsaccordionAccordionPrimaryStylenames::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VAccordion[0]/domChild[1]</td>
+ <td>my-second-accordion-item</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/accordion/AccordionPrimaryStylenames.java b/uitest/src/com/vaadin/tests/components/accordion/AccordionPrimaryStylenames.java
new file mode 100644
index 0000000000..bd7f047fc7
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/accordion/AccordionPrimaryStylenames.java
@@ -0,0 +1,38 @@
+package com.vaadin.tests.components.accordion;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Accordion;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.NativeButton;
+
+public class AccordionPrimaryStylenames extends TestBase {
+
+ @Override
+ protected void setup() {
+ final Accordion acc = new Accordion();
+ acc.addComponent(new NativeButton("First tab"));
+ acc.addComponent(new NativeButton("Second tab"));
+ acc.setPrimaryStyleName("my-accordion");
+ addComponent(acc);
+
+ addComponent(new Button("Set primary stylename",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ acc.setPrimaryStyleName("my-second-accordion");
+ }
+ }));
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Accordion should work with primary stylenames both initially and dynamically";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 9900;
+ }
+
+}