Skip to content

Commit

Permalink
Add method setProperties() to ol.Object
Browse files Browse the repository at this point in the history
  • Loading branch information
TDesjardins committed Sep 12, 2018
1 parent 6028812 commit dd1f697
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions gwt-ol3-client/src/main/java/ol/Object.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ public abstract class Object extends Observable {
*/
public native <T> 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 <T> void setProperties(JsPropertyMap<T> 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 <T> void setProperties(JsPropertyMap<T> properties, boolean silent);

/**
* Unsets a property.
*
Expand Down
11 changes: 11 additions & 0 deletions gwt-ol3-client/src/test/java/ol/ObjectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*******************************************************************************/
package ol;

import jsinterop.base.JsPropertyMap;

/**
* Test for {@link ol.Object}.
*
Expand Down Expand Up @@ -44,6 +46,15 @@ public void testObject() {
assertNull(object.get(PARAM_CUSTOM_VALUE));
assertNull(object.getProperties().get(PARAM_CUSTOM_VALUE));

JsPropertyMap<java.lang.Object> 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);

});

}
Expand Down

0 comments on commit dd1f697

Please sign in to comment.