Example usage for com.google.gwt.gdata.client.calendar CalendarEventQuery newInstance

List of usage examples for com.google.gwt.gdata.client.calendar CalendarEventQuery newInstance

Introduction

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

Prototype

public static native CalendarEventQuery newInstance(String feedUri) ;

Source Link

Document

Constructs a calendar event query.

Usage

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

License:Apache License

/**
 * Retrieves a calendar feed using a Query object.
 * In GData, feed URIs can contain querystring parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * We query for events with a title starting with 
 * "GWT-Calendar-Client", this is the event that will be deleted.
 * If no event is found, display a message.
 * Otherwise call deleteEvent to delete the event. Alternatively
 * we could also have used targetEvent.deleteEntry to
 * delete the event, but the effect is the same.
 * /* w  ww .  ja v  a 2  s  . c o m*/
 * @param calendarsFeedUri The uri of the calendars feed
 */
private void queryCalendars(String calendarsFeedUri) {
    showStatus("Querying for events...", false);
    CalendarEventQuery query = CalendarEventQuery.newInstance(calendarsFeedUri);
    query.setFullTextQuery("GWT-Calendar-Client");
    service.getEventsFeed(query, new CalendarEventFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Event feed: " + caught.getMessage(), true);
        }

        public void onSuccess(CalendarEventFeed result) {
            CalendarEventEntry[] entries = (CalendarEventEntry[]) result.getEntries();
            if (entries.length == 0) {
                showStatus("No events found containing the text 'GWT-Calendar-Client'.", false);
            } else {
                CalendarEventEntry targetEvent = entries[0];
                String eventEntryUri = targetEvent.getEditLink().getHref();
                deleteEvent(eventEntryUri, targetEvent.getEtag());
            }
        }
    });
}

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

License:Apache License

/**
 * Retrieves an events feed using a Query object.
 * In GData, feed URIs can contain querystring parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * Upon successfully receiving the events feed, the event entries 
 * are displayed to the user via the showData method.
 * The MinimumStartTime and MaximumStartTime parameters are used to
 * limit the range of events to a given time period.
 * //w ww.j  a v  a2s.com
 * @param eventsFeedUri The uri of the events feed
 */
@SuppressWarnings("deprecation")
private void queryEvents(String eventsFeedUri) {
    showStatus("Querying for events...", false);
    CalendarEventQuery query = CalendarEventQuery.newInstance(eventsFeedUri);
    Date startDate = new Date();
    startDate.setMonth(startDate.getMonth() - 1);
    Date endDate = new Date();
    query.setMinimumStartTime(DateTime.newInstance(startDate));
    query.setMaximumStartTime(DateTime.newInstance(endDate));
    service.getEventsFeed(query, new CalendarEventFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Event feed: " + caught.getMessage(), true);
        }

        public void onSuccess(CalendarEventFeed result) {
            CalendarEventEntry[] entries = (CalendarEventEntry[]) result.getEntries();
            if (entries.length == 0) {
                showStatus("No events found for the past month.", false);
            } else {
                showData(entries);
            }
        }
    });
}

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

License:Apache License

/**
 * Retrieves an events feed using a Query object.
 * In GData, feed URIs can contain querystring parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * Upon successfully receiving the events feed, the event entries 
 * are displayed to the user via the showData method.
 * The FullTextQuery parameter is used to search for events
 * containing a specific text string.// w  w w.ja  va  2s. c om
 * 
 * @param eventsFeedUri The uri of the events feed
 */
private void queryEvents(String eventsFeedUri) {
    showStatus("Querying for events...", false);
    CalendarEventQuery query = CalendarEventQuery.newInstance(eventsFeedUri);
    query.setFullTextQuery("GWT-Calendar-Client");
    service.getEventsFeed(query, new CalendarEventFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Event feed: " + caught.getMessage(), true);
        }

        public void onSuccess(CalendarEventFeed result) {
            CalendarEventEntry[] entries = (CalendarEventEntry[]) result.getEntries();
            if (entries.length == 0) {
                showStatus("No events found containing the text 'GWT-Calendar-Client'.", false);
            } else {
                showData(entries);
            }
        }
    });
}

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

License:Apache License

/**
 * Retrieves a Calendar events feed using a Query object.
 * In GData, feed URIs can contain querystring parameters. The
 * GData query objects aid in building parameterized feed URIs.
 * On success, identify the first event entry with a title starting
 * with "GWT-Calendar-Client", this will be the event that will be updated.
 * If no event is found, display a message.
 * Otherwise call updateEvent to update the event.
 * /*from w  w w  .  j  av a  2s.c om*/
 * @param eventsFeedUri The uri of the events feed
 */
private void queryEvents(String eventsFeedUri) {
    showStatus("Querying for events...", false);
    CalendarEventQuery query = CalendarEventQuery.newInstance(eventsFeedUri);
    query.setFullTextQuery("GWT-Calendar-Client");
    service.getEventsFeed(query, new CalendarEventFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the Event feed: " + caught.getMessage(), true);
        }

        public void onSuccess(CalendarEventFeed result) {
            CalendarEventEntry[] entries = (CalendarEventEntry[]) result.getEntries();
            if (entries.length == 0) {
                showStatus("No events found containing the text 'GWT-Calendar-Client'.", false);
            } else {
                CalendarEventEntry targetEvent = null;
                for (CalendarEventEntry entry : entries) {
                    String title = entry.getTitle().getText();
                    if (title.startsWith("GWT-Calendar-Client")) {
                        targetEvent = entry;
                        break;
                    }
                }
                if (targetEvent == null) {
                    showStatus("Did not find a event entry whose title starts with "
                            + "the prefix 'GWT-Calendar-Client'.", false);
                } else {
                    updateEvent(targetEvent);
                }
            }
        }
    });
}