aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java')
-rw-r--r--server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java b/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java
index 9faf3fb0a5..a4667fed03 100644
--- a/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java
+++ b/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java
@@ -297,9 +297,9 @@ public class DesignAttributeHandler {
} else if (widthAuto) {
attributes.put("width-auto", "true");
} else {
- DecimalFormat fmt = new DecimalFormat();
- attributes.put("width", fmt.format(component.getWidth())
- + component.getWidthUnits().getSymbol());
+ attributes.put("width",
+ formatDesignAttribute(component.getWidth())
+ + component.getWidthUnits().getSymbol());
}
}
if (!areEqualHeight(component, defaultInstance)) {
@@ -309,15 +309,29 @@ public class DesignAttributeHandler {
} else if (heightAuto) {
attributes.put("height-auto", "true");
} else {
- DecimalFormat fmt = new DecimalFormat();
- attributes.put("height", fmt.format(component.getHeight())
- + component.getHeightUnits().getSymbol());
+ attributes.put("height",
+ formatDesignAttribute(component.getHeight())
+ + component.getHeightUnits().getSymbol());
}
}
}
}
/**
+ * Formats the given design attribute value. The method is provided to
+ * ensure consistent number formatting for design attribute values
+ *
+ * @since 7.4
+ * @param number
+ * the number to be formatted
+ * @return the formatted number
+ */
+ public static String formatDesignAttribute(float number) {
+ DecimalFormat fmt = new DecimalFormat();
+ return fmt.format(number);
+ }
+
+ /**
* Returns the design attribute name corresponding the given method name.
* For example given a method name <code>setPrimaryStyleName</code> the
* return value would be <code>primary-style-name</code>