Example usage for com.google.gwt.gdata.client.blogger PostEntry getContent

List of usage examples for com.google.gwt.gdata.client.blogger PostEntry getContent

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.blogger PostEntry getContent.

Prototype

public final native Text getContent() ;

Source Link

Document

Returns the content.

Usage

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

License:Apache License

/**
 * Create a blog post by inserting a post entry into
 * a blog posts feed./*from  w  w w.jav a2 s . c om*/
 * Set the post's title and contents to an arbitrary string. Here
 * we prefix the title with 'GWT-Blogger-Client' so that
 * we can identify which posts were created by this demo.
 * To avoid publishing the new post we set the Atom control status
 * to "draft".
 * Finally, we associate the new post with two categories.
 * On success and failure, display a status message.
 * 
 * @param postFeed The post feed into which to insert the new post
 */
private void insertPost(BlogPostFeed postFeed) {
    showStatus("Creating blog post entry...", false);
    PostEntry newPost = PostEntry.newInstance();
    newPost.setTitle(Text.newInstance());
    newPost.getTitle().setText("GWT-Blogger-Client - inserted post");
    newPost.setContent(Text.newInstance());
    newPost.getContent().setText("This is the body of the blog post. We " + "can include <b>HTML</b> tags.");
    newPost.setControl(Control.newInstance());
    newPost.getControl().setDraft(Draft.newInstance());
    newPost.getControl().getDraft().setValue(Draft.VALUE_YES);
    Category cat1 = Category.newInstance();
    cat1.setScheme("http://www.blogger.com/atom/ns#");
    cat1.setTerm("Label1");
    Category cat2 = Category.newInstance();
    cat2.setLabel("http://www.blogger.com/atom/ns#");
    cat2.setTerm("Label2");
    newPost.setCategories(new Category[] { cat1, cat2 });
    postFeed.insertEntry(newPost, new PostEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while creating a blog post: " + caught.getMessage(), true);
        }

        public void onSuccess(PostEntry result) {
            showStatus("Created a blog entry titled '" + result.getTitle().getText() + "'.", false);
        }
    });
}

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

License:Apache License

/**
* Displays a Blogger post entry in a tabular fashion with
* the help of a GWT FlexTable widget. The data fields Title, 
* Author, Published and Contents are displayed.
* 
* @param entry The Blogger post entry to display.
*/// ww w.  j av a2 s .  c o  m
private void showData(PostEntry entry) {
    mainPanel.clear();
    mainPanel.insertRow(0);
    mainPanel.addCell(0);
    mainPanel.setWidget(0, 0, new HTML("<h2>" + entry.getTitle().getText() + "</h2>"));
    mainPanel.insertRow(1);
    mainPanel.addCell(1);
    mainPanel.setWidget(1, 0, new HTML("<i>By " + entry.getAuthors()[0].getName().getValue() + " on "
            + entry.getPublished().getValue().getDate().toString() + "</i>"));
    mainPanel.insertRow(2);
    mainPanel.addCell(2);
    mainPanel.setWidget(2, 0, new Label(entry.getContent().getText()));
}

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

License:Apache License

/**
 * Update a blog post by making use of the updateEntry
 * method of the Entry class./*from  ww  w . jav  a  2 s.c o m*/
 * Set the post's title and contents to an arbitrary string. Here
 * we prefix the title with 'GWT-Blogger-Client' so that
 * we can identify which posts were updated by this demo.
 * We also update the name of one of the post's categories.
 * On success and failure, display a status message.
 * 
 * @param postEntry The post entry which to update
 */
private void updatePost(PostEntry postEntry) {
    showStatus("Updating post entry...", false);
    postEntry.getTitle().setText("GWT-Blogger-Client - updated post");
    postEntry.setContent(Text.newInstance());
    postEntry.getContent().setText("My updated post");
    Category[] categories = postEntry.getCategories();
    for (Category category : categories) {
        if (category.getTerm().equals("Label1")) {
            category.setTerm("Label1-updated");
        }
    }
    postEntry.updateEntry(new PostEntryCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while updating a blog post: " + caught.getMessage(), true);
        }

        public void onSuccess(PostEntry result) {
            showStatus("Updated a blog entry.", false);
        }
    });
}