当前位置: 首页>>代码示例>>Java>>正文


Java Image.addErrorHandler方法代码示例

本文整理汇总了Java中com.google.gwt.user.client.ui.Image.addErrorHandler方法的典型用法代码示例。如果您正苦于以下问题:Java Image.addErrorHandler方法的具体用法?Java Image.addErrorHandler怎么用?Java Image.addErrorHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.user.client.ui.Image的用法示例。


在下文中一共展示了Image.addErrorHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadImage

import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
/**
         * Shows a resource as the {@code <img>} element.
         */
        public void loadImage(String url) {
            ClientUtils.setMembers(display, imgContainer);
            image = new Image();
            image.addLoadHandler(this);
            image.addErrorHandler(this);
            image.setUrl(url);
            drawHandler = imgContainer.addDrawHandler(this);
            resizedHandler = imgContainer.addResizedHandler(this);
            ClientUtils.fine(LOG, "loadImage url: %s, width: %s", url, image.getWidth());
            if (image.getWidth() == 0) {
                WidgetCanvas widgetCanvas = new WidgetCanvas(image);
                widgetCanvas.setVisible(false);
                widgetCanvas.setWidth(1);
                widgetCanvas.setHeight(1);
                widgetCanvas.draw();
                Img loadingImg = new Img("[SKIN]/loadingSmall.gif", 16, 16);
//                Img loadingImg = new Img("[SKIN]/shared/progressCursorTracker.gif", 16, 16);
                loadingImg.setAltText(i18n.ImportBatchDataSource_State_LOADING());
                loadingImg.setPrompt(i18n.ImportBatchDataSource_State_LOADING());
                loadingImg.setLayoutAlign(Alignment.CENTER);
                imgContainer.setMembers(loadingImg, widgetCanvas);
            }
            scheduleForRender();
        }
 
开发者ID:proarc,项目名称:proarc,代码行数:28,代码来源:DigitalObjectPreview.java

示例2: updateAppImage

import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:32,代码来源:GalleryPage.java

示例3: updateUserImage

import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:37,代码来源:ProfilePage.java

示例4: GalleryAppWidget

import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
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);
  }
}
 
开发者ID:mit-cml,项目名称:appinventor-extensions,代码行数:30,代码来源:GalleryGuiFactory.java

示例5: ImageContainer

import com.google.gwt.user.client.ui.Image; //导入方法依赖的package包/类
public ImageContainer(String imageUrl, boolean isSecure) {
	image = new Image(imageUrl);
	//this.loadedCallbacks.add(loadedCallback);
	image.addLoadHandler(this);
	image.addErrorHandler(this);
	image.setVisible(false);
	
	if (!image.getUrl().equalsIgnoreCase("")) {
		Image.prefetch(image.getUrl());
		// Add image to Root Panel so that loaded callback gets fired if image does exist
		RootPanel.get().add(image);
	}
}
 
开发者ID:openremote,项目名称:WebConsole,代码行数:14,代码来源:ImageContainer.java


注:本文中的com.google.gwt.user.client.ui.Image.addErrorHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。