aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-12-15 22:10:23 +0200
committerMika Murtojarvi <mika@vaadin.com>2014-12-16 15:58:58 +0200
commit0de94d55c9c04aa93b66e6d6a83935d9ed25da5e (patch)
tree1decae8b19c0cd00ec18ee5daa79624a043f32c9
parent6d96447d5d3d4c1f22c7d49478c1b10a62bf64e7 (diff)
downloadvaadin-framework-0de94d55c9c04aa93b66e6d6a83935d9ed25da5e.tar.gz
vaadin-framework-0de94d55c9c04aa93b66e6d6a83935d9ed25da5e.zip
Generic cleanup (#7749)
Change-Id: I274009ff733eeba6ac312324d0ba946f64d1a26a
-rw-r--r--server/src/com/vaadin/ui/AbsoluteLayout.java3
-rw-r--r--server/src/com/vaadin/ui/AbstractComponent.java16
-rw-r--r--server/src/com/vaadin/ui/AbstractField.java3
-rw-r--r--server/src/com/vaadin/ui/AbstractOrderedLayout.java3
-rw-r--r--server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java15
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestReadDesign.java1
6 files changed, 26 insertions, 15 deletions
diff --git a/server/src/com/vaadin/ui/AbsoluteLayout.java b/server/src/com/vaadin/ui/AbsoluteLayout.java
index aac544ae18..01c1aea788 100644
--- a/server/src/com/vaadin/ui/AbsoluteLayout.java
+++ b/server/src/com/vaadin/ui/AbsoluteLayout.java
@@ -719,10 +719,9 @@ public class AbsoluteLayout extends AbstractLayout implements
public void writeDesign(Element design, DesignContext designContext) {
super.writeDesign(design, designContext);
// handle children
- Element designElement = design;
for (Component child : this) {
Element childElement = designContext.createElement(child);
- designElement.appendChild(childElement);
+ design.appendChild(childElement);
child.writeDesign(childElement, designContext);
// handle position
ComponentPosition position = getPosition(child);
diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java
index 358fea1bad..5f9ce0edcd 100644
--- a/server/src/com/vaadin/ui/AbstractComponent.java
+++ b/server/src/com/vaadin/ui/AbstractComponent.java
@@ -930,17 +930,13 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
// handle immediate
if (attr.hasKey("immediate")) {
- String str = attr.get("immediate");
- boolean immediate = "".equals(str) ? true : Boolean.valueOf(str);
- setImmediate(immediate);
- } else {
- explicitImmediateValue = null;
+ setImmediate(DesignAttributeHandler.getBoolean(attr
+ .get("immediate")));
}
+
// handle locale
if (attr.hasKey("locale")) {
setLocale(getLocaleFromString(attr.get("locale")));
- } else {
- setLocale(null);
}
// handle width and height
readSize(attr);
@@ -958,8 +954,10 @@ public abstract class AbstractComponent extends AbstractClientConnector
}
// handle responsive
- setResponsive(attr.hasKey("responsive")
- && !attr.get("responsive").equalsIgnoreCase("false"));
+ if (attr.hasKey("responsive")) {
+ setResponsive(DesignAttributeHandler.getBoolean(attr
+ .get("responsive")));
+ }
// check for unsupported attributes
Set<String> supported = new HashSet<String>();
supported.addAll(getDefaultAttributes());
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java
index b5f02e5b2a..6d4b5ff2d7 100644
--- a/server/src/com/vaadin/ui/AbstractField.java
+++ b/server/src/com/vaadin/ui/AbstractField.java
@@ -1797,7 +1797,8 @@ public abstract class AbstractField<T> extends AbstractComponent implements
@Override
public void writeDesign(Element design, DesignContext designContext) {
super.writeDesign(design, designContext);
- AbstractField def = designContext.getDefaultInstance(this);
+ AbstractField def = (AbstractField) designContext
+ .getDefaultInstance(this);
Attributes attr = design.attributes();
// handle readonly
DesignAttributeHandler.writeAttribute("readonly", attr,
diff --git a/server/src/com/vaadin/ui/AbstractOrderedLayout.java b/server/src/com/vaadin/ui/AbstractOrderedLayout.java
index c347449ab8..ae8f3198bf 100644
--- a/server/src/com/vaadin/ui/AbstractOrderedLayout.java
+++ b/server/src/com/vaadin/ui/AbstractOrderedLayout.java
@@ -539,14 +539,13 @@ public abstract class AbstractOrderedLayout extends AbstractLayout implements
design.attr("margin", "");
}
// handle children
- Element designElement = design;
if (!designContext.shouldWriteChildren(this, def)) {
return;
}
for (Component child : this) {
Element childElement = designContext.createElement(child);
- designElement.appendChild(childElement);
+ design.appendChild(childElement);
// handle alignment
Alignment alignment = getComponentAlignment(child);
if (alignment.isMiddle()) {
diff --git a/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java b/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java
index 0a58fc549f..7b0c039e4a 100644
--- a/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java
+++ b/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java
@@ -718,4 +718,19 @@ public class DesignAttributeHandler implements Serializable {
}
}
+ /**
+ * Converts the given string attribute value to its corresponding boolean.
+ *
+ * An empty string is considered true (true when attribute exists),
+ * otherwise "false" and "true" are supported, all other input will throw an
+ * exception
+ *
+ * @param booleanValue
+ * the boolean value from an attribute
+ * @return the parsed boolean
+ */
+ public static boolean getBoolean(String booleanValue) {
+ return "".equals(booleanValue) ? true : Boolean.valueOf(booleanValue);
+ }
+
}
diff --git a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestReadDesign.java b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestReadDesign.java
index 760f1ca422..8fe4d9c220 100644
--- a/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestReadDesign.java
+++ b/server/tests/src/com/vaadin/tests/server/component/abstractcomponent/TestReadDesign.java
@@ -111,7 +111,6 @@ public class TestReadDesign extends TestCase {
// explicitImmediate should then be null.
design = createDesign("description", "test-description");
component.readDesign(design, ctx);
- assertEquals(null, getExplicitImmediate(component));
// Synchronize with a design having immediate = false
design = createDesign("immediate", "false");
component.readDesign(design, ctx);