diff options
author | Matti Hosio <mhosio@vaadin.com> | 2014-12-03 13:41:05 +0200 |
---|---|---|
committer | Matti Hosio <mhosio@vaadin.com> | 2014-12-04 15:08:06 +0200 |
commit | ccbed3fcfa5870c376014036bde8455aaa952384 (patch) | |
tree | 9415a79a4e2a8a19c2e2a5db3b3d01c832ab3614 /server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java | |
parent | 9730b6def11af6f0bcb1e8b0535e0ec081ac84dd (diff) | |
download | vaadin-framework-ccbed3fcfa5870c376014036bde8455aaa952384.tar.gz vaadin-framework-ccbed3fcfa5870c376014036bde8455aaa952384.zip |
Declarative support for AbsoluteLayout (#7749)
Change-Id: Icd90d78b3ddd14ffaef48f610c043e7a816db106
Diffstat (limited to 'server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java')
-rw-r--r-- | server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java b/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java index 423b2fb60b..daebb1c09a 100644 --- a/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java +++ b/server/src/com/vaadin/ui/declarative/DesignAttributeHandler.java @@ -244,12 +244,35 @@ public class DesignAttributeHandler { * the number to be formatted * @return the formatted number */ - public static String formatDesignAttribute(float number) { + public static String formatFloat(float number) { + return getDecimalFormat().format(number); + } + + /** + * 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 formatDouble(double number) { + return getDecimalFormat().format(number); + } + + /** + * Creates the decimal format used when writing attributes to the design + * + * @since 7.4 + * @return the decimal format + */ + private static DecimalFormat getDecimalFormat() { DecimalFormatSymbols symbols = new DecimalFormatSymbols(new Locale( "en_US")); DecimalFormat fmt = new DecimalFormat("0.###", symbols); fmt.setGroupingUsed(false); - return fmt.format(number); + return fmt; } /** @@ -359,8 +382,13 @@ public class DesignAttributeHandler { "Unknown resource type " + value.getClass().getName()); return null; } + } else if (sourceType == Float.class || sourceType == Float.TYPE) { + return formatFloat(((Float) value).floatValue()); + } else if (sourceType == Double.class || sourceType == Double.TYPE) { + return formatDouble(((Double) value).doubleValue()); } else { return value.toString(); + } } |