Example usage for com.google.gwt.gdata.client.calendar CalendarEntry getSelfLink

List of usage examples for com.google.gwt.gdata.client.calendar CalendarEntry getSelfLink

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.calendar CalendarEntry getSelfLink.

Prototype

public final native com.google.gwt.gdata.client.Link getSelfLink() ;

Source Link

Document

Returns the link that provides the URI of the feed or entry.

Usage

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

License:Apache License

/**
 * Retrieve the calendars feed using the calendar service and
 * the calendars feed uri.// w ww  .  j a v  a  2s.co  m
 * On success, identify the first calendar entry with a title starting
 * with "GWT-Calendar-Client", this will be the calendar that will be
 * deleted.
 * If no calendar is found, display a message.
 * Otherwise call deleteCalendar to delete the calendar. Alternatively
 * we could also have used targetCalendar.deleteEntry to
 * delete the calendar, but the effect is the same.
 * 
 * @param calendarsFeedUri The uri of the calendars feed
 */
private void getCalendars(String calendarsFeedUri) {
    showStatus("Loading calendars...", false);
    service.getOwnCalendarsFeed(calendarsFeedUri, new CalendarFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Calendar feed: " + caught.getMessage(), true);
        }

        public void onSuccess(CalendarFeed result) {
            CalendarEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("You have no calendars.", false);
            } else {
                CalendarEntry targetCalendar = null;
                for (CalendarEntry entry : entries) {
                    String title = entry.getTitle().getText();
                    if (title.startsWith("GWT-Calendar-Client")) {
                        targetCalendar = entry;
                        break;
                    }
                }
                if (targetCalendar == null) {
                    showStatus("Did not find a calendar entry whose title starts "
                            + "with the prefix 'GWT-Calendar-Client'.", false);
                } else {
                    String calendarEntryUri = targetCalendar.getSelfLink().getHref();
                    deleteCalendar(calendarEntryUri);
                }
            }
        }
    });
}