use of org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCategory 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.MarketplaceCategory 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.MarketplaceCategory in project epp.mpc by eclipse.
the class NewsUrlHandler method handleSearch.
@Override
protected boolean handleSearch(CatalogDescriptor descriptor, String url, String searchString, Map<String, String> params) {
MarketplaceWizard marketplaceWizard = viewer.getWizard();
// $NON-NLS-1$
String filterParam = params.get("filter");
// $NON-NLS-1$
String[] filters = filterParam.split(" ");
ICategory searchCategory = null;
IMarket searchMarket = null;
for (String filter : filters) {
if (filter.startsWith("tid:")) {
// $NON-NLS-1$
// $NON-NLS-1$
String id = filter.substring("tid:".length());
List<CatalogCategory> catalogCategories = marketplaceWizard.getCatalog().getCategories();
for (CatalogCategory catalogCategory : catalogCategories) {
if (catalogCategory instanceof MarketplaceCategory) {
MarketplaceCategory marketplaceCategory = (MarketplaceCategory) catalogCategory;
List<? extends IMarket> markets = marketplaceCategory.getMarkets();
for (IMarket market : markets) {
if (id.equals(market.getId())) {
searchMarket = market;
} else {
final List<? extends ICategory> categories = market.getCategory();
for (ICategory category : categories) {
if (id.equals(category.getId())) {
searchCategory = category;
}
}
}
}
}
}
}
}
marketplaceWizard.getCatalogPage().search(descriptor, searchMarket, searchCategory, searchString);
return true;
}
Aggregations