From dd1f6977627ca124d5d48203e0a7989826871db9 Mon Sep 17 00:00:00 2001 From: Tino Desjardins Date: Wed, 12 Sep 2018 11:17:43 +0200 Subject: [PATCH] Add method setProperties() to ol.Object --- gwt-ol3-client/src/main/java/ol/Object.java | 17 +++++++++++++++++ gwt-ol3-client/src/test/java/ol/ObjectTest.java | 11 +++++++++++ 2 files changed, 28 insertions(+) diff --git a/gwt-ol3-client/src/main/java/ol/Object.java b/gwt-ol3-client/src/main/java/ol/Object.java index cbd01e77d..b96c2af47 100644 --- a/gwt-ol3-client/src/main/java/ol/Object.java +++ b/gwt-ol3-client/src/main/java/ol/Object.java @@ -88,6 +88,23 @@ public abstract class Object extends Observable { */ public native void set(String key, T value); + /** + * Sets a collection of key-value pairs. Note that this changes any existing properties + * and adds new ones (it does not remove any existing properties). + * + * @param properties properties to set + */ + public native void setProperties(JsPropertyMap properties); + + /** + * Sets a collection of key-value pairs. Note that this changes any existing properties + * and adds new ones (it does not remove any existing properties). + * + * @param properties properties to set + * @param silent Update without triggering an event. + */ + public native void setProperties(JsPropertyMap properties, boolean silent); + /** * Unsets a property. * diff --git a/gwt-ol3-client/src/test/java/ol/ObjectTest.java b/gwt-ol3-client/src/test/java/ol/ObjectTest.java index a22dc0e10..e297a7da8 100644 --- a/gwt-ol3-client/src/test/java/ol/ObjectTest.java +++ b/gwt-ol3-client/src/test/java/ol/ObjectTest.java @@ -15,6 +15,8 @@ *******************************************************************************/ package ol; +import jsinterop.base.JsPropertyMap; + /** * Test for {@link ol.Object}. * @@ -44,6 +46,15 @@ public void testObject() { assertNull(object.get(PARAM_CUSTOM_VALUE)); assertNull(object.getProperties().get(PARAM_CUSTOM_VALUE)); + JsPropertyMap properties = JsPropertyMap.of(); + properties.set(PARAM_CUSTOM_VALUE, "new value"); + + object.setProperties(properties); + assertEquals("new value", object.get(PARAM_CUSTOM_VALUE)); + assertEquals("new value", object.getProperties().get(PARAM_CUSTOM_VALUE)); + + object.setProperties(properties, true); + }); }