diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-06-01 09:32:37 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2015-06-01 09:34:46 +0300 |
commit | 6677046e5e23667403b8fb0499a618495796e1c8 (patch) | |
tree | 0d4bb0bf40b16be2c9e7e6158729f5bd3ff54d22 /shared | |
parent | cf563c053fdf0d6b2991eba98e1cc118a8e74e54 (diff) | |
parent | 5b92ec790e3d3949992275d54ee8ac61ad94c157 (diff) | |
download | vaadin-framework-6677046e5e23667403b8fb0499a618495796e1c8.tar.gz vaadin-framework-6677046e5e23667403b8fb0499a618495796e1c8.zip |
Merge remote-tracking branch 'origin/master' into grid-unbuffered-editor
This also refactors some event handling logic.
Change-Id: I9cf96381650076da01686c5d964eb3e7e92c24c0
Diffstat (limited to 'shared')
6 files changed, 90 insertions, 3 deletions
diff --git a/shared/src/com/vaadin/shared/ApplicationConstants.java b/shared/src/com/vaadin/shared/ApplicationConstants.java index 37bf5c8a00..3431387b77 100644 --- a/shared/src/com/vaadin/shared/ApplicationConstants.java +++ b/shared/src/com/vaadin/shared/ApplicationConstants.java @@ -137,4 +137,9 @@ public class ApplicationConstants implements Serializable { */ public static final String CSRF_TOKEN_DEFAULT_VALUE = "init"; + /** + * The name of the parameter used for re-synchronizing. + */ + public static final String RESYNCHRONIZE_ID = "resynchronize"; + } diff --git a/shared/src/com/vaadin/shared/ui/MarginInfo.java b/shared/src/com/vaadin/shared/ui/MarginInfo.java index d15fa0a281..7119ce2f90 100644 --- a/shared/src/com/vaadin/shared/ui/MarginInfo.java +++ b/shared/src/com/vaadin/shared/ui/MarginInfo.java @@ -115,6 +115,8 @@ public class MarginInfo implements Serializable { /** * Checks if this MarginInfo object has margins on all edges enabled. * + * @since 7.5.0 + * * @return true if all edges have margins enabled */ public boolean hasAll() { diff --git a/shared/src/com/vaadin/shared/ui/grid/GridState.java b/shared/src/com/vaadin/shared/ui/grid/GridState.java index 3faa4b441c..c4121cbf45 100644 --- a/shared/src/com/vaadin/shared/ui/grid/GridState.java +++ b/shared/src/com/vaadin/shared/ui/grid/GridState.java @@ -103,7 +103,9 @@ public class GridState extends TabIndexState { public static final String JSONKEY_CELLSTYLES = "cs"; /** - * The key that tells whether details are visible for the row + * The key that tells whether details are visible for the row. + * + * @since 7.5.0 * * @see com.vaadin.ui.Grid#setDetailsGenerator(com.vaadin.ui.Grid.DetailsGenerator) * @see com.vaadin.ui.Grid#setDetailsVisible(Object, boolean) diff --git a/shared/src/com/vaadin/shared/ui/ui/DebugWindowServerRpc.java b/shared/src/com/vaadin/shared/ui/ui/DebugWindowServerRpc.java index cb94a9b081..b6f17661d0 100644 --- a/shared/src/com/vaadin/shared/ui/ui/DebugWindowServerRpc.java +++ b/shared/src/com/vaadin/shared/ui/ui/DebugWindowServerRpc.java @@ -47,4 +47,14 @@ public interface DebugWindowServerRpc extends ServerRpc { */ public void analyzeLayouts(); + /** + * Sends a request to the server to print a design to the console for the + * given component. + * + * @since 7.5 + * @param connector + * the component connector to output a declarative design for + */ + public void showServerDesign(Connector connector); + } diff --git a/shared/src/com/vaadin/shared/util/SharedUtil.java b/shared/src/com/vaadin/shared/util/SharedUtil.java index bc5d87b9f5..d363d767be 100644 --- a/shared/src/com/vaadin/shared/util/SharedUtil.java +++ b/shared/src/com/vaadin/shared/util/SharedUtil.java @@ -149,11 +149,12 @@ public class SharedUtil implements Serializable { sb.append(parts[i]); sb.append(separator); } - return sb.substring(0, sb.length() - 1); + return sb.substring(0, sb.length() - separator.length()); } /** - * Capitalizes the first character in the given string + * Capitalizes the first character in the given string in a way suitable for + * use in code (methods, properties etc) * * @since 7.4 * @param string @@ -239,4 +240,29 @@ public class SharedUtil implements Serializable { return uri; } + /** + * Converts a dash ("-") separated string into camelCase. + * <p> + * Examples: + * <p> + * {@literal foo} becomes {@literal foo} {@literal foo-bar} becomes + * {@literal fooBar} {@literal foo--bar} becomes {@literal fooBar} + * + * @since + * @param dashSeparated + * The dash separated string to convert + * @return a camelCase version of the input string + */ + public static String dashSeparatedToCamelCase(String dashSeparated) { + if (dashSeparated == null) { + return null; + } + String[] parts = dashSeparated.split("-"); + for (int i = 1; i < parts.length; i++) { + parts[i] = capitalize(parts[i]); + } + + return join(parts, ""); + } + } diff --git a/shared/tests/src/com/vaadin/shared/util/SharedUtilTests.java b/shared/tests/src/com/vaadin/shared/util/SharedUtilTests.java index 208d4ca7c7..e77501a446 100644 --- a/shared/tests/src/com/vaadin/shared/util/SharedUtilTests.java +++ b/shared/tests/src/com/vaadin/shared/util/SharedUtilTests.java @@ -3,6 +3,8 @@ package com.vaadin.shared.util; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; +import java.util.Locale; + import org.junit.Assert; import org.junit.Test; @@ -76,4 +78,44 @@ public class SharedUtilTests { String[] splitParts = SharedUtil.splitCamelCase(camelCaseString); Assert.assertArrayEquals(parts, splitParts); } + + @Test + public void join() { + String s1 = "foo-bar-baz"; + String s2 = "foo--bar"; + + Assert.assertEquals("foobarbaz", SharedUtil.join(s1.split("-"), "")); + Assert.assertEquals("foo!bar!baz", SharedUtil.join(s1.split("-"), "!")); + Assert.assertEquals("foo!!bar!!baz", + SharedUtil.join(s1.split("-"), "!!")); + + Assert.assertEquals("foo##bar", SharedUtil.join(s2.split("-"), "#")); + } + + @Test + public void dashSeparatedToCamelCase() { + Assert.assertEquals(null, SharedUtil.dashSeparatedToCamelCase(null)); + Assert.assertEquals("", SharedUtil.dashSeparatedToCamelCase("")); + Assert.assertEquals("foo", SharedUtil.dashSeparatedToCamelCase("foo")); + Assert.assertEquals("fooBar", + SharedUtil.dashSeparatedToCamelCase("foo-bar")); + Assert.assertEquals("fooBar", + SharedUtil.dashSeparatedToCamelCase("foo--bar")); + Assert.assertEquals("fooBarBaz", + SharedUtil.dashSeparatedToCamelCase("foo-bar-baz")); + Assert.assertEquals("fooBarBaz", + SharedUtil.dashSeparatedToCamelCase("foo-Bar-Baz")); + } + + @Test + public void methodUppercaseWithTurkishLocale() { + Locale defaultLocale = Locale.getDefault(); + try { + Locale.setDefault(new Locale("tr", "TR")); + Assert.assertEquals("Integer", SharedUtil.capitalize("integer")); + } finally { + Locale.setDefault(defaultLocale); + } + } + } |