List of usage examples for com.google.gwt.gadgets.client.io Response getText
public final native String getText() ;
From source file:com.google.gwt.gadgets.sample.traveler.client.TravelerGadget.java
License:Apache License
private void buildUi(TravelerPreferences prefs) { String serverUrl = prefs.serverUrl().getValue(); if (serverUrl == null || "".equals(serverUrl)) { String specUrl = GadgetsUtil.getUrlParameters("url"); String staticContentUrl = specUrl.substring(0, specUrl.lastIndexOf('/')); serverUrl = staticContentUrl.substring(0, staticContentUrl.lastIndexOf('/')); }/*from w ww .j a v a2 s . c o m*/ if (!serverUrl.endsWith("/")) { serverUrl += "/"; } travelerServletClient = new TravelerServletClient(serverUrl); errorNotifier = ErrorNotifier.getErrorNotifier(); // Building personal tab final ResponseReceivedHandler<Object> refreshWhenDone = new ResponseReceivedHandler<Object>() { public void onResponseReceived(ResponseReceivedEvent<Object> event) { Response<Object> response = event.getResponse(); if (response.getStatusCode() == 200) { refreshPersonalMap(); } else { errorNotifier.showError(response.getStatusCode(), response.getText()); } } }; LocationHandler createHandler = new LocationHandler() { public void handle(Location location) { travelerServletClient.saveLocation(location, refreshWhenDone); } }; LocationHandler deleteHandler = new LocationHandler() { public void handle(Location location) { travelerServletClient.deleteLocation(location, refreshWhenDone); } }; personalMap = new TravelMap(createHandler, deleteHandler); refreshPersonalMap(); // Building friends tab String noPhotoUrl = serverUrl + NO_PHOTO_NAME; final PersonBrowser browser = new PersonBrowser(people, FRIENDS_DOCK_HEIGHT, noPhotoUrl); final TravelMap friendsMap = new TravelMap(); browser.setPersonClickedHandler(new PersonClickedHandler() { public void handle(String id) { friendsMap.clear(); travelerServletClient.getUsersLocations(id, new ResponseReceivedHandler<JsArray<Location>>() { public void onResponseReceived(ResponseReceivedEvent<JsArray<Location>> event) { Response<JsArray<Location>> response = event.getResponse(); if (response.getStatusCode() == 200) { friendsMap.zoomOut(); friendsMap.showLocation(response.getData()); } else { errorNotifier.showError(response.getStatusCode(), response.getText()); } } }); } }); DockLayoutPanel friendsTab = new DockLayoutPanel(Unit.PX); friendsTab.addNorth(browser, FRIENDS_DOCK_HEIGHT); friendsTab.add(friendsMap); // Building top level panel final TabLayoutPanel tabs = new TabLayoutPanel(1.5, Unit.EM); tabs.add(personalMap, "My Map"); tabs.add(friendsTab, "Friends"); tabs.setSize("100%", "100%"); tabs.addSelectionHandler(new SelectionHandler<Integer>() { public void onSelection(SelectionEvent<Integer> event) { Widget widget = tabs.getWidget(event.getSelectedItem()); if (widget instanceof RequiresResize) { ((RequiresResize) widget).onResize(); } } }); RootLayoutPanel.get().add(tabs); }
From source file:com.google.gwt.gadgets.sample.traveler.client.TravelerGadget.java
License:Apache License
private void refreshPersonalMap() { travelerServletClient.getLocations(new ResponseReceivedHandler<JsArray<Location>>() { public void onResponseReceived(ResponseReceivedEvent<JsArray<Location>> event) { Response<JsArray<Location>> response = event.getResponse(); if (response.getStatusCode() == 200) { personalMap.showLocation(response.getData()); } else { errorNotifier.showError(response.getStatusCode(), response.getText()); }/* w w w .j a v a 2s .c om*/ } }); }