use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog in project epp.mpc by eclipse.
the class MarketplaceClientUiTest method testOfflineCatalogErrors.
@Test
public void testOfflineCatalogErrors() throws Exception {
final MarketplaceCatalog catalog = new MarketplaceCatalog();
catalog.getDiscoveryStrategies().add(new MarketplaceDiscoveryStrategy(new CatalogDescriptor(new URL(UNREACHABLE_MARKETPLACE_URL), "Unreachable Marketplace")));
IStatus status = catalog.performDiscovery(new NullProgressMonitor());
assertEquals(IStatus.ERROR, status.getSeverity());
assertTrue(status.getMessage().startsWith(OFFLINE_HINT_TEXT));
}
use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog in project epp.mpc by eclipse.
the class MarketplaceCatalogTest method setupCatalog.
protected void setupCatalog() throws MalformedURLException {
final SearchResult discoveryResult = new SearchResult();
discoveryResult.setNodes(discoveryNodes);
CatalogDescriptor catalogDescriptor = new CatalogDescriptor();
catalogDescriptor.setUrl(new URL("http://marketplace.eclipse.org"));
MarketplaceDiscoveryStrategy discoveryStrategy = new MarketplaceDiscoveryStrategy(catalogDescriptor) {
final MarketplaceCategory category = new MarketplaceCategory();
{
category.setId("<root>");
}
@Override
public void performDiscovery(IProgressMonitor monitor) throws CoreException {
if (!categories.contains(category)) {
categories.add(category);
}
handleSearchResult(category, discoveryResult, new NullProgressMonitor());
}
@Override
protected synchronized Map<String, IInstallableUnit> computeInstalledIUs(IProgressMonitor monitor) {
Map<String, IInstallableUnit> installedIus = new HashMap<String, IInstallableUnit>();
for (INode node : installedNodes) {
IIus ius = node.getIus();
if (ius != null) {
for (IIu iu : ius.getIuElements()) {
String featureId = iu.getId() + ".feature.group";
InstallableUnit installableUnit = new InstallableUnit();
installableUnit.setId(featureId);
installedIus.put(featureId, installableUnit);
}
}
}
return installedIus;
}
@Override
protected MarketplaceCategory findMarketplaceCategory(IProgressMonitor monitor) throws CoreException {
return category;
}
};
catalog = new MarketplaceCatalog() {
@Override
protected IStatus checkForUpdates(List<MarketplaceNodeCatalogItem> updateCheckNeeded, final Map<String, IInstallableUnit> installedIUs, final IProgressMonitor monitor) {
for (MarketplaceNodeCatalogItem item : updateCheckNeeded) {
checkedForUpdate.add(item.getData());
List<MarketplaceNodeInstallableUnitItem> installableUnitItems = item.getInstallableUnitItems();
boolean hasUpdate = updateAvailable.contains(item.getData());
for (MarketplaceNodeInstallableUnitItem iuItem : installableUnitItems) {
iuItem.setUpdateAvailable(hasUpdate);
}
}
return Status.OK_STATUS;
}
};
catalog.getDiscoveryStrategies().add(discoveryStrategy);
}
use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog in project epp.mpc by eclipse.
the class SelectionModelStateSerializerTest method setUp.
@Before
public void setUp() throws Exception {
CatalogDescriptor catalogDescriptor = new CatalogDescriptor(new URL("http://marketplace.eclipse.org"), "Eclipse.org Marketplace");
discoveryStrategy = new MarketplaceDiscoveryStrategy(catalogDescriptor) {
@Override
public IMarketplaceService createMarketplaceService() {
DefaultMarketplaceService marketplaceService = new DefaultMarketplaceService(catalogDescriptor.getUrl());
Map<String, String> requestMetaParameters = ServiceLocator.computeDefaultRequestMetaParameters();
marketplaceService.setRequestMetaParameters(requestMetaParameters);
return marketplaceService;
}
};
catalog = new MarketplaceCatalog();
catalog.getDiscoveryStrategies().add(discoveryStrategy);
selectionModel = new SelectionModel(new InstallProfile() {
public Set<String> getInstalledFeatures() {
return Collections.emptySet();
}
});
}
use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog in project epp.mpc by eclipse.
the class MarketplaceViewer method catalogUpdated.
@Override
protected void catalogUpdated(final boolean wasCancelled, final boolean wasError) {
MarketplaceCatalog catalog = getCatalog();
List<AbstractDiscoveryStrategy> discoveryStrategies = catalog.getDiscoveryStrategies();
for (AbstractDiscoveryStrategy discoveryStrategy : discoveryStrategies) {
if (discoveryStrategy instanceof MarketplaceDiscoveryStrategy) {
MarketplaceDiscoveryStrategy marketplaceDiscoveryStrategy = (MarketplaceDiscoveryStrategy) discoveryStrategy;
marketplaceDiscoveryStrategy.addLoginListener(loginListener);
for (CatalogCategory catalogCategory : catalog.getCategories()) {
if (catalogCategory instanceof MarketplaceCategory) {
MarketplaceCategory marketplaceCategory = (MarketplaceCategory) catalogCategory;
if (marketplaceCategory.getContents() == Contents.FEATURED && getWizard().shouldShowOpenFavoritesBanner()) {
marketplaceDiscoveryStrategy.addOpenFavoritesItem(marketplaceCategory);
}
}
}
}
}
runUpdate(new Runnable() {
public void run() {
MarketplaceViewer.super.catalogUpdated(wasCancelled, wasError);
for (CatalogFilter filter : getConfiguration().getFilters()) {
if (filter instanceof MarketplaceFilter) {
((MarketplaceFilter) filter).catalogUpdated(wasCancelled);
}
}
setFilters(queryData);
}
});
}
use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog in project epp.mpc by eclipse.
the class MarketplaceWizardCommand method updateCategoryChoices.
private void updateCategoryChoices(final ComboTagFilter marketCategoryTagFilter, final ComboTagFilter marketFilter) {
Set<Tag> newChoices = new HashSet<Tag>();
List<Tag> choices = new ArrayList<Tag>();
Set<IMarket> selectedMarkets = new HashSet<IMarket>();
for (Tag marketTag : marketFilter.getSelected()) {
selectedMarkets.add((IMarket) marketTag.getData());
}
final MarketplaceCatalog catalog = (MarketplaceCatalog) marketCategoryTagFilter.getCatalog();
List<IMarket> markets = catalog.getMarkets();
for (IMarket market : markets) {
if (selectedMarkets.isEmpty() || selectedMarkets.contains(market)) {
for (ICategory marketCategory : market.getCategory()) {
Tag categoryTag = new Tag(ICategory.class, marketCategory.getId(), marketCategory.getName());
categoryTag.setData(marketCategory);
if (newChoices.add(categoryTag)) {
choices.add(categoryTag);
}
}
}
}
Collections.sort(choices, new Comparator<Tag>() {
public int compare(Tag o1, Tag o2) {
return o1.getLabel().compareTo(o2.getLabel());
}
});
marketCategoryTagFilter.setChoices(choices);
}
Aggregations