use of org.activityinfo.legacy.shared.model.LocationDTO in project activityinfo by bedatadriven.
the class LocationFilterPanel method createList.
private void createList() {
ListLoader filterLoader = new BaseListLoader(new LocationProxy());
ListStore<LocationDTO> filterComboboxStore = new ListStore<>(filterLoader);
filterCombobox = new ComboBox<>();
filterCombobox.setEmptyText(I18N.CONSTANTS.searchForLocationToAdd());
filterCombobox.setDisplayField("name");
filterCombobox.setStore(filterComboboxStore);
filterCombobox.setUseQueryCache(false);
filterCombobox.setTypeAhead(true);
filterCombobox.setTypeAheadDelay(120);
filterCombobox.setQueryDelay(100);
filterCombobox.addSelectionChangedListener(new SelectionChangedListener<LocationDTO>() {
@Override
public void selectionChanged(SelectionChangedEvent<LocationDTO> se) {
if (se.getSelectedItem() != null && !store.contains(se.getSelectedItem())) {
store.add(se.getSelectedItem());
filterToolBar.setApplyFilterEnabled(true);
// reset typed filter
filterCombobox.setRawValue("");
}
}
});
listView = new ListView<>();
listView.setStore(store);
listView.setDisplayProperty("name");
listView.setSelectionModel(listSelectionModel);
add(filterCombobox, new RowData(1, -1));
add(listView, new RowData(1, 1));
}
use of org.activityinfo.legacy.shared.model.LocationDTO in project activityinfo by bedatadriven.
the class LocationForm method saveNewLocation.
private void saveNewLocation() {
if (coordinateFields.validate() && nameField.validate() && axeField.validate()) {
LocationDTO newLocation = new LocationDTO();
newLocation.setId(new KeyGenerator().generateInt());
newLocation.setLocationTypeId(locationType.getId());
newLocation.setName(nameField.getValue());
newLocation.setAxe(axeField.getValue());
newLocation.setLatitude(coordinateFields.getLatitudeField().getValue());
newLocation.setLongitude(coordinateFields.getLongitudeField().getValue());
for (AdminLevelDTO level : adminPresenter.getAdminLevels()) {
newLocation.setAdminEntity(level.getId(), adminPresenter.getAdminEntity(level));
}
newLocationPresenter.accept(newLocation);
}
}
use of org.activityinfo.legacy.shared.model.LocationDTO in project activityinfo by bedatadriven.
the class LocationMap method updateSearchMarkers.
private void updateSearchMarkers() {
markerLayer.clearLayers();
List<LocationDTO> locations = Lists.reverse(searchPresenter.getStore().getModels());
LatLngBounds bounds = new LatLngBounds();
boolean empty = true;
for (LocationDTO location : locations) {
if (location.hasCoordinates()) {
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
Marker marker = createMarker(latLng, location.getMarker());
markerLayer.addLayer(marker);
bounds.extend(latLng);
bindClickEvent(location, marker);
empty = false;
}
}
//
// if (searchPresenter.get !empty) {
// updateMap(bounds);
// }
}
use of org.activityinfo.legacy.shared.model.LocationDTO in project activityinfo by bedatadriven.
the class LocationSearchPresenter method numberLocations.
private void numberLocations(List<LocationDTO> locations) {
int number = 0;
for (LocationDTO location : locations) {
if (location.hasCoordinates()) {
location.setMarker(String.valueOf((char) ('A' + number)));
number++;
}
if (number >= 26) {
break;
}
}
}
use of org.activityinfo.legacy.shared.model.LocationDTO in project activityinfo by bedatadriven.
the class SearchLocationsHandler method retrieveLocations.
private void retrieveLocations(final SearchLocations command, final ExecutionContext context, final AsyncCallback<LocationResult> callback, final int limit, final int totalCount) {
SqlQuery query = baseQuery(command).appendColumns("LocationId", "Name", "Axe", "X", "Y", "LocationTypeId").setLimitClause(dialect.limitClause(0, limit));
query.execute(context.getTransaction(), new SqlResultCallback() {
@Override
public void onSuccess(SqlTransaction tx, SqlResultSet results) {
// Create a list of locations from query result
List<LocationDTO> locations = Lists.newArrayList();
Map<Integer, LocationDTO> locationsById = Maps.newHashMap();
for (SqlResultSetRow row : results.getRows()) {
LocationDTO location = LocationDTO.fromSqlRow(row);
locations.add(location);
locationsById.put(location.getId(), location);
}
LocationResult result = new LocationResult(locations);
result.setOffset(0);
result.setTotalLength(totalCount > results.getRows().size() ? totalCount : results.getRows().size());
callback.onSuccess(result);
}
});
}
Aggregations