List of usage examples for com.google.gwt.jsonp.client JsonpRequestBuilder requestObject
public <T extends JavaScriptObject> JsonpRequest<T> requestObject(String url, AsyncCallback<T> callback)
From source file:gov.wa.wsdot.apps.analytics.client.activities.twitter.view.search.SearchView.java
License:Open Source License
@UiHandler("moreSearchBtn") public void onMore(ClickEvent e) { int nextPage = pageNum + 1; searchLoader.setVisible(true);/*www.ja v a2s. c om*/ JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Set timeout for 30 seconds (30000 milliseconds) jsonp.setTimeout(30000); jsonp.requestObject(url + nextPage, new AsyncCallback<Mention>() { @Override public void onFailure(Throwable caught) { Window.alert("Failure: " + caught.getMessage()); searchLoader.setVisible(false); } @Override public void onSuccess(Mention mention) { if (mention.getMentions() != null) { pageNum++; updateSearch(mention.getMentions()); searchLoader.setVisible(false); } } }); }
From source file:gov.wa.wsdot.apps.analytics.client.activities.twitter.view.search.SearchView.java
License:Open Source License
@EventHandler void onSearch(SearchEvent e) { pageNum = 1;/*from www . j av a 2 s . co m*/ backToSearchTopBtn.setVisible(false); searchText = e.getSearchText(); searchList.clear(); moreSearchBtn.setVisible(false); exportLink.setVisible(false); tweetSearch.setText(e.getSearchText()); String url = getUrl(e); searchLoader.setVisible(true); JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Set timeout for 30 seconds (30000 milliseconds) jsonp.setTimeout(30000); jsonp.requestObject(url + pageNum, new AsyncCallback<Mention>() { @Override public void onFailure(Throwable caught) { Window.alert("Failure: " + caught.getMessage()); searchLoader.setVisible(false); } @Override public void onSuccess(Mention mention) { if (mention.getMentions() != null) { updateSearch(mention.getMentions()); searchLoader.setVisible(false); } } }); }
From source file:gov.wa.wsdot.apps.analytics.client.activities.twitter.view.search.SearchView.java
License:Open Source License
public void getSuggestions(String searchText) { String url = JSON_URL_SUGGESTION; String searchString = SafeHtmlUtils.htmlEscape(searchText.trim().replace("'", "")); // Append the name of the callback function to the JSON URL. url += searchString;/* www .ja va 2s .c o m*/ url = URL.encode(url); JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Set timeout for 30 seconds (30000 milliseconds) jsonp.setTimeout(30000); jsonp.requestObject(url, new AsyncCallback<Words>() { @Override public void onFailure(Throwable caught) { // Just fail silently here. } @Override public void onSuccess(Words words) { if (words.getWords() != null) { List<SearchObject> searchHints = new ArrayList<SearchObject>(); for (int i = 0; i < words.getWords().length(); i++) { SearchObject search = new SearchObject(); search.setKeyword(words.getWords().get(i)); searchHints.add(search); } updateSuggestions(searchHints); } } }); }
From source file:gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sentiment.SentimentPieChart.java
License:Open Source License
/** * Requests data from the server/*from w w w .j a v a2 s.c o m*/ * @param dateRange * @param account */ public static void updateChart(final String dateRange, final String account) { cardContent.clear(); String url = ""; String screenName = account; sentimentLoader.setVisible(true); url = JSON_URL + "/sentiment/" + screenName + dateRange; JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Set timeout for 30 seconds (30000 milliseconds) jsonp.setTimeout(30000); jsonp.requestObject(url, new AsyncCallback<SentimentSummary>() { @Override public void onFailure(Throwable caught) { Window.alert("Failure: " + caught.getMessage()); sentimentLoader.setVisible(false); } @Override public void onSuccess(SentimentSummary result) { // Create a callback to be called when the visualization API // has been loaded. sentimentSummary = result.getSentimentSummary(); // Create the API Loader ChartLoader chartLoader = new ChartLoader(ChartPackage.CORECHART); chartLoader.loadApi(new Runnable() { @Override public void run() { cardContent.add(getPieChart()); drawPieChart(sentimentSummary); sentimentLoader.setVisible(false); } }); } }); }
From source file:gov.wa.wsdot.apps.analytics.client.activities.twitter.view.sources.SourcesPieChart.java
License:Open Source License
/** * Requests data from the server/*from www . j av a 2 s.com*/ * @param dateRange * @param account */ public static void updateChart(final String dateRange, final String account) { cardContent.clear(); String url = ""; String screenName = account; sourcesLoader.setVisible(true); url = JSON_URL + "/" + screenName + dateRange; sourcesLoader.setVisible(true); JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Set timeout for 30 seconds (30000 milliseconds) jsonp.setTimeout(30000); jsonp.requestObject(url, new AsyncCallback<SourceSummary>() { @Override public void onFailure(Throwable caught) { Window.alert("Failure: " + caught.getMessage()); sourcesLoader.setVisible(false); } @Override public void onSuccess(SourceSummary result) { // Create a callback to be called when the visualization API // has been loaded. sourceSummary = result.getSourceSummary(); // Create the API Loader ChartLoader chartLoader = new ChartLoader(ChartPackage.CORECHART); chartLoader.loadApi(new Runnable() { @Override public void run() { cardContent.add(getPieChart()); drawPieChart(sourceSummary); sourcesLoader.setVisible(false); } }); } }); }
From source file:gov.wa.wsdot.apps.analytics.client.activities.twitter.view.summary.SummaryChart.java
License:Open Source License
/** * Requests tweet and mention counts from server for a given date range and account. * @param dateRange//from w ww.jav a 2s.c o m * @param account : Can be "All" */ public static void updateTweetsChart(String dateRange, String account) { tweetContent.clear(); tweetLabel.clear(); tweetLabel.setVisible(true); tweetsLoader.setVisible(true); final String url; String screenName = account; url = JSON_URL + "/" + screenName + dateRange; JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Set timeout for 30 seconds (30000 milliseconds) jsonp.setTimeout(30000); jsonp.requestObject(url, new AsyncCallback<TweetSummary>() { @Override public void onFailure(Throwable caught) { Window.alert("Failure: " + caught.getMessage()); tweetsLoader.setVisible(false); } @Override public void onSuccess(TweetSummary result) { // Create a callback to be called when the visualization API // has been loaded. tweetSummary = result.getTweetSummary(); // Create the API Loader ChartLoader chartLoader = new ChartLoader(ChartPackage.CORECHART); chartLoader.loadApi(new Runnable() { @Override public void run() { tweetContent.clear(); tweetLabel.clear(); tweetContent.add(getTweetsChart()); drawTweetsChart(tweetSummary); tweetsLoader.setVisible(false); } }); } }); }
From source file:gov.wa.wsdot.apps.analytics.client.activities.twitter.view.summary.SummaryChart.java
License:Open Source License
/** * * Requests follower counts from server for a given date range and account. * * @param dateRange/*www . j a v a 2s. c o m*/ * @param account : Can be "all" */ public static void updateChartFollowers(String dateRange, String account) { followerContent.clear(); followersLoader.setVisible(true); followersLabel.clear(); followersLabel.setVisible(true); String screenName = account; String url = ""; url = JSON_URL + "/followers/" + screenName + dateRange; JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Set timeout for 30 seconds (30000 milliseconds) jsonp.setTimeout(30000); jsonp.requestObject(url, new AsyncCallback<FollowerSummary>() { @Override public void onFailure(Throwable caught) { Window.alert("Failure: " + caught.getMessage()); followersLoader.setVisible(false); } @Override public void onSuccess(FollowerSummary result) { // Create a callback to be called when the visualization API // has been loaded. followerSummary = result.getFollowerSummary(); // Create the API Loader ChartLoader chartLoader = new ChartLoader(ChartPackage.CORECHART); chartLoader.loadApi(new Runnable() { @Override public void run() { followerContent.add(getFollowersChart()); drawFollowersChart(followerSummary); followersLoader.setVisible(false); followersLabel.setVisible(true); } }); } }); }
From source file:gov.wa.wsdot.apps.analytics.client.activities.twitter.view.tweet.TweetView.java
License:Open Source License
private void updateSentiment(final String sentimentType) { String url = JSON_URL + this.id + "/" + sentimentType; JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Set timeout for 30 seconds (30000 milliseconds) jsonp.setTimeout(30000);//from www . j a va2 s .c o m jsonp.requestObject(url, new AsyncCallback<Mention>() { @Override public void onFailure(Throwable caught) { Window.alert("Failure: " + caught.getMessage()); } @Override public void onSuccess(Mention result) { if (sentimentType.equalsIgnoreCase("positive")) { sentiment.setIconType(IconType.SENTIMENT_SATISFIED); sentiment.setIconColor("teal accent-4"); } else if (sentimentType.equalsIgnoreCase("negative")) { sentiment.setIconType(IconType.SENTIMENT_DISSATISFIED); sentiment.setIconColor("deep-orange"); } else { sentiment.setIconType(IconType.SENTIMENT_NEUTRAL); sentiment.setIconColor("black"); } } }); }
From source file:gov.wa.wsdot.apps.analytics.client.activities.twitter.view.tweets.TweetsView.java
License:Open Source License
@EventHandler void onSentimentDisplay(SentimentDisplayEvent event) { pageNum = 1;// w ww .j a va 2s . co m tweetsList.clear(); moreTweetsBtn.setVisible(false); String url = Consts.HOST_URL + "/mentions/" + event.getSentiment() + "/" + currentAccount + startDate + endDate + "/"; currentUrl = url; tweetsLoader.setVisible(true); JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Set timeout for 30 seconds (30000 milliseconds) jsonp.setTimeout(30000); jsonp.requestObject(url + pageNum, new AsyncCallback<Mention>() { @Override public void onFailure(Throwable caught) { Window.alert("Failure: " + caught.getMessage()); tweetsLoader.setVisible(false); } @Override public void onSuccess(Mention mention) { if (mention.getMentions() != null) { updateTweetsList(mention.getMentions()); tweetsLoader.setVisible(false); } } }); }
From source file:gov.wa.wsdot.apps.analytics.client.activities.twitter.view.tweets.TweetsView.java
License:Open Source License
/** * Loads in the next set of 10 tweets using the values of currentAccount, currentDate and pageNum. * @param e/*from w ww . j a v a2s. c om*/ */ @UiHandler("moreTweetsBtn") public void onMore(ClickEvent e) { int nextPage = pageNum + 1; tweetsLoader.setVisible(true); JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); // Set timeout for 30 seconds (30000 milliseconds) jsonp.setTimeout(30000); jsonp.requestObject(currentUrl + nextPage, new AsyncCallback<Mention>() { @Override public void onFailure(Throwable caught) { Window.alert("Failure: " + caught.getMessage()); tweetsLoader.setVisible(false); } @Override public void onSuccess(Mention mention) { if (mention.getMentions() != null) { pageNum++; updateTweetsList(mention.getMentions()); tweetsLoader.setVisible(false); } } }); }