List of usage examples for com.google.gwt.search.client SearchUtils loadSearchApi
public static void loadSearchApi(Runnable onLoad)
From source file:com.appspot.socialinquirer.client.SocialInquirer.java
License:Apache License
public void onModuleLoad() { final EventBus eventBus = clientFactory.getEventBus(); final PlaceController placeController = clientFactory.getPlaceController(); final UserRpcServiceAsync userService = clientFactory.getUserService(); final EverScribeConstants constants = clientFactory.getConstants(); GWT.runAsync(new RunAsyncCallback() { public void onFailure(Throwable caught) { UiUtils.showErrorDialog(constants, constants.errorCodeDownloadFailed()); }//from w w w . j a v a 2 s. c o m public void onSuccess() { // Start ActivityManager for the main widget with our // ActivityMapper ActivityMapper activityMapper = new AppActivityMapper(clientFactory); ActivityManager activityManager = new ActivityManager(activityMapper, eventBus); // TODO-NM: Fix this. activityManager.setDisplay(appWidget); // Start PlaceHistoryHandler with our PlaceHistoryMapper final AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class); final PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper); userService.getRandomQuote(new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { RootPanel.get("quots").add(new HTML( "<p>There is nothing more powerful than an idea whose time has come.</p>", true)); } @Override public void onSuccess(String result) { RootPanel.get("quots").add(new HTML("<p>" + result + "</p>", true)); } }); userService.getCurrentUser(new AsyncCallback<User>() { @Override public void onFailure(Throwable caught) { MenuBar menu = createMenuBar(constants, null); RootPanel.get("menu").add(menu); RootPanel.get("content").add(appWidget); // RootPanel.get("loginPanel").add(new HTML("<a // href=\"/Auth?command=EvernoteAuth\" // class=\"login\">Login with Evernote</a>")); // handle exception; historyHandler.register(placeController, eventBus, homePlace); // Goes to place represented on URL or default place historyHandler.handleCurrentHistory(); } @Override public void onSuccess(User result) { RootPanel.get("content").add(appWidget); if (result != null) { MenuBar menu = createMenuBar(constants, result); RootPanel.get("menu").add(menu); clientFactory.setUser(result); historyHandler.register(placeController, eventBus, homePlace); } else { MenuBar menu = createMenuBar(constants, null); RootPanel.get("menu").add(menu); historyHandler.register(placeController, eventBus, homePlace); } // Goes to place represented on URL or default place historyHandler.handleCurrentHistory(); } }); } }); SearchUtils.loadSearchApi(new Runnable() { public void run() { } }); }
From source file:com.google.gwt.search.sample.hellosearch.client.HelloSearch.java
License:Apache License
public void onModuleLoad() { clips.setWidth("100%"); clips.addStyleName("clips"); clips.add(new Label("Saved Clippings:")); clips.setWidth(CLIP_WIDTH + "px"); hp.add(clips);/*from w w w .ja va2s .co m*/ final Label loadingLabel = new Label("Loading..."); hp.add(loadingLabel); hp.setWidth("100%"); hp.getElement().getStyle().setPropertyPx("margin", 15); RootPanel.get().add(hp); // Use the AjaxLoader to load the Search API before running the rest of // the startup. SearchUtils.loadSearchApi(new Runnable() { public void run() { hp.remove(loadingLabel); onApiLoad(); } }); }
From source file:next.celebs.api.API.java
License:Apache License
public void getPhotos(final Key searchKey, final int numberPages, final Response<JsArray<ImageResult>> response) { final SearchResultsHandler resultHandler = new SearchResultsHandler() { @Override/* www . j a v a 2s.c om*/ public void onSearchResults(SearchResultsEvent event) { JsArray<ImageResult> data = (JsArray<ImageResult>) event.getResults(); response.read(data); } }; SearchUtils.loadSearchApi(new Runnable() { public void run() { ImageSearch search = initImageSearch(resultHandler); search.execute(searchKey.getSearchQuery()); int[] page = { 1 }; gotoPage(page, numberPages, search); } }); }
From source file:next.celebs.model.API.java
License:Apache License
public void getPhotos(final Key searchKey, final int numberPages, final Response<JsArray<ImageResult>> response) { final SearchResultsHandler resultHandler = new SearchResultsHandler() { @Override/*from ww w.j av a 2 s.c o m*/ public void onSearchResults(SearchResultsEvent event) { @SuppressWarnings("unchecked") JsArray<ImageResult> data = (JsArray<ImageResult>) event.getResults(); response.read(data); } }; SearchUtils.loadSearchApi(new Runnable() { public void run() { ImageSearch search = initImageSearch(resultHandler); search.execute(searchKey.getSearchQuery()); int[] page = { 1 }; gotoPage(page, numberPages, search); } }); }