summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Ahlroos <john@vaadin.com>2012-10-15 15:07:20 +0300
committerJohn Ahlroos <john@vaadin.com>2012-10-15 15:07:20 +0300
commit20c21ac90633b05061c81aadcbbd6d7aa1b938ce (patch)
treed1d108d62510d0e0734d637dc8b695864cf4f1be
parent081d5dc14015838be5b358632474997a8b8855ba (diff)
downloadvaadin-framework-20c21ac90633b05061c81aadcbbd6d7aa1b938ce.tar.gz
vaadin-framework-20c21ac90633b05061c81aadcbbd6d7aa1b938ce.zip
Fixed primary stylename handling in Form #9904
Change-Id: I2cd21b386f7276be9f9dee305e086e8258094bf7
-rw-r--r--client/src/com/vaadin/client/ui/form/VForm.java27
-rw-r--r--uitest/src/com/vaadin/tests/components/form/FormPrimaryStyleName.html87
-rw-r--r--uitest/src/com/vaadin/tests/components/form/FormPrimaryStyleName.java47
3 files changed, 157 insertions, 4 deletions
diff --git a/client/src/com/vaadin/client/ui/form/VForm.java b/client/src/com/vaadin/client/ui/form/VForm.java
index 9b8dd80652..eb206e75b9 100644
--- a/client/src/com/vaadin/client/ui/form/VForm.java
+++ b/client/src/com/vaadin/client/ui/form/VForm.java
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright 2011 Vaadin Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -62,19 +62,38 @@ public class VForm extends ComplexPanel implements KeyDownHandler {
setStyleName(CLASSNAME);
fieldSet.appendChild(legend);
legend.appendChild(caption);
- desc.setClassName("v-form-description");
+
fieldSet.appendChild(desc); // Adding description for initial padding
// measurements, removed later if no
// description is set
- fieldContainer.setClassName(CLASSNAME + "-content");
+
fieldSet.appendChild(fieldContainer);
errorMessage.setVisible(false);
- errorMessage.setStyleName(CLASSNAME + "-errormessage");
+
fieldSet.appendChild(errorMessage.getElement());
fieldSet.appendChild(footerContainer);
}
@Override
+ public void setStyleName(String style) {
+ super.setStyleName(style);
+ updateStyleNames();
+ }
+
+ @Override
+ public void setStylePrimaryName(String style) {
+ super.setStylePrimaryName(style);
+ updateStyleNames();
+ }
+
+ protected void updateStyleNames() {
+ fieldContainer.setClassName(getStylePrimaryName() + "-content");
+ errorMessage.setStyleName(getStylePrimaryName() + "-errormessage");
+ desc.setClassName(getStylePrimaryName() + "-description");
+ footerContainer.setClassName(getStylePrimaryName() + "-footer");
+ }
+
+ @Override
public void onKeyDown(KeyDownEvent event) {
shortcutHandler.handleKeyboardEvent(Event.as(event.getNativeEvent()));
}
diff --git a/uitest/src/com/vaadin/tests/components/form/FormPrimaryStyleName.html b/uitest/src/com/vaadin/tests/components/form/FormPrimaryStyleName.html
new file mode 100644
index 0000000000..a4b738a36d
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/form/FormPrimaryStyleName.html
@@ -0,0 +1,87 @@
+<?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.form.FormPrimaryStyleName?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertNotCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VForm[0]</td>
+ <td>v-form</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VForm[0]</td>
+ <td>my-form</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VForm[0]/domChild[0]/domChild[1]</td>
+ <td>my-form-description</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VForm[0]/domChild[0]/domChild[2]</td>
+ <td>my-form-content</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VForm[0]/domChild[0]/domChild[3]</td>
+ <td>my-form-errormessage</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VForm[0]/domChild[0]/domChild[4]</td>
+ <td>my-form-footer</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VButton[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertNotCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VForm[0]</td>
+ <td>my-form</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VForm[0]</td>
+ <td>my-second-form</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VForm[0]/domChild[0]/domChild[1]</td>
+ <td>my-second-form-description</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VForm[0]/domChild[0]/domChild[2]</td>
+ <td>my-second-form-content</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VForm[0]/domChild[0]/domChild[3]</td>
+ <td>my-second-form-errormessage</td>
+</tr>
+<tr>
+ <td>assertCSSClass</td>
+ <td>vaadin=runcomvaadintestscomponentsformFormPrimaryStyleName::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VForm[0]/domChild[0]/domChild[4]</td>
+ <td>my-second-form-footer</td>
+</tr>
+
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/form/FormPrimaryStyleName.java b/uitest/src/com/vaadin/tests/components/form/FormPrimaryStyleName.java
new file mode 100644
index 0000000000..241c39d449
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/form/FormPrimaryStyleName.java
@@ -0,0 +1,47 @@
+package com.vaadin.tests.components.form;
+
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Form;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+
+public class FormPrimaryStyleName extends TestBase {
+
+ @Override
+ protected void setup() {
+ final Form form = new Form();
+ form.addField("aaa", new TextField());
+ form.setDescription("This is a form description");
+ form.setCaption("This is a form caption");
+ form.setPrimaryStyleName("my-form");
+
+ HorizontalLayout formFooter = new HorizontalLayout();
+ formFooter.addComponent(new Label("Form footer"));
+ form.setFooter(formFooter);
+
+ addComponent(form);
+
+ addComponent(new Button("Set primary stylename",
+ new Button.ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ form.setPrimaryStyleName("my-second-form");
+ }
+ }));
+
+ }
+
+ @Override
+ protected String getDescription() {
+ return "Form should handle primary stylenames both initially and dynamically";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 9904;
+ }
+
+}