Search in sources :

Example 6 with Feature

use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project webtools.servertools by eclipse.

the class ExtensionUtility method alreadyExists.

/**
 * Return true if the new feature is already installed, or a newer one is.
 *
 * @param existing
 * @param newFeature
 * @return true if the new feature is already installed, or a newer one is.
 */
private static boolean alreadyExists(List<Extension> existing, IServerExtension newFeature) {
    if (existing.contains(newFeature))
        return true;
    Version newV = newFeature.getVersion();
    Iterator<Extension> iterator = existing.iterator();
    while (iterator.hasNext()) {
        IServerExtension feature = iterator.next();
        if (feature.getId().equals(newFeature.getId())) {
            if (newV == null)
                return true;
            if (feature.getVersion().compareTo(newV) >= 0)
                return true;
        }
    }
    return false;
}
Also used : Version(org.eclipse.equinox.p2.metadata.Version)

Example 7 with Feature

use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project epp.mpc by eclipse.

the class MarketplaceWizard method getNextPage.

IWizardPage getNextPage(IWizardPage page, boolean nextpressed) {
    boolean skipFeatureSelection = false;
    MarketplacePage catalogPage = getCatalogPage();
    if (page == catalogPage && nextpressed) {
        profileChangeOperation = null;
        featureSelectionWizardPage.updateMessage();
        if (catalogPage.canSkipFeatureSelection()) {
            skipFeatureSelection = true;
        }
    }
    if (page == featureSelectionWizardPage || (page == catalogPage && skipFeatureSelection)) {
        IWizardContainer container = getContainer();
        if (nextpressed && profileChangeOperation != null && profileChangeOperation instanceof RemediationOperation) {
            try {
                container.run(true, false, new IRunnableWithProgress() {

                    public void run(IProgressMonitor monitor) {
                        ((RemediationOperation) profileChangeOperation).setCurrentRemedy(featureSelectionWizardPage.getRemediationGroup().getCurrentRemedy());
                        profileChangeOperation.resolveModal(monitor);
                    }
                });
            } catch (InterruptedException e) {
            // Nothing to report if thread was interrupted
            } catch (InvocationTargetException e) {
                ProvUI.handleException(e.getCause(), null, StatusManager.SHOW | StatusManager.LOG);
            }
        }
        IWizardPage nextPage = null;
        boolean operationUpdated = false;
        if (profileChangeOperation == null) {
            if (nextpressed) {
                updateProfileChangeOperation();
                operationUpdated = true;
            }
            if (profileChangeOperation == null || !profileChangeOperation.getResolutionResult().isOK()) {
                // can't compute a change operation, so there must be some kind of error
                // we show these on the the feature selection wizard page
                nextPage = featureSelectionWizardPage;
            } else if (profileChangeOperation instanceof UninstallOperation) {
                // next button was used to resolve errors on an uninstall.
                // by returning the same page the finish button will be enabled, allowing the user to finish.
                nextPage = featureSelectionWizardPage;
            } else if (profileChangeOperation instanceof RemediationOperation) {
                nextPage = featureSelectionWizardPage;
            }
        }
        if (nextPage == null && nextpressed && profileChangeOperation instanceof RemediationOperation && !featureSelectionWizardPage.isInRemediationMode()) {
            featureSelectionWizardPage.flipToRemediationComposite();
            nextPage = featureSelectionWizardPage;
        }
        if (nextPage == null && computeMustCheckLicenseAcceptance()) {
            if (acceptLicensesPage == null) {
                acceptLicensesPage = new AcceptLicensesWizardPage(ProvisioningUI.getDefaultUI().getLicenseManager(), operationIUs, profileChangeOperation);
                addPage(acceptLicensesPage);
            } else {
                acceptLicensesPage.update(operationIUs, profileChangeOperation);
            }
            if (nextpressed || acceptLicensesPage.hasLicensesToAccept() || profileChangeOperation instanceof RemediationOperation) {
                nextPage = acceptLicensesPage;
            }
        }
        if (nextPage == null && page == catalogPage) {
            nextPage = featureSelectionWizardPage;
        }
        if (operationUpdated && nextPage == container.getCurrentPage()) {
            container.updateButtons();
        }
        return nextPage;
    }
    if (page instanceof ImportFavoritesPage) {
        return catalogPage;
    }
    return getNextPageInList(page);
}
Also used : IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AcceptLicensesWizardPage(org.eclipse.equinox.p2.ui.AcceptLicensesWizardPage) RemediationOperation(org.eclipse.equinox.p2.operations.RemediationOperation) UninstallOperation(org.eclipse.equinox.p2.operations.UninstallOperation) IWizardPage(org.eclipse.jface.wizard.IWizardPage) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 8 with Feature

use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project epp.mpc by eclipse.

the class AbstractProvisioningOperation method queryInstallableUnits.

/**
 * Perform a query to get the installable units. This causes p2 to determine what features are available in each
 * repository. We select installable units by matching both the feature id and the repository; it is possible though
 * unlikely that the same feature id is available from more than one of the selected repositories, and we must
 * ensure that the user gets the one that they asked for.
 */
protected List<IInstallableUnit> queryInstallableUnits(SubMonitor monitor, List<IMetadataRepository> repositories) throws URISyntaxException {
    final List<IInstallableUnit> installableUnits = new ArrayList<IInstallableUnit>();
    monitor.setWorkRemaining(repositories.size());
    for (final IMetadataRepository repository : repositories) {
        checkCancelled(monitor);
        final Set<String> installableUnitIdsThisRepository = getDescriptorIds(repository);
        IQuery<IInstallableUnit> query = QueryUtil.createLatestQuery(QueryUtil.createIUGroupQuery());
        IQueryResult<IInstallableUnit> result = repository.query(query, monitor.newChild(1));
        for (IInstallableUnit iu : result) {
            String id = iu.getId();
            if (installableUnitIdsThisRepository.contains(id)) {
                installableUnits.add(iu);
            }
        }
    }
    return installableUnits;
}
Also used : ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)

Example 9 with Feature

use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project epp.mpc by eclipse.

the class ResolveFeatureNamesOperation method run.

public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
    try {
        SubMonitor monitor = SubMonitor.convert(progressMonitor, Messages.ResolveFeatureNamesOperation_resolvingFeatures, 100);
        try {
            List<IMetadataRepository> repositories = addRepositories(monitor.newChild(50));
            List<IInstallableUnit> installableUnits = queryInstallableUnits(monitor.newChild(50), repositories);
            Set<String> resolvedFeatureIds = new HashSet<String>();
            for (IInstallableUnit iu : installableUnits) {
                FeatureDescriptor descriptor = new FeatureDescriptor(iu);
                resolvedFeatureIds.add(descriptor.getId());
                resolvedFeatureIds.add(descriptor.getSimpleId());
                featureDescriptors.add(descriptor);
            }
            for (CatalogItem catalogItem : items) {
                for (String iu : catalogItem.getInstallableUnits()) {
                    if (!resolvedFeatureIds.contains(iu)) {
                        FeatureDescriptor descriptor = new FeatureDescriptor(iu);
                        unresolvedFeatureDescriptors.add(descriptor);
                    }
                }
            }
        } finally {
            // SECURITY: resolving feature names should never add repositories
            removeAddedRepositoryLocations();
            monitor.done();
        }
    } catch (OperationCanceledException e) {
        throw new InterruptedException();
    } catch (Exception e) {
        throw new InvocationTargetException(e);
    }
}
Also used : OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository) HashSet(java.util.HashSet)

Example 10 with Feature

use of org.eclipse.equinox.p2.publisher.eclipse.Feature in project tycho by eclipse.

the class AbstractSiteDependenciesAction method getRequiredCapabilities.

@Override
protected Set<IRequirement> getRequiredCapabilities() {
    Set<IRequirement> required = new LinkedHashSet<>();
    for (SiteFeature feature : getSiteModel().getFeatures()) {
        // $NON-NLS-1$
        String id = feature.getFeatureIdentifier() + FEATURE_GROUP_IU_SUFFIX;
        VersionRange range = getVersionRange(createVersion(feature.getFeatureVersion()));
        String filter = new TargetEnvironment(feature.getOS(), feature.getWS(), feature.getOSArch()).toFilterExpression();
        // boolean optional = feature.isOptional();
        required.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, InstallableUnit.parseFilter(filter), false, false));
    }
    for (SiteBundle bundle : getSiteModel().getBundles()) {
        String id = bundle.getBundleIdentifier();
        VersionRange range = getVersionRange(createVersion(bundle.getBundleVersion()));
        String filter = new TargetEnvironment(bundle.getOS(), bundle.getWS(), bundle.getOSArch()).toFilterExpression();
        // boolean optional = feature.isOptional();
        required.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, InstallableUnit.parseFilter(filter), false, false));
    }
    for (SiteIU iu : getSiteModel().getIUs()) {
        IRequirement requirement = getRequirement(iu);
        if (requirement != null)
            required.add(requirement);
    }
    return required;
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) LinkedHashSet(java.util.LinkedHashSet) SiteIU(org.eclipse.equinox.internal.p2.updatesite.SiteIU) SiteFeature(org.eclipse.equinox.internal.p2.updatesite.SiteFeature) VersionRange(org.eclipse.equinox.p2.metadata.VersionRange) SiteBundle(org.eclipse.equinox.internal.p2.updatesite.SiteBundle) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment)

Aggregations

IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)8 ArrayList (java.util.ArrayList)6 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)4 Version (org.eclipse.equinox.p2.metadata.Version)4 Test (org.junit.Test)4 IMetadataRepository (org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)2 IRequiredCapability (org.eclipse.equinox.internal.p2.metadata.IRequiredCapability)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 Path (org.eclipse.core.runtime.Path)1