Example usage for com.google.gwt.search.client WebResult getTitle

List of usage examples for com.google.gwt.search.client WebResult getTitle

Introduction

In this page you can find the example usage for com.google.gwt.search.client WebResult getTitle.

Prototype

public native String getTitle() ;

Source Link

Document

Returns the title value of the result.

Usage

From source file:com.appspot.socialinquirer.client.activity.HomeActivity.java

License:Apache License

/**
 * Creates the question./*from  ww w.j  a  v  a  2 s .c  om*/
 *
 * @param result the result
 * @return the question
 */
private Question createQuestion(WebResult result) {
    Question task = new Question();
    task.setTitle(result.getTitle());
    task.setContent(result.getContent());
    return task;
}

From source file:com.google.gwt.search.sample.hellosearch.client.HelloSearch.java

License:Apache License

public void onKeep(KeepEvent event) {
    final Result result = event.getResult();

    String title;/*from w  ww.ja  va  2s. c  o m*/
    if (result instanceof WebResult) {
        WebResult web = (WebResult) result;
        title = web.getTitle();

    } else if (result instanceof NewsResult) {
        NewsResult web = (NewsResult) result;
        title = web.getTitle();
    } else if (result instanceof VideoResult) {
        VideoResult video = (VideoResult) result;
        title = video.getTitle();
        // Metadata is also available
        System.out.println(
                video.getTbHeight() + "x" + video.getTbWidth() + " " + video.getDuration() + "seconds");
    } else {
        // Ads don't have an official interface
        title = "Advertisement";
    }

    HTML h = new HTML(title);
    h.addStyleName("clipLink");
    h.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            PopupPanel p = new PopupPanel(true);
            p.addStyleName("keepPopup");
            p.setWidget(result.getHtml());
            Widget w = (Widget) event.getSource();
            p.setPopupPosition(w.getAbsoluteLeft() + 5, w.getAbsoluteTop() + w.getOffsetHeight() + 5);
            p.show();
        }
    });
    clips.add(h);
}