Skip to content

Commit

Permalink
For #85 - select picture after loading
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalidze committed May 22, 2015
1 parent c899ddb commit 83d8d0d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/main/java/org/traccar/web/client/view/DeviceMarkersDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -210,6 +211,8 @@ public void load(Object loadConfig, AsyncCallback<List<Marker>> callback) {
}
};

Marker selected;

public DeviceMarkersDialog(DeviceIconType selectedIcon, DeviceMarkerHandler handler) {
this.handler = handler;

Expand Down Expand Up @@ -240,7 +243,7 @@ public void renderItem(SafeHtmlBuilder builder, SafeHtml content) {
}
};

ListStore<Marker> store = new ListStore<Marker>(keyProvider);
final ListStore<Marker> store = new ListStore<Marker>(keyProvider);
Loader<Object, List<Marker>> loader = new Loader<Object, List<Marker>>(hybridProxy);
loader.addLoadHandler(new ListStoreBinding<Object, Marker, List<Marker>>(store));

Expand Down Expand Up @@ -292,8 +295,19 @@ public void onSubmitComplete(SubmitCompleteEvent event) {
}
});

selected = new BuiltInMarker(selectedIcon);
store.addStoreHandlers(new BaseStoreHandlers<Marker>() {
@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();
}
Expand Down

0 comments on commit 83d8d0d

Please sign in to comment.