Search in sources :

Example 1 with CatalogCategory

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);
    }
}
Also used : TextSearchControl(org.eclipse.equinox.internal.p2.ui.discovery.util.TextSearchControl) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) CatalogCategory(org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory)

Example 2 with CatalogCategory

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);
        }
    });
}
Also used : CatalogFilter(org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter) MarketplaceDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy) AbstractDiscoveryStrategy(org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy) CatalogCategory(org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory) MarketplaceCatalog(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog) MarketplaceCategory(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCategory)

Example 3 with CatalogCategory

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;
}
Also used : SubMonitor(org.eclipse.core.runtime.SubMonitor) CatalogCategory(org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory)

Example 4 with 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);
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)

Example 5 with CatalogCategory

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;
}
Also used : CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)

Aggregations

CatalogCategory (org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory)8 CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)8 CoreException (org.eclipse.core.runtime.CoreException)3 SubMonitor (org.eclipse.core.runtime.SubMonitor)3 IOException (java.io.IOException)2 MalformedURLException (java.net.MalformedURLException)2 URISyntaxException (java.net.URISyntaxException)2 ArrayList (java.util.ArrayList)2 NoSuchElementException (java.util.NoSuchElementException)2 NotAuthorizedException (org.eclipse.epp.internal.mpc.core.service.AbstractDataStorageService.NotAuthorizedException)2 MarketplaceCategory (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCategory)2 ICategory (org.eclipse.epp.mpc.core.model.ICategory)2 INode (org.eclipse.epp.mpc.core.model.INode)2 AbstractDiscoveryStrategy (org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy)2 Tag (org.eclipse.equinox.internal.p2.discovery.model.Tag)2 HashMap (java.util.HashMap)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Matcher (java.util.regex.Matcher)1 IStatus (org.eclipse.core.runtime.IStatus)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1