Example usage for com.google.gwt.ajaxfeed.client.impl Globals API

List of usage examples for com.google.gwt.ajaxfeed.client.impl Globals API

Introduction

In this page you can find the example usage for com.google.gwt.ajaxfeed.client.impl Globals API.

Prototype

Globals API

To view the source code for com.google.gwt.ajaxfeed.client.impl Globals API.

Click Source Link

Usage

From source file:com.google.gwt.sample.feedreader.client.FeedSelectPanel.java

License:Apache License

public FeedSelectPanel(final ConfigurationPanel parent, final Configuration configuration, String query) {
    super("Select feed...", parent);

    FeedCallback fc = new FeedCallback() {
        public void onLoad(final JavaScriptObject jso) {
            RESULT_API.bind(jso);//w  w w.j  a v a  2  s  .c o  m

            ErrorWrapper error = RESULT_API.getError(jso);
            if (error != null) {
                Window.alert("Unable to find feeds.\n" + error.getMessage());
                return;
            }

            // Remove the loading message
            clear();

            // Update the UI piecewise
            DeferredCommand.addCommand(new IncrementalCommand() {
                List feeds = configuration.getFeeds();
                Iterator i = RESULT_API.getEntries(jso).iterator();

                public boolean execute() {
                    final FindResultApi.Entry entry = (FindResultApi.Entry) i.next();
                    if (feeds.contains(entry.getUrl())) {
                        return i.hasNext();
                    }

                    UnsunkLabel title = new UnsunkLabel(entry.getTitle(), true);
                    title.addStyleName("title");
                    UnsunkLabel snippit = new UnsunkLabel(entry.getContentSnippet(), true);
                    snippit.addStyleName("snippit");
                    UnsunkLabel url = new UnsunkLabel(entry.getUrl());
                    url.addStyleName("snippit");

                    FlowPanel vp = new FlowPanel();
                    vp.add(title);
                    vp.add(snippit);
                    vp.add(url);

                    add(new PanelLabel(vp, new Command() {
                        public void execute() {
                            History.newItem(entry.getUrl());
                        }
                    }));

                    return i.hasNext();
                }
            });
        }
    };

    Globals.API.findFeeds(query, fc);

    addStyleName("FeedSelectPanel");
    add(new PanelLabel("Waiting for results"));
}