Search in sources :

Example 1 with ResourceProviderImageDescriptor

use of org.eclipse.epp.internal.mpc.ui.catalog.ResourceProviderImageDescriptor in project epp.mpc by eclipse.

the class CatalogDescriptor method imageDescriptorForUrl.

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;
}
Also used : ResourceFuture(org.eclipse.epp.internal.mpc.ui.catalog.ResourceProvider.ResourceFuture) ResourceProvider(org.eclipse.epp.internal.mpc.ui.catalog.ResourceProvider) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) ResourceProviderImageDescriptor(org.eclipse.epp.internal.mpc.ui.catalog.ResourceProviderImageDescriptor)

Aggregations

IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ResourceProvider (org.eclipse.epp.internal.mpc.ui.catalog.ResourceProvider)1 ResourceFuture (org.eclipse.epp.internal.mpc.ui.catalog.ResourceProvider.ResourceFuture)1 ResourceProviderImageDescriptor (org.eclipse.epp.internal.mpc.ui.catalog.ResourceProviderImageDescriptor)1