use of org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory in project epp.mpc by eclipse.
the class MarketplaceViewer method fixLayout.
protected static void fixLayout(CategoryItem<?> categoryItem) {
// FIXME remove once the layout has been fixed upstream
CatalogCategory category = categoryItem.getData();
boolean hasDescription = category.getDescription() != null;
int valignTitle = hasDescription ? SWT.BEGINNING : SWT.CENTER;
int totalRows = hasDescription ? 2 : 1;
final Control[] children = categoryItem.getChildren();
Composite categoryHeaderContainer = (Composite) children[0];
GridLayoutFactory.fillDefaults().numColumns(3).margins(5, hasDescription ? 5 : 10).equalWidth(false).applyTo(categoryHeaderContainer);
final Control[] headerChildren = categoryHeaderContainer.getChildren();
final Control iconLabel = headerChildren[0];
final Control nameLabel = headerChildren[1];
final Control tooltip = headerChildren[2];
GridDataFactory.swtDefaults().align(SWT.CENTER, valignTitle).span(1, totalRows).applyTo(iconLabel);
GridDataFactory.fillDefaults().grab(true, false).align(SWT.BEGINNING, valignTitle).applyTo(nameLabel);
if (tooltip instanceof Label) {
GridDataFactory.fillDefaults().align(SWT.END, valignTitle).applyTo(tooltip);
}
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory 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.equinox.internal.p2.discovery.model.CatalogCategory in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method findMarketplaceCategory.
protected MarketplaceCategory findMarketplaceCategory(IProgressMonitor monitor) throws CoreException {
MarketplaceCategory catalogCategory = null;
SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceDiscoveryStrategy_catalogCategory, 10000);
try {
for (CatalogCategory candidate : getCategories()) {
if (candidate.getSource() == source) {
catalogCategory = (MarketplaceCategory) candidate;
}
}
if (catalogCategory == null) {
List<? extends IMarket> markets = marketplaceService.listMarkets(progress.newChild(10000));
// marketplace has markets and categories, however a node and/or category can appear in multiple
// markets. This doesn't match well with discovery's concept of a category. Discovery requires all
// items to be in a category, so we use a single root category and tagging.
catalogCategory = new MarketplaceCategory();
// $NON-NLS-1$
catalogCategory.setId("<root>");
// $NON-NLS-1$
catalogCategory.setName("<root>");
catalogCategory.setSource(source);
catalogCategory.setMarkets(markets);
categories.add(catalogCategory);
}
} finally {
progress.done();
}
return catalogCategory;
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method addCatalogItem.
public void addCatalogItem(MarketplaceCategory catalogCategory) {
CatalogItem catalogItem = createCategoryItem(catalogCategory);
items.add(catalogItem);
}
use of org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory in project epp.mpc by eclipse.
the class MarketplaceDiscoveryStrategy method createCategoryItem.
private CatalogItem createCategoryItem(MarketplaceCategory catalogCategory) {
CatalogItem catalogItem = new CatalogItem();
catalogItem.setSource(source);
catalogItem.setData(catalogDescriptor);
catalogItem.setId(catalogDescriptor.getUrl().toString());
catalogItem.setCategoryId(catalogCategory.getId());
return catalogItem;
}
Aggregations