Example usage for com.google.gwt.gdata.client.maps FeatureFeedCallback FeatureFeedCallback

List of usage examples for com.google.gwt.gdata.client.maps FeatureFeedCallback FeatureFeedCallback

Introduction

In this page you can find the example usage for com.google.gwt.gdata.client.maps FeatureFeedCallback FeatureFeedCallback.

Prototype

FeatureFeedCallback

Source Link

Usage

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

License:Apache License

/**
 * Retrieve the features feed for a given map using the
 * Maps service and the features feed uri.
 * In GData all get, insert, update and delete methods always
 * receive a callback defining success and failure handlers.
 * Here, the failure handler displays an error message while the
 * success handler obtains the first feature entry with a title
 * starting with "GWT-Maps-Client" and calls deleteFeature to
 * delete the feature./*w w w .  j  a  va 2s  .  c  o  m*/
 * If no feature is found, a message is displayed.
 * 
 * @param mapEntryUri The uri of the map entry for which to
 * retrieve the features feed
 */
private void getFeatures(String mapEntryUri) {
    String featuresFeedUri = mapEntryUri.replace("/feeds/maps/", "/feeds/features/") + "/full";
    showStatus("Loading features feed...", false);
    service.getFeatureFeed(featuresFeedUri, new FeatureFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the features feed: " + caught.getMessage(), true);
        }

        public void onSuccess(FeatureFeed result) {
            FeatureEntry[] entries = result.getEntries();
            FeatureEntry targetFeature = null;
            for (FeatureEntry entry : entries) {
                if (entry.getTitle().getText().startsWith("GWT-Maps-Client")) {
                    targetFeature = entry;
                    break;
                }
            }
            if (targetFeature == null) {
                showStatus("No map feature found that contains 'GWT-Maps-Client' " + "in the title.", false);
            } else {
                String featureEntryUri = targetFeature.getSelfLink().getHref();
                deleteFeature(featureEntryUri);
            }
        }
    });
}

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

License:Apache License

/**
 * Retrieve the features feed for a given map using the
 * Maps service and the features feed uri.
 * In GData all get, insert, update and delete methods always
 * receive a callback defining success and failure handlers.
 * Here, the failure handler displays an error message while the
 * success handler calls showData to display the feature entries.
 * /*from   w  ww. j  a v a2 s. c o  m*/
 * @param mapEntryUri The uri of the map entry for which to
 * retrieve the features feed
 */
private void getFeatures(String mapEntryUri) {
    String featuresFeedUri = mapEntryUri.replace("/feeds/maps/", "/feeds/features/") + "/full";
    showStatus("Loading features feed...", false);
    service.getFeatureFeed(featuresFeedUri, new FeatureFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the features feed: " + caught.getMessage(), true);
        }

        public void onSuccess(FeatureFeed result) {
            FeatureEntry[] entries = result.getEntries();
            if (entries.length == 0) {
                showStatus("The map contains no features.", false);
            } else {
                showData(entries);
            }
        }
    });
}

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

License:Apache License

/**
 * Retrieve the features feed for a given map using the
 * Maps service and the features feed uri.
 * In GData all get, insert, update and delete methods always
 * receive a callback defining success and failure handlers.
 * Here, the failure handler displays an error message while the
 * success handler obtains the first feature entry with a title
 * starting with "GWT-Maps-Client" and calls updateFeature to
 * update the feature entry.//  ww  w.  j  a  va2s.  co  m
 * If no feature is found, a message is displayed.
 * 
 * @param mapEntryUri The uri of the map entry for which to
 * retrieve the features feed
 */
private void getFeatures(String mapEntryUri) {
    String featuresFeedUri = mapEntryUri.replace("/feeds/maps/", "/feeds/features/") + "/full";
    showStatus("Loading features feed...", false);
    service.getFeatureFeed(featuresFeedUri, new FeatureFeedCallback() {
        public void onFailure(CallErrorException caught) {
            showStatus("An error occurred while retrieving the features feed: " + caught.getMessage(), true);
        }

        public void onSuccess(FeatureFeed result) {
            FeatureEntry[] entries = result.getEntries();
            FeatureEntry targetFeature = null;
            for (FeatureEntry entry : entries) {
                if (entry.getTitle().getText().startsWith("GWT-Maps-Client")) {
                    targetFeature = entry;
                    break;
                }
            }
            if (targetFeature == null) {
                showStatus("No map feature found that contains 'GWT-Maps-Client' " + "in the title.", false);
            } else {
                updateFeature(targetFeature);
            }
        }
    });
}