Search in sources :

Example 36 with CatalogDescriptor

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

the class AbstractMarketplaceWizardCommand method createConfiguration.

protected MarketplaceCatalogConfiguration createConfiguration(final MarketplaceCatalog catalog, ExecutionEvent event) {
    MarketplaceCatalogConfiguration configuration = new MarketplaceCatalogConfiguration();
    configuration.setVerifyUpdateSiteAvailability(false);
    if (catalogDescriptors == null || catalogDescriptors.isEmpty()) {
        final IStatus remoteCatalogStatus = installRemoteCatalogs();
        configuration.getCatalogDescriptors().addAll(CatalogRegistry.getInstance().getCatalogDescriptors());
        if (configuration.getCatalogDescriptors().isEmpty()) {
            // doesn't make much sense to continue without catalogs.
            // nothing will work and no way to recover later
            IStatus cause;
            if (!remoteCatalogStatus.isOK()) {
                cause = remoteCatalogStatus;
            } else {
                cause = new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, Messages.MarketplaceWizardCommand_noRemoteCatalogs);
            }
            IStatus exitStatus = new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, cause.getCode(), Messages.MarketplaceWizardCommand_cannotOpenMarketplace, new CoreException(cause));
            try {
                MarketplaceClientUi.handle(exitStatus, StatusManager.SHOW | StatusManager.BLOCK | (exitStatus.getSeverity() == IStatus.CANCEL ? 0 : StatusManager.LOG));
            } catch (Exception ex) {
                // HOTFIX for bug 477269 - Display might get disposed during call to handle due to workspace shutdown or similar.
                // In that case, just log...
                MarketplaceClientUi.getLog().log(exitStatus);
            }
            return null;
        } else if (!remoteCatalogStatus.isOK()) {
            MarketplaceClientUi.handle(remoteCatalogStatus, StatusManager.LOG);
        }
    } else {
        configuration.getCatalogDescriptors().addAll(catalogDescriptors);
    }
    if (selectedCatalogDescriptor != null) {
        if (selectedCatalogDescriptor.getLabel().equals("org.eclipse.epp.mpc.descriptorHint")) {
            // $NON-NLS-1$
            CatalogDescriptor resolvedDescriptor = CatalogRegistry.getInstance().findCatalogDescriptor(selectedCatalogDescriptor.getUrl().toExternalForm());
            if (resolvedDescriptor == null) {
                IStatus status = new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, Messages.MarketplaceWizardCommand_CouldNotFindMarketplaceForSolution, new ExecutionException(selectedCatalogDescriptor.getUrl().toExternalForm()));
                MarketplaceClientUi.handle(status, StatusManager.SHOW | StatusManager.BLOCK | StatusManager.LOG);
                return null;
            } else {
                configuration.setCatalogDescriptor(resolvedDescriptor);
            }
        } else {
            configuration.setCatalogDescriptor(selectedCatalogDescriptor);
        }
    }
    return configuration;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) MarketplaceCatalogConfiguration(org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceCatalogConfiguration) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException) CoreException(org.eclipse.core.runtime.CoreException) ExecutionException(org.eclipse.core.commands.ExecutionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CatalogDescriptor(org.eclipse.epp.mpc.ui.CatalogDescriptor)

Example 37 with CatalogDescriptor

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

the class AbstractMarketplaceWizardCommand method registerOrOverrideCatalog.

private void registerOrOverrideCatalog(CatalogDescriptor descriptor) {
    CatalogRegistry catalogRegistry = CatalogRegistry.getInstance();
    List<CatalogDescriptor> descriptors = catalogRegistry.getCatalogDescriptors();
    for (CatalogDescriptor catalogDescriptor : descriptors) {
        if (catalogDescriptor.getUrl().toExternalForm().equals(descriptor.getUrl().toExternalForm())) {
            catalogRegistry.unregister(catalogDescriptor);
        }
    }
    catalogRegistry.register(descriptor);
}
Also used : CatalogRegistry(org.eclipse.epp.internal.mpc.ui.CatalogRegistry) 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