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

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

Introduction

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

Prototype

public void setTimeout(int timeout) 

Source Link

Usage

From source file:gov.wa.wsdot.apps.analytics.client.activities.twitter.AnalyticsViewImpl.java

License:Open Source License

private void getStartDate() {

    String url = Consts.HOST_URL + "/summary/startTime";

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

        @Override//  ww w. j a  va  2 s .  c  o m
        public void onFailure(Throwable caught) {
            Window.alert("Failure: " + caught.getMessage());
        }

        @Override
        public void onSuccess(TweetTimes result) {
            // Fire SetDateEvent to change date picker to default date from server
            DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
            Date startDate = dateTimeFormat.parse(result.getStartDate());
            Date endDate = dateTimeFormat.parse(result.getEndDate());

            presenter.getEventBus().fireEvent(new SetDateEvent(startDate, endDate));

        }
    });
}

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

License:Open Source License

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

    list.clear();//from w w  w.  ja v a 2s. 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/retweets/" + 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();
                updateRetweetList(mention.getMentions(), list, listType);
                loader.setVisible(false);
            }
        }
    });
}

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();//ww  w  .  java  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);/*from ww w . j  a 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 w w w  .j a v a 2 s  . c  om*/
    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;//from  w  w  w .j  a  v a  2  s.  com
    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 a 2s . 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 w ww .  jav 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/*from  ww  w . ja  v  a2s .  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 va2 s.  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);
                }
            });
        }
    });
}