Example usage for com.google.gwt.gdata.client.gbase ItemsFeedCallback ItemsFeedCallback

List of usage examples for com.google.gwt.gdata.client.gbase ItemsFeedCallback ItemsFeedCallback

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.gbase ItemsFeedCallback ItemsFeedCallback.

Prototype

ItemsFeedCallback

Source Link

Usage

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseDeleteItemDemo.java

License:Apache License

/**
 * Retrieve the items feed using the Google Base service and
 * the items feed uri. In GData all get, insert, update
 * and delete methods always receive a callback defining success
 * and failure handlers./* w ww  .  ja v a2  s  .  c  o m*/
 * Here, the failure handler displays an error message while the
 * success handler obtains the first Item entry with a title
 * starting with "GWT-GoogleBase-Client" and calls deleteItem
 * to delete the item. Alternatively we could also have used
 * targetItem.deleteEntry but the effect is the same.
 * If no item is found a message is displayed.
 * 
 * @param itemsFeedUri The uri of the items feed
 */
private void getItems(String itemsFeedUri) {
    showStatus("Loading items feed...", false);
    service.getItemsFeed(itemsFeedUri, new ItemsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the items feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsFeed result) {
            ItemsEntry[] entries = result.getEntries();
            ItemsEntry targetItem = null;
            for (ItemsEntry entry : entries) {
                if (entry.getTitle().getText().startsWith("GWT-GoogleBase-Client")) {
                    targetItem = entry;
                    break;
                }
            }
            if (targetItem == null) {
                showStatus("No item found that contains 'GWT-GoogleBase-Client' " + "in the title.", false);
            } else {
                String itemsEntryUri = targetItem.getSelfLink().getHref();
                deleteItem(itemsEntryUri);
            }
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseRetrieveItemAttributesDemo.java

License:Apache License

/**
 * Retrieve the items feed using the Google Base service and
 * the items feed uri. In GData all get, insert, update
 * and delete methods always receive a callback defining success
 * and failure handlers./*from   w w  w . ja v a  2s  .  c  om*/
 * Here, the failure handler displays an error message while the
 * success handler obtains the first Item entry with a title
 * starting with "GWT-GoogleBase-Client" and calls showData
 * to display the item's attributes.
 * 
 * @param itemsFeedUri The uri of the items feed
 */
private void getItems(String itemsFeedUri) {
    showStatus("Loading items feed...", false);
    service.getItemsFeed(itemsFeedUri, new ItemsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the items feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsFeed result) {
            ItemsEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("You have no items.", false);
            } else {
                ItemsEntry targetItem = null;
                for (ItemsEntry entry : entries) {
                    String title = entry.getTitle().getText();
                    if (title.startsWith("GWT-GoogleBase-Client")) {
                        targetItem = entry;
                        break;
                    }
                }
                if (targetItem == null) {
                    showStatus("No item found that contains 'GWT-GoogleBase-Client' " + "in the title.", false);
                } else {
                    showData(targetItem.getAttributes());
                }
            }
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseRetrieveItemsDemo.java

License:Apache License

/**
 * Retrieve the items feed using the Google Base service and
 * the items feed uri. In GData all get, insert, update
 * and delete methods always receive a callback defining success
 * and failure handlers.//from  w  ww  . j  a  va 2s .c  om
 * Here, the failure handler displays an error message while the
 * success handler calls showData to display the item entries.
 * 
 * @param itemsFeedUri The uri of the items feed
 */
private void getItems(String itemsFeedUri) {
    showStatus("Loading items feed...", false);
    service.getItemsFeed(itemsFeedUri, new ItemsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the items feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsFeed result) {
            ItemsEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("You have no items.", false);
            } else {
                showData(entries);
            }
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseRetrieveMediaDemo.java

License:Apache License

/**
 * Retrieve the items feed using the Google Base service and
 * the items feed uri. In GData all get, insert, update
 * and delete methods always receive a callback defining success
 * and failure handlers.//from   w ww .ja v a 2s . co m
 * Here, the failure handler displays an error message while the
 * success handler obtains the first item entry that is associated
 * with on or more media attachments and calls getMedia to
 * retrieve its media entries.
 * 
 * @param itemsFeedUri The uri of the items feed
 */
private void getItems(String itemsFeedUri) {
    showStatus("Loading items feed...", false);
    service.getItemsFeed(itemsFeedUri, new ItemsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the items feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsFeed result) {
            ItemsEntry[] entries = result.getEntries();
            ItemsEntry targetItem = null;
            for (ItemsEntry entry : entries) {
                FeedLink<MediaFeed> link = entry.getFeedLink().cast();
                if (link.getCountHint() > 0) {
                    targetItem = entry;
                    break;
                }
            }
            if (targetItem == null) {
                showStatus("You have no items containing media.", false);
            } else {
                String itemsEntryUri = targetItem.getSelfLink().getHref();
                getMedia(itemsEntryUri);
            }
        }
    });
}

From source file:com.google.gwt.gdata.sample.hellogdata.client.GoogleBaseUpdateItemDemo.java

License:Apache License

/**
 * Retrieve the items feed using the Google Base service and
 * the items feed uri. In GData all get, insert, update
 * and delete methods always receive a callback defining success
 * and failure handlers.//from ww w .j a v a  2s. c o m
 * Here, the failure handler displays an error message while the
 * success handler obtains the first Item entry with a title
 * starting with "GWT-GoogleBase-Client" and calls updateItem
 * to update the item.
 * If no item is found a message is displayed.
 * 
 * @param itemsFeedUri The uri of the items feed
 */
private void getItems(String itemsFeedUri) {
    showStatus("Loading items feed...", false);
    service.getItemsFeed(itemsFeedUri, new ItemsFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the items feed: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsFeed result) {
            ItemsEntry[] entries = result.getEntries();
            ItemsEntry targetEntry = null;
            for (ItemsEntry entry : entries) {
                if (entry.getTitle().getText().startsWith("GWT-GoogleBase-Client")) {
                    targetEntry = entry;
                    break;
                }
            }
            if (targetEntry == null) {
                showStatus("No item found that contains 'GWT-GoogleBase-Client' " + "in the title.", false);
            } else {
                updateItem(targetEntry);
            }
        }
    });
}