use of org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy in project epp.mpc by eclipse.
the class MarketplaceCatalog method calculateInstalledIUs.
private Map<String, IInstallableUnit> calculateInstalledIUs(IProgressMonitor monitor) {
Map<String, IInstallableUnit> installedIUs = new HashMap<String, IInstallableUnit>();
List<AbstractDiscoveryStrategy> discoveryStrategies = getDiscoveryStrategies();
SubMonitor progress = SubMonitor.convert(monitor, discoveryStrategies.size() * 1000);
for (AbstractDiscoveryStrategy discoveryStrategy : discoveryStrategies) {
if (monitor.isCanceled()) {
break;
}
SubMonitor childProgress = progress.newChild(1000);
if (discoveryStrategy instanceof MarketplaceDiscoveryStrategy) {
MarketplaceDiscoveryStrategy marketplaceDiscoveryStrategy = (MarketplaceDiscoveryStrategy) discoveryStrategy;
Map<String, IInstallableUnit> ius = marketplaceDiscoveryStrategy.computeInstalledIUs(childProgress);
installedIUs.putAll(ius);
}
childProgress.setWorkRemaining(0);
}
return installedIUs;
}
use of org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy in project epp.mpc by eclipse.
the class MarketplaceCatalog method performDiscovery.
protected IStatus performDiscovery(DiscoveryOperation operation, boolean refresh, IProgressMonitor monitor) {
MultiStatus status = new MultiStatus(MarketplaceClientUi.BUNDLE_ID, 0, Messages.MarketplaceCatalog_queryFailed, null);
if (getDiscoveryStrategies().isEmpty()) {
throw new IllegalStateException();
}
// reset, keeping no items but the same tags, categories and certifications
List<CatalogItem> items = new ArrayList<CatalogItem>();
List<CatalogCategory> categories = new ArrayList<CatalogCategory>(getCategories());
List<Certification> certifications = new ArrayList<Certification>(getCertifications());
List<Tag> tags = new ArrayList<Tag>(getTags());
if (!refresh) {
for (CatalogCategory catalogCategory : categories) {
catalogCategory.getItems().clear();
}
}
final int totalTicks = 100000;
final int discoveryTicks = totalTicks - (totalTicks / 10);
monitor.beginTask(Messages.MarketplaceCatalog_queryingMarketplace, totalTicks);
try {
int strategyTicks = discoveryTicks / getDiscoveryStrategies().size();
for (AbstractDiscoveryStrategy discoveryStrategy : getDiscoveryStrategies()) {
if (monitor.isCanceled()) {
status.add(Status.CANCEL_STATUS);
break;
}
if (discoveryStrategy instanceof MarketplaceDiscoveryStrategy) {
List<CatalogCategory> oldCategories = discoveryStrategy.getCategories();
List<CatalogItem> oldItems = discoveryStrategy.getItems();
List<Certification> oldCertifications = discoveryStrategy.getCertifications();
List<Tag> oldTags = discoveryStrategy.getTags();
discoveryStrategy.setCategories(categories);
discoveryStrategy.setItems(items);
discoveryStrategy.setCertifications(certifications);
discoveryStrategy.setTags(tags);
try {
MarketplaceDiscoveryStrategy marketplaceStrategy = (MarketplaceDiscoveryStrategy) discoveryStrategy;
operation.run(marketplaceStrategy, new SubProgressMonitor(monitor, strategyTicks));
} catch (CoreException e) {
IStatus error = MarketplaceClientCore.computeWellknownProblemStatus(e);
if (error == null) {
error = new Status(e.getStatus().getSeverity(), DiscoveryCore.ID_PLUGIN, NLS.bind(Messages.MarketplaceCatalog_failedWithError, discoveryStrategy.getClass().getSimpleName()), e);
}
status.add(error);
} finally {
// remove everything from strategy again, so it can't accidentally mess with the results later
discoveryStrategy.setCategories(oldCategories);
discoveryStrategy.setItems(oldItems);
discoveryStrategy.setCertifications(oldCertifications);
discoveryStrategy.setTags(oldTags);
// make sure strategy didn't misbehave
if (items.contains(null)) {
while (items.remove(null)) {
}
IStatus error = new Status(IStatus.WARNING, DiscoveryCore.ID_PLUGIN, NLS.bind(Messages.MarketplaceCatalog_addedNullEntry, discoveryStrategy.getClass().getSimpleName()));
status.add(error);
}
}
}
}
update(categories, items, certifications, tags);
} finally {
monitor.done();
}
return computeStatus(status);
}
use of org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy in project epp.mpc by eclipse.
the class ImportFavoritesPage method findUserFavoritesService.
private IUserFavoritesService findUserFavoritesService() {
IUserFavoritesService userFavoritesService = null;
for (AbstractDiscoveryStrategy strategy : getCatalog().getDiscoveryStrategies()) {
if (strategy instanceof FavoritesDiscoveryStrategy) {
FavoritesDiscoveryStrategy favoritesStrategy = (FavoritesDiscoveryStrategy) strategy;
userFavoritesService = favoritesStrategy.getMarketplaceService().getUserFavoritesService();
}
}
return userFavoritesService;
}
Aggregations