Example usage for com.google.gwt.gdata.client.gbase ItemsEntry getTitle

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

Introduction

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

Prototype

public final native Text getTitle() ;

Source Link

Document

Returns the title.

Usage

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

License:Apache License

/**
 * Create an item by inserting an item entry into
 * an items feed.//from  ww w  .  j a v  a2s .c o  m
 * Set the item's title to an arbitrary string. Here
 * we prefix the title with 'GWT-GoogleBase-Client' so that
 * we can identify which items were created by this demo.
 * The new item is created as a product review with values
 * for the default product review attributes.
 * On success and failure, display a status message.
 * 
 * @param itemsFeedUri The uri of the items feed into which
 * to insert the new item entry
 */
private void createItem(String itemsFeedUri) {
    showStatus("Creating item...", false);
    ItemsEntry entry = ItemsEntry.newInstance();
    entry.setTitle(Text.newInstance());
    entry.getTitle().setText("GWT-GoogleBase-Client - inserted item");
    entry.setContent(Text.newInstance());
    entry.getContent().setText("GData is great data!! :)");

    Attribute targetCountry = Attribute.newInstance();
    targetCountry.setValue("US");
    Attribute reviewType = Attribute.newInstance();
    reviewType.setValue("Product Review");
    Attribute nameOfItem = Attribute.newInstance();
    nameOfItem.setValue("gwt-gdata");
    Attribute expirationDate = Attribute.newInstance();
    expirationDate.setValue("2038-01-19T03:14:07Z");
    Attribute rating = Attribute.newInstance();
    rating.setValue("5-Excellent");
    Attribute customerId = Attribute.newInstance();
    customerId.setValue("5752122");
    Attribute itemType = Attribute.newInstance();
    itemType.setValue("Reviews");
    Attribute itemLanguage = Attribute.newInstance();
    itemLanguage.setValue("en");

    entry.setAttribute("target_country", targetCountry);
    entry.setAttribute("review_type", reviewType);
    entry.setAttribute("name_of_item_reviewed", nameOfItem);
    entry.setAttribute("expiration_date", expirationDate);
    entry.setAttribute("rating", rating);
    entry.setAttribute("customer_id", customerId);
    entry.setAttribute("item_type", itemType);
    entry.setAttribute("item_language", itemLanguage);

    service.insertEntry(itemsFeedUri, entry, new ItemsEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while creating an item: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsEntry result) {
            showStatus("Created an item.", false);
        }
    });
}

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.//from ww w  . j av  a  2 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./* w w w  .  j a v a 2  s. 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

/**
* Displays a set of Google Base item entries in a tabular 
* fashion with the help of a GWT FlexTable widget. The data fields 
* Title, URL and Published are displayed.
* 
* @param entries The Google Base item entries to display.
*//* ww  w  . jav  a 2 s . c om*/
private void showData(ItemsEntry[] entries) {
    mainPanel.clear();
    String[] labels = new String[] { "Title", "URL", "Published" };
    mainPanel.insertRow(0);
    for (int i = 0; i < labels.length; i++) {
        mainPanel.addCell(0);
        mainPanel.setWidget(0, i, new Label(labels[i]));
        mainPanel.getFlexCellFormatter().setStyleName(0, i, "hm-tableheader");
    }
    for (int i = 0; i < entries.length; i++) {
        ItemsEntry entry = entries[i];
        int row = mainPanel.insertRow(i + 1);
        mainPanel.addCell(row);
        mainPanel.setWidget(row, 0, new Label(entry.getTitle().getText()));
        mainPanel.addCell(row);
        if (entry.getHtmlLink() == null) {
            mainPanel.setWidget(row, 1, new Label("Not available"));
        } else {
            String link = entry.getHtmlLink().getHref();
            mainPanel.setWidget(row, 1,
                    new HTML("<a href=\"" + link + "\" target=\"_blank\">" + link + "</a>"));
            mainPanel.addCell(row);
            mainPanel.setWidget(row, 2, new Label(entry.getPublished().getValue().getDate().toString()));
        }
    }
}

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.//  w ww  . ja  v  a2  s. com
 * 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);
            }
        }
    });
}

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

License:Apache License

/**
 * Update an item by making use of the updateEntry
 * method of the Entry class.//from  w w w  .  j a va 2s .  c  o m
 * Set the item's title to an arbitrary string. Here
 * we prefix the title with 'GWT-GoogleBase-Client' so that
 * we can identify which items were updated by this demo.
 * We also update the target_country property for this item.
 * On success and failure, display a status message.
 * 
 * @param itemsEntry The item entry which to update
 */
private void updateItem(ItemsEntry itemsEntry) {
    showStatus("Updating item...", false);
    itemsEntry.setTitle(Text.newInstance());
    itemsEntry.getTitle().setText("GWT-GoogleBase-Client - updated item");
    MapAttribute attributes = itemsEntry.getAttributes();
    if (attributes.contains("target_country")) {
        attributes.get("target_country")[0].setValue("UK");
    }
    itemsEntry.updateEntry(new ItemsEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while updating an item: " + caught.getMessage(), true);
        }

        public void onSuccess(ItemsEntry result) {
            showStatus("Updated an item.", false);
        }
    });
}