Search in sources :

Example 1 with MarketplaceCatalog

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));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) MarketplaceDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy) MarketplaceCatalog(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Test(org.junit.Test)

Example 2 with MarketplaceCatalog

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);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) INode(org.eclipse.epp.mpc.core.model.INode) IStatus(org.eclipse.core.runtime.IStatus) HashMap(java.util.HashMap) MarketplaceDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy) SearchResult(org.eclipse.epp.internal.mpc.core.model.SearchResult) MarketplaceCategory(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCategory) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) InstallableUnit(org.eclipse.equinox.internal.p2.metadata.InstallableUnit) URL(java.net.URL) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IIu(org.eclipse.epp.mpc.core.model.IIu) MarketplaceNodeInstallableUnitItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeInstallableUnitItem) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ArrayList(java.util.ArrayList) List(java.util.List) MarketplaceCatalog(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog) IIus(org.eclipse.epp.mpc.core.model.IIus) MarketplaceNodeCatalogItem(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor)

Example 3 with MarketplaceCatalog

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();
        }
    });
}
Also used : MarketplaceDiscoveryStrategy(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy) DefaultMarketplaceService(org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService) SelectionModel(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel) MarketplaceCatalog(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog) IMarketplaceService(org.eclipse.epp.mpc.core.service.IMarketplaceService) InstallProfile(org.eclipse.epp.internal.mpc.ui.wizards.InstallProfile) Map(java.util.Map) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Before(org.junit.Before)

Example 4 with MarketplaceCatalog

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);
        }
    });
}
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 5 with MarketplaceCatalog

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);
}
Also used : ICategory(org.eclipse.epp.mpc.core.model.ICategory) ArrayList(java.util.ArrayList) Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag) MarketplaceCatalog(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog) IMarket(org.eclipse.epp.mpc.core.model.IMarket) HashSet(java.util.HashSet)

Aggregations

MarketplaceCatalog (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog)10 MarketplaceDiscoveryStrategy (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy)5 URL (java.net.URL)4 CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)4 ArrayList (java.util.ArrayList)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 MarketplaceCategory (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCategory)2 AbstractDiscoveryStrategy (org.eclipse.equinox.internal.p2.discovery.AbstractDiscoveryStrategy)2 Before (org.junit.Before)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 SearchResult (org.eclipse.epp.internal.mpc.core.model.SearchResult)1 DefaultMarketplaceService (org.eclipse.epp.internal.mpc.core.service.DefaultMarketplaceService)1 MarketplaceNodeCatalogItem (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeCatalogItem)1 MarketplaceNodeInstallableUnitItem (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceNodeInstallableUnitItem)1