diff options
author | John Ahlroos <john@vaadin.com> | 2012-10-16 14:07:40 +0300 |
---|---|---|
committer | John Ahlroos <john@vaadin.com> | 2012-10-17 08:52:28 +0300 |
commit | 7bacf1abbd74b0b4ef47cc6033671198fd8f5e4b (patch) | |
tree | 8e4b3ea810d09f3aef8543b51e7d2ce64aa3761f | |
parent | 754cf6a33685507cc3a7d5afeb761f227df66fb8 (diff) | |
download | vaadin-framework-7bacf1abbd74b0b4ef47cc6033671198fd8f5e4b.tar.gz vaadin-framework-7bacf1abbd74b0b4ef47cc6033671198fd8f5e4b.zip |
Fixed primary stylename handling for ListSelect #9907
Change-Id: Ia717af9a2dd973f16366ee527bf8f3c221fd4403
3 files changed, 115 insertions, 1 deletions
diff --git a/client/src/com/vaadin/client/ui/listselect/VListSelect.java b/client/src/com/vaadin/client/ui/listselect/VListSelect.java index 520995012e..d8d0a43378 100644 --- a/client/src/com/vaadin/client/ui/listselect/VListSelect.java +++ b/client/src/com/vaadin/client/ui/listselect/VListSelect.java @@ -39,8 +39,25 @@ public class VListSelect extends VOptionGroupBase { select = getOptionsContainer(); select.addChangeHandler(this); select.addClickHandler(this); - select.setStyleName(CLASSNAME + "-select"); select.setVisibleItemCount(VISIBLE_COUNT); + setStyleName(CLASSNAME); + } + + @Override + public void setStyleName(String style) { + super.setStyleName(style); + updateStyleNames(); + } + + @Override + public void setStylePrimaryName(String style) { + super.setStylePrimaryName(style); + updateStyleNames(); + } + + protected void updateStyleNames() { + container.setStyleName(getStylePrimaryName()); + select.setStyleName(getStylePrimaryName() + "-select"); } protected ListBox getOptionsContainer() { diff --git a/uitest/src/com/vaadin/tests/components/listselect/ListSelectPrimaryStylename.html b/uitest/src/com/vaadin/tests/components/listselect/ListSelectPrimaryStylename.html new file mode 100644 index 0000000000..7dbb99d0e6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/listselect/ListSelectPrimaryStylename.html @@ -0,0 +1,57 @@ +<?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.listselect.ListSelectPrimaryStylename?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertNotCSSClass</td> + <td>vaadin=runcomvaadintestscomponentslistselectListSelectPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VListSelect[0]</td> + <td>v-select</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentslistselectListSelectPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VListSelect[0]</td> + <td>my-list</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentslistselectListSelectPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VListSelect[0]/domChild[0]</td> + <td>my-list-select</td> +</tr> +<tr> + <td>click</td> + <td>vaadin=runcomvaadintestscomponentslistselectListSelectPrimaryStylename::/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=runcomvaadintestscomponentslistselectListSelectPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VListSelect[0]</td> + <td>my-list</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentslistselectListSelectPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VListSelect[0]</td> + <td>my-second-list</td> +</tr> +<tr> + <td>assertCSSClass</td> + <td>vaadin=runcomvaadintestscomponentslistselectListSelectPrimaryStylename::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VListSelect[0]/domChild[0]</td> + <td>my-second-list-select</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/listselect/ListSelectPrimaryStylename.java b/uitest/src/com/vaadin/tests/components/listselect/ListSelectPrimaryStylename.java new file mode 100644 index 0000000000..06dec920ea --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/listselect/ListSelectPrimaryStylename.java @@ -0,0 +1,40 @@ +package com.vaadin.tests.components.listselect; + +import java.util.Arrays; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.ListSelect; + +public class ListSelectPrimaryStylename extends TestBase { + + @Override + protected void setup() { + final ListSelect list = new ListSelect("Caption", Arrays.asList( + "Option 1", + "Option 2", "Option 3")); + list.setPrimaryStyleName("my-list"); + addComponent(list); + + addComponent(new Button("Change primary stylename", + new Button.ClickListener() { + @Override + public void buttonClick(ClickEvent event) { + list.setPrimaryStyleName("my-second-list"); + } + })); + + } + + @Override + protected String getDescription() { + return "List select should should support primary stylenames both initially and dynamically"; + } + + @Override + protected Integer getTicketNumber() { + return 9907; + } + +} |