Search in sources :

Example 1 with MarketplaceCatalogConfiguration

use of org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceCatalogConfiguration in project epp.mpc by eclipse.

the class MarketplaceWizardCommand method createConfiguration.

@Override
protected MarketplaceCatalogConfiguration createConfiguration(final MarketplaceCatalog catalog, ExecutionEvent event) {
    MarketplaceCatalogConfiguration configuration = super.createConfiguration(catalog, event);
    if (configuration == null) {
        // errors have already been logged, just return
        return null;
    }
    configuration.getFilters().clear();
    final ComboTagFilter marketFilter = new ComboTagFilter() {

        @Override
        public void catalogUpdated(boolean wasCancelled) {
            List<Tag> choices = new ArrayList<Tag>();
            List<IMarket> markets = catalog.getMarkets();
            for (IMarket market : markets) {
                Tag marketTag = new Tag(IMarket.class, market.getId(), market.getName());
                marketTag.setData(market);
                choices.add(marketTag);
            }
            setChoices(choices);
        }
    };
    marketFilter.setSelectAllOnNoSelection(true);
    marketFilter.setNoSelectionLabel(Messages.MarketplaceWizardCommand_allMarkets);
    marketFilter.setTagClassification(ICategory.class);
    marketFilter.setChoices(new ArrayList<Tag>());
    final ComboTagFilter marketCategoryTagFilter = new ComboTagFilter() {

        @Override
        public void catalogUpdated(boolean wasCancelled) {
            updateCategoryChoices(this, marketFilter);
        }
    };
    marketCategoryTagFilter.setSelectAllOnNoSelection(true);
    marketCategoryTagFilter.setNoSelectionLabel(Messages.MarketplaceWizardCommand_allCategories);
    marketCategoryTagFilter.setTagClassification(ICategory.class);
    marketCategoryTagFilter.setChoices(new ArrayList<Tag>());
    final IPropertyChangeListener marketListener = new IPropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent event) {
            final String property = event.getProperty();
            if (AbstractTagFilter.PROP_SELECTED.equals(property)) {
                updateCategoryChoices(marketCategoryTagFilter, marketFilter);
            }
        }
    };
    marketFilter.addPropertyChangeListener(marketListener);
    configuration.getFilters().add(marketFilter);
    configuration.getFilters().add(marketCategoryTagFilter);
    configuration.setInitialState(wizardState);
    if (operations != null && !operations.isEmpty()) {
        configuration.setInitialOperations(operations);
    }
    for (CatalogFilter filter : configuration.getFilters()) {
        ((MarketplaceFilter) filter).setCatalog(catalog);
    }
    return configuration;
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) MarketplaceFilter(org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceFilter) ArrayList(java.util.ArrayList) CatalogFilter(org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter) MarketplaceCatalogConfiguration(org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceCatalogConfiguration) Tag(org.eclipse.equinox.internal.p2.discovery.model.Tag) ComboTagFilter(org.eclipse.epp.internal.mpc.ui.wizards.ComboTagFilter) IMarket(org.eclipse.epp.mpc.core.model.IMarket)

Example 2 with MarketplaceCatalogConfiguration

use of org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceCatalogConfiguration 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 3 with MarketplaceCatalogConfiguration

use of org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceCatalogConfiguration in project epp.mpc by eclipse.

the class AbstractMarketplaceWizardCommand method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    final MarketplaceCatalog catalog = createCatalog();
    if (catalog == null) {
        // errors have already been logged, just return
        return null;
    }
    MarketplaceCatalogConfiguration configuration = createConfiguration(catalog, event);
    if (configuration == null) {
        // errors have already been logged, just return
        return null;
    }
    DiscoveryWizard wizard = createWizard(catalog, configuration, event);
    openWizardDialog(wizard, event);
    return null;
}
Also used : MarketplaceCatalogConfiguration(org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceCatalogConfiguration) MarketplaceCatalog(org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog) DiscoveryWizard(org.eclipse.equinox.internal.p2.ui.discovery.wizards.DiscoveryWizard)

Aggregations

MarketplaceCatalogConfiguration (org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceCatalogConfiguration)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 MarketplaceCatalog (org.eclipse.epp.internal.mpc.ui.catalog.MarketplaceCatalog)1 ComboTagFilter (org.eclipse.epp.internal.mpc.ui.wizards.ComboTagFilter)1 MarketplaceFilter (org.eclipse.epp.internal.mpc.ui.wizards.MarketplaceFilter)1 IMarket (org.eclipse.epp.mpc.core.model.IMarket)1 CatalogDescriptor (org.eclipse.epp.mpc.ui.CatalogDescriptor)1 Tag (org.eclipse.equinox.internal.p2.discovery.model.Tag)1 CatalogFilter (org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogFilter)1 DiscoveryWizard (org.eclipse.equinox.internal.p2.ui.discovery.wizards.DiscoveryWizard)1 IPropertyChangeListener (org.eclipse.jface.util.IPropertyChangeListener)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1