예제 #1
0
 private static ImageDescriptor imageDescriptorForUrl(ICatalog catalog, String imageUrl)
     throws MalformedURLException {
   if (imageUrl != null && imageUrl.length() > 0) {
     ResourceProvider resourceProvider =
         MarketplaceClientUiPlugin.getInstance().getResourceProvider();
     ResourceFuture resource = resourceProvider.getResource(imageUrl);
     if (resource == null) {
       String requestSource =
           NLS.bind(Messages.CatalogDescriptor_requestCatalog, catalog.getName(), catalog.getId());
       try {
         resource = resourceProvider.retrieveResource(requestSource, imageUrl);
       } catch (URISyntaxException e) {
         MarketplaceClientUi.log(
             IStatus.WARNING,
             Messages.CatalogDescriptor_badUri,
             catalog.getName(),
             catalog.getId(),
             resource,
             e);
       } catch (IOException e) {
         MarketplaceClientUi.log(
             IStatus.WARNING,
             Messages.CatalogDescriptor_downloadError,
             catalog.getName(),
             catalog.getId(),
             resource,
             e);
       }
     }
     if (resource != null) {
       return new ResourceProviderImageDescriptor(resourceProvider, imageUrl);
     }
     return ImageDescriptor.createFromURL(URLUtil.toURL(imageUrl));
   }
   return null;
 }
예제 #2
0
 public CatalogDescriptor(ICatalog catalog) throws MalformedURLException {
   setLabel(catalog.getName());
   setUrl(URLUtil.toURL(catalog.getUrl()));
   String imageUrl = catalog.getImageUrl();
   setIcon(imageDescriptorForUrl(catalog, imageUrl));
   setDescription(catalog.getDescription());
   setInstallFromAllRepositories(!catalog.isSelfContained());
   if (catalog.getDependencyRepository() != null) {
     setDependenciesRepository(URLUtil.toURL(catalog.getDependencyRepository()));
   }
   setCatalogBranding(catalog.getBranding());
   if (catalog.getBranding() != null) {
     imageDescriptorForUrl(catalog, catalog.getBranding().getWizardIcon());
   }
   if (catalog.getNews() != null) {
     CatalogRegistry.getInstance().addCatalogNews(this, catalog.getNews());
   }
 }