public SelectLocationEvent(MapWidget mapWidget, GetLocationForStringAlternative alternative) { super(); this.mapWidget = mapWidget; canonicalLocation = alternative.getCanonicalLocation(); center = alternative.getCenter(); bbox = alternative.getBbox(); geocoderName = alternative.getGeocoderName(); userData = alternative.getUserData(); }
public SelectLocationEvent(MapWidget mapWidget, GetLocationForStringResponse alternative) { super(); this.mapWidget = mapWidget; canonicalLocation = alternative.getCanonicalLocation(); center = alternative.getCenter(); bbox = alternative.getBbox(); geocoderName = alternative.getGeocoderName(); userData = alternative.getUserData(); }
@Override public GetLocationForStringRequest getEmptyCommandRequest() { return new GetLocationForStringRequest(); }
@Override public void execute(GetLocationForStringRequest request, GetLocationForStringResponse response) throws Exception { String location = request.getLocation(); if (null == location) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "location"); String crsString = request.getCrs(); if (null == crsString) { throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs"); if (null != request.getLocale()) { locale = new Locale(request.getLocale()); int maxAlternatives = request.getMaxAlternatives(); Pattern namePattern = getShouldUsePattern(request.getServicePattern()); for (GeocoderService geocoderService : geocoderInfo.getGeocoderServices()) { if (shouldUse(namePattern, geocoderService.getName())) { response.setLocationFound(false); if (!results.isEmpty()) { response.setLocationFound(true); response.setCanonicalLocation(matchedLocation); response.setGeocoderName(geocoderName); response.setUserData(results.get(0).getUserData()); response.setBbox(bbox); response.setCenter(new Coordinate(bbox.getX() + bbox.getWidth() / 2, bbox.getY() + bbox.getHeight() / 2));
@Override public void findLocation(final String location) { showAlternativesView(false); GwtCommand command = new GwtCommand(GetLocationForStringRequest.COMMAND); GetLocationForStringRequest request = new GetLocationForStringRequest(); request.setCrs(mapPresenter.getViewPort().getCrs()); request.setLocation(location); request.setServicePattern(servicePattern); command.setCommandRequest(request); GeomajasServerExtension.getInstance().getCommandService().execute(command, new AbstractCommandCallback<GetLocationForStringResponse>() { public void execute(GetLocationForStringResponse response) { goToLocation(response, location); } }); }
@Override public void goToLocation(final GetLocationForStringResponse response, final String location) { if (response.isLocationFound()) { fireGeocoderEvent(new SelectLocationEvent(mapPresenter, response)); } else { List<GetLocationForStringAlternative> alternatives = response.getAlternatives(); if (null != alternatives && alternatives.size() > 0) { fireGeocoderEvent(new SelectAlternativeEvent(mapPresenter, alternatives)); } else { fireGeocoderEvent(new LocationNotFoundEvent(location)); } } }
private ListGridRecord[] toRecords(List<GetLocationForStringAlternative> alternatives) { ListGridRecord[] records = new ListGridRecord[alternatives.size()]; for (int i = 0; i < records.length; i++) { GetLocationForStringAlternative alt = alternatives.get(i); ListGridRecord record = new ListGridRecord(); record.setAttribute(LOCATION_FIELD, alt.getCanonicalLocation()); record.setAttribute(LOCATION_OBJECT, alt); records[i] = record; } return records; }
@Override public GetLocationForStringResponse getEmptyCommandResponse() { return new GetLocationForStringResponse(); }
public SelectLocationEvent(MapPresenter mapPresenter, GetLocationForStringAlternative alternative) { super(); this.mapPresenter = mapPresenter; canonicalLocation = alternative.getCanonicalLocation(); center = alternative.getCenter(); bbox = alternative.getBbox(); geocoderName = alternative.getGeocoderName(); userData = alternative.getUserData(); }
public SelectLocationEvent(MapPresenter mapPresenter, GetLocationForStringResponse alternative) { super(); this.mapPresenter = mapPresenter; canonicalLocation = alternative.getCanonicalLocation(); center = alternative.getCenter(); bbox = alternative.getBbox(); geocoderName = alternative.getGeocoderName(); userData = alternative.getUserData(); }
public void goToLocation(final String location) { GwtCommand command = new GwtCommand(GetLocationForStringRequest.COMMAND); GetLocationForStringRequest request = new GetLocationForStringRequest(); request.setCrs(map.getMapModel().getCrs()); request.setLocation(location); request.setServicePattern(servicePattern); if (GWT.isClient()) { // causes NPE when run as junit test String locale = LocaleInfo.getCurrentLocale().getLocaleName(); if (!"default".equals(locale)) { request.setLocale(locale); } } command.setCommandRequest(request); GwtCommandDispatcher.getInstance().execute(command, new AbstractCommandCallback<GetLocationForStringResponse>() { public void execute(GetLocationForStringResponse response) { goToLocation(response, location); } }); }
public void goToLocation(final CommandResponse commandResponse, final String location) { if (commandResponse instanceof GetLocationForStringResponse) { GetLocationForStringResponse response = (GetLocationForStringResponse) commandResponse; if (response.isLocationFound()) { removeAltWindow(); handlerManager.fireEvent(new SelectLocationEvent(map, response)); } else { List<GetLocationForStringAlternative> alternatives = response.getAlternatives(); if (null != alternatives && alternatives.size() > 0) { handlerManager.fireEvent(new SelectAlternativeEvent(map, alternatives)); } else { SC.say(messages.locationNotFound(location)); } } } }
@Override public void setAlternatives(List<GetLocationForStringAlternative> alternatives) { alternativesPanel.clear(); for (GetLocationForStringAlternative alternative : alternatives) { final String altText = alternative.getCanonicalLocation(); Label altLabel = new Label(altText); altLabel.setStyleName(resource.css().geocoderGadgetAltLabel()); altLabel.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { alternativesPresenter.findLocation(altText); } }); alternativesPanel.add(altLabel); } }