當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。