Skip to content

Commit 1999d83

Browse files
javier-godoypaodb
authored andcommitted
feat: add json-migration-helper
Close #169
1 parent d85c8fc commit 1999d83

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.flowingcode.vaadin.addons</groupId>
66
<artifactId>google-maps</artifactId>
7-
<version>2.3.1-SNAPSHOT</version>
7+
<version>2.4.0-SNAPSHOT</version>
88
<name>Google Maps Addon</name>
99
<description>Integration of google-map for Vaadin platform</description>
1010

@@ -132,6 +132,12 @@
132132
</exclusions>
133133
</dependency>
134134

135+
<dependency>
136+
<groupId>com.flowingcode.vaadin</groupId>
137+
<artifactId>json-migration-helper</artifactId>
138+
<version>0.0.1-SNAPSHOT</version>
139+
</dependency>
140+
135141
<dependency>
136142
<groupId>org.slf4j</groupId>
137143
<artifactId>slf4j-simple</artifactId>

src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMap.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.flowingcode.vaadin.addons.googlemaps.maptypestyle.ElementType;
2424
import com.flowingcode.vaadin.addons.googlemaps.maptypestyle.FeatureType;
2525
import com.flowingcode.vaadin.addons.googlemaps.maptypestyle.MapStyle;
26+
import com.flowingcode.vaadin.jsonmigration.JsonMigration;
2627
import com.vaadin.flow.component.ClickEvent;
2728
import com.vaadin.flow.component.ClientCallable;
2829
import com.vaadin.flow.component.Component;
@@ -518,7 +519,7 @@ public Registration addClickListener(ComponentEventListener<GoogleMapClickEvent>
518519
DomListenerRegistration registration =
519520
getElement()
520521
.addEventListener("google-map-click", ev -> {
521-
JsonObject latLng = ev.getEventData().get("event.detail.latLng");
522+
JsonObject latLng = JsonMigration.getEventData(ev).get("event.detail.latLng");
522523
listener.onComponentEvent(new GoogleMapClickEvent(this, true, latLng));
523524
}).addEventData("event.detail.latLng");
524525
return registration::remove;
@@ -530,7 +531,7 @@ public Registration addRightClickListener(ComponentEventListener<GoogleMapClickE
530531
DomListenerRegistration registration =
531532
getElement()
532533
.addEventListener("google-map-rightclick", ev -> {
533-
JsonObject latLng = ev.getEventData().get("event.detail.latLng");
534+
JsonObject latLng = JsonMigration.getEventData(ev).get("event.detail.latLng");
534535
listener.onComponentEvent(new GoogleMapClickEvent(this, true, latLng));
535536
}).addEventData("event.detail.latLng");
536537
return registration::remove;
@@ -767,7 +768,7 @@ public Registration addGoogleMapBoundsChangedListener(
767768
DomListenerRegistration registration =
768769
getElement().addEventListener("google-map-bounds_changed", ev -> {
769770
listener.onComponentEvent(new GoogleMapBoundsChangedEvent(this, true,
770-
new LatLonBounds(ev.getEventData().get("event.detail"))));
771+
new LatLonBounds(JsonMigration.getEventData(ev).get("event.detail"))));
771772
}).debounce(1000, DebouncePhase.TRAILING).addEventData("event.detail");
772773
return registration::remove;
773774
}
@@ -803,7 +804,7 @@ public void addCustomControls(CustomControl... customControls) {
803804
customControl.getControlButton().getElement().setAttribute("slot", "customControlSlot_" + i);
804805
getElement().appendChild(customControl.getControlButton().getElement());
805806
}
806-
getElement().setPropertyJson("customControls", jsonArray);
807+
JsonMigration.setPropertyJson(getElement(), "customControls", jsonArray);
807808
}
808809

809810
/**
@@ -822,7 +823,7 @@ public void setCustomControls(CustomControl... customControls) {
822823
getElement().appendChild(customControl.getControlButton().getElement());
823824
this.customControls.add(customControl);
824825
}
825-
getElement().setPropertyJson("customControls", jsonArray);
826+
JsonMigration.setPropertyJson(getElement(), "customControls", jsonArray);
826827
});
827828
}
828829

@@ -924,6 +925,6 @@ public void setMapStyle(MapStyle... mapStyles) {
924925
MapStyle mapStyle = mapStyles[i];
925926
jsonArray.set(i, mapStyle.getJson());
926927
}
927-
getElement().setPropertyJson("styles", jsonArray);
928+
JsonMigration.setPropertyJson(getElement(), "styles", jsonArray);
928929
}
929930
}

src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMapMarker.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package com.flowingcode.vaadin.addons.googlemaps;
2222

2323

24+
import com.flowingcode.vaadin.jsonmigration.JsonMigration;
2425
import com.vaadin.flow.component.ClickEvent;
2526
import com.vaadin.flow.component.Component;
2627
import com.vaadin.flow.component.ComponentEvent;
@@ -193,7 +194,7 @@ public void setIconUrl(String iconUrl) {
193194
* @param icon the icon image of the marker
194195
*/
195196
public void setIcon(GoogleMapIcon icon) {
196-
this.getElement().setPropertyJson("icon", icon.getJson());
197+
JsonMigration.setPropertyJson(getElement(), "icon", icon.getJson());
197198
}
198199

199200
/**
@@ -203,7 +204,7 @@ public void setIcon(GoogleMapIcon icon) {
203204
* @param label the new marker's label
204205
*/
205206
public void setLabel(MarkerLabel label) {
206-
this.getElement().setPropertyJson("label", label.getJson());
207+
JsonMigration.setPropertyJson(getElement(), "label", label.getJson());
207208
}
208209

209210
/**

src/main/java/com/flowingcode/vaadin/addons/googlemaps/GoogleMapPoly.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package com.flowingcode.vaadin.addons.googlemaps;
2222

23+
import com.flowingcode.vaadin.jsonmigration.JsonMigration;
2324
import com.vaadin.flow.component.ClickEvent;
2425
import com.vaadin.flow.component.Component;
2526
import com.vaadin.flow.component.ComponentEventListener;
@@ -191,7 +192,7 @@ public void setIcons(Icon... icons) {
191192
for (int i = 0; i < icons.length; i++) {
192193
jsonArray.set(i, icons[i].getJson());
193194
}
194-
getElement().setPropertyJson("icons", jsonArray);
195+
JsonMigration.setPropertyJson(getElement(), "icons", jsonArray);
195196
}
196197

197198
/**
@@ -204,7 +205,7 @@ public void setIcons(IconSequence... icons) {
204205
for (int i = 0; i < icons.length; i++) {
205206
jsonArray.set(i, icons[i].getJson());
206207
}
207-
getElement().setPropertyJson("icons", jsonArray);
208+
JsonMigration.setPropertyJson(getElement(), "icons", jsonArray);
208209
}
209210

210211
}

0 commit comments

Comments
 (0)