Search in sources :

Example 21 with CatalogDescriptor

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

the class CatalogDescriptorTest method testFindCatalogDescriptorWithCommonPrefixDifferentProtocol1.

/**
 * @throws Exception
 * @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=488436">bug 488436</a>
 */
@Test
public void testFindCatalogDescriptorWithCommonPrefixDifferentProtocol1() throws Exception {
    CatalogRegistry registry = CatalogRegistry.getInstance();
    String marketplace = "http://marketplace.eclipse.org";
    String marketplaceHttps = URLUtil.toggleHttps(marketplace);
    String hostedMarketplace = "https://marketplace.eclipse.org/hosted_catalog/test";
    String hostedMarketplaceHttp = URLUtil.toggleHttps(hostedMarketplace);
    CatalogDescriptor marketplaceDescriptor = new CatalogDescriptor(new URL(marketplace), null);
    CatalogDescriptor hostedMarketplaceDescriptor = new CatalogDescriptor(new URL(hostedMarketplace), null);
    registry.register(marketplaceDescriptor);
    registry.register(hostedMarketplaceDescriptor);
    CatalogDescriptor found = registry.findCatalogDescriptor(marketplaceHttps);
    assertThat(found, is(marketplaceDescriptor));
    found = registry.findCatalogDescriptor(hostedMarketplaceHttp);
    assertThat(found, is(hostedMarketplaceDescriptor));
}
Also used : CatalogRegistry(org.eclipse.epp.internal.mpc.ui.CatalogRegistry) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Test(org.junit.Test)

Example 22 with CatalogDescriptor

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

the class CatalogDescriptorTest method testFindCatalogDescriptorWithCommonPrefix.

/**
 * @throws Exception
 * @see <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=488436">bug 488436</a>
 */
@Test
public void testFindCatalogDescriptorWithCommonPrefix() throws Exception {
    CatalogRegistry registry = CatalogRegistry.getInstance();
    String marketplace = "http://marketplace.eclipse.org";
    String hostedMarketplace = "http://marketplace.eclipse.org/hosted_catalog/test";
    CatalogDescriptor marketplaceDescriptor = new CatalogDescriptor(new URL(marketplace), null);
    CatalogDescriptor hostedMarketplaceDescriptor = new CatalogDescriptor(new URL(hostedMarketplace), null);
    registry.register(marketplaceDescriptor);
    registry.register(hostedMarketplaceDescriptor);
    CatalogDescriptor found = registry.findCatalogDescriptor(marketplace);
    assertThat(found, is(marketplaceDescriptor));
    found = registry.findCatalogDescriptor(hostedMarketplace);
    assertThat(found, is(hostedMarketplaceDescriptor));
}
Also used : CatalogRegistry(org.eclipse.epp.internal.mpc.ui.CatalogRegistry) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor) Test(org.junit.Test)

Example 23 with CatalogDescriptor

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

the class CatalogExtensionPointReader method getCatalogDescriptors.

public List<CatalogDescriptor> getCatalogDescriptors() {
    IExtensionPoint extensionPoint = // $NON-NLS-1$
    Platform.getExtensionRegistry().getExtensionPoint(// $NON-NLS-1$
    "org.eclipse.epp.mpc.ui", // $NON-NLS-1$
    "catalog");
    if (extensionPoint == null) {
        throw new IllegalStateException();
    }
    List<CatalogDescriptor> descriptors = new ArrayList<CatalogDescriptor>();
    for (IConfigurationElement element : extensionPoint.getConfigurationElements()) {
        if (element.getName().equals("catalog")) {
            // $NON-NLS-1$
            try {
                // $NON-NLS-1$
                String urlText = element.getAttribute("url");
                if (urlText == null || urlText.trim().length() == 0) {
                    throw new Exception(Messages.CatalogExtensionPointReader_urlRequired);
                }
                URL url = URLUtil.toURL(urlText);
                // $NON-NLS-1$
                String label = element.getAttribute("label");
                if (label == null || label.trim().length() == 0) {
                    throw new Exception(Messages.CatalogExtensionPointReader_labelRequired);
                }
                CatalogDescriptor descriptor = new CatalogDescriptor(url, label);
                // $NON-NLS-1$
                descriptor.setDescription(element.getAttribute("description"));
                // $NON-NLS-1$
                final String icon = element.getAttribute("icon");
                if (icon != null) {
                    URL iconResource = Platform.getBundle(element.getContributor().getName()).getResource(icon);
                    if (iconResource == null) {
                        throw new Exception(NLS.bind(Messages.CatalogExtensionPointReader_cannotFindResource, icon));
                    }
                    descriptor.setIcon(ImageDescriptor.createFromURL(iconResource));
                }
                // $NON-NLS-1$
                String selfContained = element.getAttribute("selfContained");
                if (selfContained == null || selfContained.trim().length() == 0) {
                    // $NON-NLS-1$
                    selfContained = "true";
                } else {
                    selfContained = selfContained.trim();
                }
                descriptor.setInstallFromAllRepositories(!Boolean.valueOf(selfContained));
                // $NON-NLS-1$
                String dependenciesRepository = element.getAttribute("dependenciesRepository");
                if (dependenciesRepository != null && dependenciesRepository.trim().length() > 0) {
                    URL repository = new URL(dependenciesRepository);
                    // we do this later, so let's see the error now.
                    repository.toURI();
                    descriptor.setDependenciesRepository(repository);
                }
                if (!descriptors.contains(descriptor)) {
                    descriptors.add(descriptor);
                }
            } catch (Exception e) {
                MarketplaceClientUi.error(NLS.bind(Messages.CatalogExtensionPointReader_cannotRegisterCatalog_bundle_reason, element.getContributor().getName(), e.getMessage()), e);
            }
        }
    }
    return descriptors;
}
Also used : IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint) ArrayList(java.util.ArrayList) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) URL(java.net.URL) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor)

Example 24 with CatalogDescriptor

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

the class MarketplacePage method getNews.

private INews getNews() {
    CatalogDescriptor descriptor = configuration.getCatalogDescriptor();
    INews news = CatalogRegistry.getInstance().getCatalogNews(descriptor);
    return news;
}
Also used : INews(org.eclipse.epp.mpc.core.model.INews) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor)

Example 25 with CatalogDescriptor

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

the class MarketplacePage method setVisible.

@Override
public void setVisible(boolean visible) {
    if (visible) {
        CatalogDescriptor catalogDescriptor = configuration.getCatalogDescriptor();
        if (catalogDescriptor != null) {
            setTitle(catalogDescriptor.getLabel());
        }
        if (previousCatalogDescriptor == null || !previousCatalogDescriptor.equals(catalogDescriptor)) {
            previousCatalogDescriptor = catalogDescriptor;
            tabFolder.setSelection(searchTabItem);
            getViewer().setContentType(ContentType.SEARCH);
            getWizard().initializeCatalog();
            updated = false;
        }
    }
    super.setVisible(visible);
}
Also used : 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