Example usage for com.google.gwt.jsonp.client JsonpRequestBuilder JsonpRequestBuilder

List of usage examples for com.google.gwt.jsonp.client JsonpRequestBuilder JsonpRequestBuilder

Introduction

In this page you can find the example usage for com.google.gwt.jsonp.client JsonpRequestBuilder JsonpRequestBuilder.

Prototype

JsonpRequestBuilder

Source Link

Usage

From source file:gov.wa.wsdot.apps.analytics.client.activities.twitter.view.ranking.RankingView.java

License:Open Source License

public static void getLikes(String account, Date start, Date end, final MaterialCollection list,
        final String listType) {

    list.clear();/*from ww  w  .j  av  a  2 s .c  o m*/

    DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d");
    String startDate = fmt.format(start);
    String endDate = fmt.format(end);
    String screenName = account;

    String url = Consts.HOST_URL + "/summary/statuses/favorites/" + listType + "/" + screenName + startDate
            + endDate;

    loader.setVisible(true);

    JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
    // Set timeout for 30 seconds (30000 milliseconds)
    jsonp.setTimeout(30000);
    jsonp.requestObject(url, new AsyncCallback<Mention>() {

        @Override
        public void onFailure(Throwable caught) {
            Window.alert("Failure: " + caught.getMessage());
            loader.setVisible(false);
        }

        @Override
        public void onSuccess(Mention mention) {
            if (mention.getMentions() != null) {
                list.clear();
                updateLikesList(mention.getMentions(), list, listType);
                loader.setVisible(false);
            }
        }
    });
}

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);/*w  w  w .  j  a va2 s .c o m*/

    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;// ww  w  .j  a  v 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;//w  ww . ja va 2  s  .  c om
    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/* w w w  .  j a  v a 2 s  .  c om*/
 * @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   w  w w.  j a v a  2 s .c om
 * @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//  w  w w . j  av  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/*w  ww .j  a v a2 s . com*/
 * @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);/*w w  w  .  j av a 2 s .  co 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;//from   w  w  w .  ja va2 s  .  c o 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);
            }
        }
    });
}