From 83d8d0d3bfcc7debb2ddf5e029c5304a5e7eb427 Mon Sep 17 00:00:00 2001 From: Vitaly Litvak Date: Fri, 22 May 2015 11:44:33 +0300 Subject: [PATCH] For #85 - select picture after loading --- .../web/client/view/DeviceMarkersDialog.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/traccar/web/client/view/DeviceMarkersDialog.java b/src/main/java/org/traccar/web/client/view/DeviceMarkersDialog.java index 9838300a..36d63ed3 100644 --- a/src/main/java/org/traccar/web/client/view/DeviceMarkersDialog.java +++ b/src/main/java/org/traccar/web/client/view/DeviceMarkersDialog.java @@ -49,6 +49,7 @@ import org.traccar.web.client.Application; import org.traccar.web.client.i18n.Messages; import org.traccar.web.client.model.BaseAsyncCallback; +import org.traccar.web.client.model.BaseStoreHandlers; import org.traccar.web.shared.model.DeviceIcon; import org.traccar.web.shared.model.DeviceIconType; import org.traccar.web.shared.model.Position; @@ -210,6 +211,8 @@ public void load(Object loadConfig, AsyncCallback> callback) { } }; + Marker selected; + public DeviceMarkersDialog(DeviceIconType selectedIcon, DeviceMarkerHandler handler) { this.handler = handler; @@ -240,7 +243,7 @@ public void renderItem(SafeHtmlBuilder builder, SafeHtml content) { } }; - ListStore store = new ListStore(keyProvider); + final ListStore store = new ListStore(keyProvider); Loader> loader = new Loader>(hybridProxy); loader.addLoadHandler(new ListStoreBinding>(store)); @@ -292,8 +295,19 @@ public void onSubmitComplete(SubmitCompleteEvent event) { } }); + selected = new BuiltInMarker(selectedIcon); + store.addStoreHandlers(new BaseStoreHandlers() { + @Override + public void onAnything() { + for (int i = 0; i < store.size(); i++) { + if (store.get(i).getKey().equals(selected.getKey())) { + view.getSelectionModel().select(i, false); + break; + } + } + } + }); loader.load(); - view.getSelectionModel().select(new BuiltInMarker(selectedIcon), false); updateImages(); }