Java 类com.google.gwt.event.dom.client.ErrorHandler 实例源码

项目:appinventor-extensions    文件:GalleryPage.java   
/**
 * Helper method to update the app image
 * @param url  The URL of the image to show
 * @param container  The container that image widget resides
 */
private void updateAppImage(String url, final Panel container) {
    image = new Image();
    image.addStyleName("app-image");
    image.setUrl(url);
    // if the user has provided a gallery app image, we'll load it. But if not
    // the error will occur and we'll load default image
    image.addErrorHandler(new ErrorHandler() {
      public void onError(ErrorEvent event) {
        image.setUrl(GalleryApp.DEFAULTGALLERYIMAGE);
      }
    });
    container.add(image);

    if(gallery.getSystemEnvironment() != null &&
        gallery.getSystemEnvironment().toString().equals("Development")){
      final OdeAsyncCallback<String> callback = new OdeAsyncCallback<String>(
        // failure message
        MESSAGES.galleryError()) {
          @Override
          public void onSuccess(String newUrl) {
            image.setUrl(newUrl + "?" + System.currentTimeMillis());
          }
        };
      Ode.getInstance().getGalleryService().getBlobServingUrl(url, callback);
    }
}
项目:appinventor-extensions    文件:ProfilePage.java   
/**
 * Helper method to update the user's image
 * @param url  The URL of the image to show
 * @param container  The container that image widget resides
 */
private void updateUserImage(final String url, Panel container) {
  userAvatar = new Image();
  //setUrl if the new URL is the same one as it was before; an easy workaround is
  //to make the URL unique so it forces the browser to reload
  userAvatar.setUrl(url + "?" + System.currentTimeMillis());
  userAvatar.addStyleName("app-image");
  if (profileStatus == PRIVATE) {
    //userAvatar.addStyleName("status-updating");
  }
  // if the user has provided a gallery app image, we'll load it. But if not
  // the error will occur and we'll load default image
  userAvatar.addErrorHandler(new ErrorHandler() {
    public void onError(ErrorEvent event) {
      userAvatar.setUrl(GalleryApp.DEFAULTUSERIMAGE);
    }
  });
  container.add(userAvatar);

  if(gallery.getSystemEnvironment() != null &&
      gallery.getSystemEnvironment().toString().equals("Development")){
    final OdeAsyncCallback<String> callback = new OdeAsyncCallback<String>(
      // failure message
      MESSAGES.galleryError()) {
        @Override
        public void onSuccess(String newUrl) {
          userAvatar.setUrl(newUrl + "?" + System.currentTimeMillis());
        }
      };
    Ode.getInstance().getGalleryService().getBlobServingUrl(url, callback);
  }
}
项目:appinventor-extensions    文件:GalleryGuiFactory.java   
private GalleryAppWidget(final GalleryApp app) {
  nameLabel = new Label(app.getTitle());
  authorLabel = new Label(app.getDeveloperName());
  numDownloadsLabel = new Label(Integer.toString(app.getDownloads()));
  numLikesLabel = new Label(Integer.toString(app.getLikes()));
  numViewsLabel = new Label(Integer.toString(app.getViews()));
  numCommentsLabel = new Label(Integer.toString(app.getComments()));
  image = new Image();
  image.addErrorHandler(new ErrorHandler() {
    public void onError(ErrorEvent event) {
      image.setUrl(GalleryApp.DEFAULTGALLERYIMAGE);
    }
  });
  String url = gallery.getCloudImageURL(app.getGalleryAppId());
  image.setUrl(url);

  if(gallery.getSystemEnvironment() != null &&
      gallery.getSystemEnvironment().toString().equals("Development")){
    final OdeAsyncCallback<String> callback = new OdeAsyncCallback<String>(
      // failure message
      MESSAGES.galleryError()) {
        @Override
        public void onSuccess(String newUrl) {
          image.setUrl(newUrl + "?" + System.currentTimeMillis());
        }
      };
    Ode.getInstance().getGalleryService().getBlobServingUrl(url, callback);
  }
}
项目:iambookmaster    文件:ParagraphEditor.java   
public ImageSprite(Sprite sprite) {
    this.sprite = sprite;
    addErrorHandler(new ErrorHandler(){
        public void onError(ErrorEvent event) {
            Window.alert(appMessages.paragraphCannotLoadImage(backImage.getUrl()));
        }
    });
    setUrl(sprite.getPicture().getUrl());
}
项目:firefly    文件:BasicPagingImageGrid.java   
public void addErrorHandler(ErrorHandler errorHandler) {
    this.errorHandler = errorHandler;
}
项目:iambookmaster    文件:IPhoneScrollPanel.java   
public PublicImage(String url, LoadHandler loadHandler, ErrorHandler errorHandler) {
    addLoadHandler(loadHandler);
    addErrorHandler(errorHandler);
    setUrl(url);
}