Search in sources :

Example 6 with CatalogDescriptor

use of org.eclipse.epp.mpc.ui.CatalogDescriptor 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 7 with CatalogDescriptor

use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.

the class MarketplaceUrlHandlerTest method installMockMarketplace.

@Before
public void installMockMarketplace() throws Exception {
    URL url = new URL("http://marketplace.eclipse.org");
    eclipseMarketplace = new CatalogDescriptor(url, "Eclipse Marketplace");
    CatalogRegistry.getInstance().register(eclipseMarketplace);
}
Also used : URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Before(org.junit.Before)

Example 8 with CatalogDescriptor

use of org.eclipse.epp.mpc.ui.CatalogDescriptor 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 9 with CatalogDescriptor

use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.

the class CatalogRegistry method doFindCatalogDescriptor.

private CatalogDescriptor doFindCatalogDescriptor(String url) {
    CatalogDescriptor matchingDescriptor = null;
    String matchingUrl = null;
    for (CatalogDescriptor catalogDescriptor : catalogDescriptors) {
        String descriptorUrl = catalogDescriptor.getUrl().toExternalForm();
        if (url.startsWith(descriptorUrl) && (matchingUrl == null || matchingUrl.length() < descriptorUrl.length())) {
            String suffix = url.substring(descriptorUrl.length());
            if (suffix.length() > 0 && suffix.charAt(0) == '/') {
                suffix = suffix.substring(1);
            }
            if (suffix.startsWith(ICatalogService.DEDICATED_CATALOG_HOSTING_SEGMENT)) {
                continue;
            }
            matchingDescriptor = catalogDescriptor;
            matchingUrl = descriptorUrl;
        }
    }
    return matchingDescriptor;
}
Also used : CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor)

Example 10 with CatalogDescriptor

use of org.eclipse.epp.mpc.ui.CatalogDescriptor in project epp.mpc by eclipse.

the class MarketplacePage method createMarketplaceSwitcher.

private void createMarketplaceSwitcher(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new FillLayout());
    final CatalogSwitcher switcher = new CatalogSwitcher(composite, SWT.BORDER, configuration);
    switcher.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            CatalogDescriptor descriptor = (CatalogDescriptor) ((IStructuredSelection) event.getSelection()).getFirstElement();
            showMarketplace(descriptor);
        }
    });
    CatalogDescriptor selectedDescriptor = configuration.getCatalogDescriptor();
    if (selectedDescriptor != null) {
        switcher.setSelection(new StructuredSelection(selectedDescriptor));
        lastSelection = selectedDescriptor;
    }
    marketplaceSwitcher = switcher;
    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).minSize(1, SWT.DEFAULT).hint(500, SWT.DEFAULT).applyTo(composite);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor)

Aggregations

CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)37 URL (java.net.URL)18 Test (org.junit.Test)10 IStatus (org.eclipse.core.runtime.IStatus)7 CatalogRegistry (org.eclipse.epp.internal.mpc.ui.CatalogRegistry)7 MarketplaceCatalog (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog)4 MarketplaceUrlHandler (org.eclipse.epp.mpc.ui.MarketplaceUrlHandler)4 Before (org.junit.Before)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 ArrayList (java.util.ArrayList)3 ExecutionException (org.eclipse.core.commands.ExecutionException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 Status (org.eclipse.core.runtime.Status)3 MarketplaceDiscoveryStrategy (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceDiscoveryStrategy)3 INode (org.eclipse.epp.mpc.core.model.INode)3 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 List (java.util.List)2 CoreException (org.eclipse.core.runtime.CoreException)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2