Search in sources :

Example 1 with AbstractDiscoveryStrategy

use of org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy 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 2 with AbstractDiscoveryStrategy

use of org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy in project epp.mpc by eclipse.

the class FavoritesViewer method findFavoritesStrategy.

private FavoritesDiscoveryStrategy findFavoritesStrategy() {
    FavoritesDiscoveryStrategy favoritesStrategy = null;
    List<AbstractDiscoveryStrategy> discoveryStrategies = getCatalog().getDiscoveryStrategies();
    for (AbstractDiscoveryStrategy strategy : discoveryStrategies) {
        if (strategy instanceof FavoritesDiscoveryStrategy) {
            favoritesStrategy = (FavoritesDiscoveryStrategy) strategy;
            break;
        }
    }
    return favoritesStrategy;
}
Also used : FavoritesDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy) AbstractDiscoveryStrategy(org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy)

Example 3 with AbstractDiscoveryStrategy

use of org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy in project epp.mpc by eclipse.

the class MarketplaceCatalog method performNewsDiscovery.

public IStatus performNewsDiscovery(IProgressMonitor monitor) {
    if (getDiscoveryStrategies().isEmpty()) {
        throw new IllegalStateException();
    }
    INews news = null;
    MultiStatus status = new MultiStatus(MarketplaceClientUi.BUNDLE_ID, 0, Messages.MarketplaceCatalog_queryFailed, null);
    final int totalTicks = 100000;
    final SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceCatalog_Checking_News, totalTicks);
    try {
        int strategyTicks = totalTicks / getDiscoveryStrategies().size();
        for (AbstractDiscoveryStrategy discoveryStrategy : getDiscoveryStrategies()) {
            if (monitor.isCanceled()) {
                status.add(Status.CANCEL_STATUS);
                break;
            }
            if (discoveryStrategy instanceof MarketplaceDiscoveryStrategy) {
                try {
                    MarketplaceDiscoveryStrategy marketplaceStrategy = (MarketplaceDiscoveryStrategy) discoveryStrategy;
                    news = marketplaceStrategy.performNewsDiscovery(progress.newChild(strategyTicks));
                    if (news != null) {
                        break;
                    }
                } catch (CoreException e) {
                    status.add(new Status(e.getStatus().getSeverity(), DiscoveryCore.ID_PLUGIN, NLS.bind(Messages.MarketplaceCatalog_failedWithError, discoveryStrategy.getClass().getSimpleName()), e));
                }
            }
        }
    } finally {
        monitor.done();
    }
    if (status.isOK()) {
        setNews(news);
    }
    return status;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) INews(org.eclipse.epp.mpc.core.model.INews) AbstractDiscoveryStrategy(org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy) SubMonitor(org.eclipse.core.runtime.SubMonitor) MultiStatus(org.eclipse.core.runtime.MultiStatus)

Example 4 with AbstractDiscoveryStrategy

use of org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy in project epp.mpc by eclipse.

the class MarketplaceWizard method initializeCatalog.

void initializeCatalog() {
    final MarketplaceCatalog catalog = getCatalog();
    synchronized (catalog) {
        List<AbstractDiscoveryStrategy> discoveryStrategies = catalog.getDiscoveryStrategies();
        for (AbstractDiscoveryStrategy strategy : discoveryStrategies) {
            strategy.dispose();
        }
        discoveryStrategies.clear();
        if (getConfiguration().getCatalogDescriptor() != null) {
            MarketplaceDiscoveryStrategy discoveryStrategy = new MarketplaceDiscoveryStrategy(getConfiguration().getCatalogDescriptor());
            discoveryStrategy.setShellProvider(this);
            discoveryStrategies.add(discoveryStrategy);
        }
    }
}
Also used : MarketplaceDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy) AbstractDiscoveryStrategy(org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy) MarketplaceCatalog(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog)

Example 5 with AbstractDiscoveryStrategy

use of org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy in project epp.mpc by eclipse.

the class MarketplaceWizard method findMarketplaceDiscoveryStrategy.

protected MarketplaceDiscoveryStrategy findMarketplaceDiscoveryStrategy() {
    MarketplaceDiscoveryStrategy marketplaceStrategy = null;
    List<AbstractDiscoveryStrategy> discoveryStrategies = getCatalog().getDiscoveryStrategies();
    for (AbstractDiscoveryStrategy strategy : discoveryStrategies) {
        if (strategy instanceof MarketplaceDiscoveryStrategy) {
            marketplaceStrategy = (MarketplaceDiscoveryStrategy) strategy;
            break;
        }
    }
    return marketplaceStrategy;
}
Also used : MarketplaceDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy) AbstractDiscoveryStrategy(org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy)

Aggregations

AbstractDiscoveryStrategy (org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy)8 MarketplaceDiscoveryStrategy (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy)3 CoreException (org.eclipse.core.runtime.CoreException)2 IStatus (org.eclipse.core.runtime.IStatus)2 MultiStatus (org.eclipse.core.runtime.MultiStatus)2 Status (org.eclipse.core.runtime.Status)2 SubMonitor (org.eclipse.core.runtime.SubMonitor)2 FavoritesDiscoveryStrategy (org.eclipse.epp.internal.mpc.ui.catalog.FavoritesDiscoveryStrategy)2 MarketplaceCatalog (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog)2 CatalogCategory (org.eclipse.equinox.internal.p2.discovery.model.CatalogCategory)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)1 MarketplaceCategory (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCategory)1 INews (org.eclipse.epp.mpc.core.model.INews)1 IUserFavoritesService (org.eclipse.epp.mpc.core.service.IUserFavoritesService)1 CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)1 Certification (org.eclipse.equinox.internal.p2.discovery.model.Certification)1 Tag (org.eclipse.equinox.internal.p2.discovery.model.Tag)1 CatalogFilter (org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter)1