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

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

Introduction

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

Prototype

public final native Text getTitle() ;

Source Link

Document

Returns the title.

Usage

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

License:Apache License

/**
* Displays a set of Google Base media entries in a tabular 
* fashion with the help of a GWT FlexTable widget. The data fields
* Title and Type, along with a thumbnail preview (if available),
* are displayed.//from   w  ww  . j av a  2 s. c  om
* 
* @param entries The Google Base media entries to display.
*/
private void showData(MediaEntry[] entries) {
    mainPanel.clear();
    String[] labels = new String[] { "Title", "Type", "Thumbnail" };
    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++) {
        MediaEntry entry = entries[i];
        MediaContent media = entry.getMediaContent();
        String fileType = media.getType();
        String fileUrl = media.getUrl();
        MediaThumbnail[] thumbs = media.getThumbnails();
        int row = mainPanel.insertRow(i + 1);
        mainPanel.addCell(row);
        mainPanel.setWidget(row, 0, new HTML(
                "<a href=\"" + fileUrl + "\" target=\"_blank\">" + entry.getTitle().getText() + "</a>"));
        mainPanel.addCell(row);
        mainPanel.setWidget(row, 1, new Label(fileType));
        mainPanel.addCell(row);
        if (thumbs.length > 0) {
            MediaThumbnail thumb = thumbs[0];
            String thumbSource = thumb.getUrl();
            double thumbWidth = thumb.getWidth();
            double thumbHeight = thumb.getHeight();
            mainPanel.setWidget(row, 2, new HTML("<img src=\"" + thumbSource + " width=\"" + thumbWidth
                    + "px\" height=\"" + thumbHeight + "px\" border=\"0px\" />"));
        } else {
            mainPanel.setWidget(row, 2, new Label("Not Available"));
        }
    }
}