use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalogSource in project epp.mpc by eclipse.
the class MarketplaceDiscoveryResources method setImage.
public void setImage(final ImageReceiver receiver, final AbstractCatalogSource discoverySource, final String imagePath, Image fallbackImage) {
if (imagePath != null && imagePath.length() > 0) {
Image image = null;
if (discoverySource instanceof MarketplaceCatalogSource) {
MarketplaceCatalogSource marketplaceSource = (MarketplaceCatalogSource) discoverySource;
ResourceFuture resource = marketplaceSource.getResourceProvider().getResource(imagePath);
if (resource != null) {
URL localURL = resource.getLocalURL();
if (localURL != null) {
try {
File imageFile = new File(new URI(localURL.getProtocol(), null, localURL.getPath(), null, null));
if (imageFile.exists()) {
image = safeCreateImage(imagePath, localURL);
}
} catch (URISyntaxException e) {
logFailedLoadingImage(imagePath, localURL, e);
}
}
}
}
if (image != null) {
receiver.setImage(image);
} else if (fallbackImage != null) {
receiver.setImage(fallbackImage);
}
new Job(Messages.MarketplaceDiscoveryResources_retrievingImage) {
{
setPriority(INTERACTIVE);
setUser(false);
setSystem(true);
}
@Override
protected IStatus run(IProgressMonitor monitor) {
if (!display.isDisposed()) {
try {
if (imagePath != null && imagePath.length() > 0) {
final URL resource = discoverySource.getResource(imagePath);
if (resource != null) {
display.asyncExec(new Runnable() {
public void run() {
final Image image = safeCreateImage(imagePath, resource);
if (image != null) {
receiver.setImage(image);
}
}
});
}
}
} catch (Exception e) {
MarketplaceClientUi.log(IStatus.WARNING, Messages.MarketplaceDiscoveryResources_FailedCreatingImage, imagePath, discoverySource.getId(), e);
// we don't want any additional logging or error popups...
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
}.schedule();
} else if (fallbackImage != null) {
receiver.setImage(fallbackImage);
}
}
use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalogSource in project epp.mpc by eclipse.
the class DiscoveryItem method getUserFavoritesService.
private IUserFavoritesService getUserFavoritesService() {
MarketplaceCatalogSource source = (MarketplaceCatalogSource) this.getData().getSource();
IUserFavoritesService userFavoritesService = source.getMarketplaceService().getUserFavoritesService();
return userFavoritesService;
}
Aggregations