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

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

Introduction

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

Prototype

public final native Text getTitle() ;

Source Link

Document

Returns the title.

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  .  ja  v  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 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.BloggerDeleteBlogPostDemo.java

License:Apache License

/**
 * Retrieve the Blogger posts feed using the Blogger service and
 * the posts feed uri for a given blog.//from  ww w . j a  v a  2 s  . c o  m
 * On success, identify the first post entry with a title starting
 * with "GWT-Blogger-Client", this will be the post that will be deleted.
 * If no post is found, display a message.
 * Otherwise call deletePost to delete the post. Alternatively
 * we could also have used targetPost.deleteEntry to
 * delete the post, but the effect is the same.
 * 
 * @param postsFeedUri The posts feed uri for a given blog
 */
private void getPosts(String postsFeedUri) {
    showStatus("Loading posts feed...", false);
    service.getBlogPostFeed(postsFeedUri, new BlogPostFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Blogger Posts " + "feed: " + caught.getMessage(),
                    true);
        }

        public void onSuccess(BlogPostFeed result) {
            PostEntry targetPost = null;
            for (PostEntry entry : result.getEntries()) {
                String title = entry.getTitle().getText();
                if (title.startsWith("GWT-Blogger-Client")) {
                    targetPost = entry;
                    break;
                }
            }
            if (targetPost == null) {
                showStatus("Did not find a post entry whose title starts with "
                        + "the prefix 'GWT-Blogger-Client'.", false);
            } else {
                deletePost(targetPost.getSelfLink().getHref());
            }
        }
    });
}

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

License:Apache License

/**
* Displays a set of Blogger post entries in a tabular fashion with
* the help of a GWT FlexTable widget. The data fields Title, URL 
* and Published are displayed.//from   ww w. j a  v  a2  s. co  m
* 
* @param entries The Blogger post entries to display.
*/
private void showData(PostEntry[] 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++) {
        PostEntry 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.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.
*//*  w  w w  .j a v  a 2 s .co 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

/**
 * Retrieve the Blogger posts feed using the Blogger service and
 * the posts feed uri for a given blog.//  ww w.  ja  va  2 s .  co m
 * On success, identify the first post entry with a title starting
 * with "GWT-Blogger-Client", this will be the post that will be updated.
 * If no post is found, display a message.
 * Otherwise call updatePost to update the post.
 * 
 * @param postsFeedUri The posts feed uri for a given blog
 */
private void getPosts(String postsFeedUri) {
    showStatus("Loading posts feed...", false);
    service.getBlogPostFeed(postsFeedUri, new BlogPostFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Blogger Posts " + "feed: " + caught.getMessage(),
                    true);
        }

        public void onSuccess(BlogPostFeed result) {
            PostEntry targetPost = null;
            for (PostEntry entry : result.getEntries()) {
                String title = entry.getTitle().getText();
                if (title.startsWith("GWT-Blogger-Client")) {
                    targetPost = entry;
                    break;
                }
            }
            if (targetPost == null) {
                showStatus("Did not find a post entry whose title starts with "
                        + "the prefix 'GWT-Blogger-Client'.", false);
            } else {
                updatePost(targetPost);
            }
        }
    });
}

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.// w  w w . j av a 2  s . com
 * 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);
        }
    });
}