Search in sources :

Example 6 with FeatureEntry

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

the class ProfileChangeOperationComputer method pruneNonInstall.

private void pruneNonInstall(List<IInstallableUnit> installableUnits) {
    Set<String> installableFeatureIds = new HashSet<String>();
    for (FeatureEntry featureEntry : featureEntries) {
        Operation operation = featureEntry.computeChangeOperation();
        if (operation == Operation.INSTALL || operation == Operation.UPDATE) {
            installableFeatureIds.add(featureEntry.getFeatureDescriptor().getId());
        }
    }
    Iterator<IInstallableUnit> it = installableUnits.iterator();
    while (it.hasNext()) {
        IInstallableUnit iu = it.next();
        if (!installableFeatureIds.contains(iu.getId())) {
            it.remove();
        }
    }
}
Also used : FeatureEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) RemediationOperation(org.eclipse.equinox.p2.operations.RemediationOperation) ProfileChangeOperation(org.eclipse.equinox.p2.operations.ProfileChangeOperation) UninstallOperation(org.eclipse.equinox.p2.operations.UninstallOperation) Operation(org.eclipse.epp.mpc.ui.Operation) InstallOperation(org.eclipse.equinox.p2.operations.InstallOperation) HashSet(java.util.HashSet)

Example 7 with FeatureEntry

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

the class ProfileChangeOperationComputer method pruneNonUninstall.

private void pruneNonUninstall(List<IInstallableUnit> installableUnits) {
    Set<String> installableFeatureIds = new HashSet<String>();
    for (FeatureEntry featureEntry : featureEntries) {
        if (featureEntry.computeChangeOperation() == Operation.UNINSTALL) {
            installableFeatureIds.add(featureEntry.getFeatureDescriptor().getId());
        }
    }
    Iterator<IInstallableUnit> it = installableUnits.iterator();
    while (it.hasNext()) {
        IInstallableUnit iu = it.next();
        if (!installableFeatureIds.contains(iu.getId())) {
            it.remove();
        }
    }
}
Also used : FeatureEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) HashSet(java.util.HashSet)

Example 8 with FeatureEntry

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

the class ProfileChangeOperationComputer method checkForUnavailable.

/**
 * Verifies that we found what we were looking for: it's possible that we have connector descriptors that are no
 * longer available on their respective sites. In that case we must inform the user. Unfortunately this is the
 * earliest point at which we can know.
 */
private void checkForUnavailable(final List<IInstallableUnit> installableUnits) throws CoreException {
    // at least one selected connector could not be found in a repository
    Set<String> foundIds = new HashSet<String>();
    for (IInstallableUnit unit : installableUnits) {
        foundIds.add(unit.getId());
    }
    Set<String> installFeatureIds = new HashSet<String>();
    for (FeatureEntry entry : featureEntries) {
        Operation operation = entry.computeChangeOperation();
        if (operation == Operation.INSTALL || operation == Operation.UPDATE) {
            installFeatureIds.add(entry.getFeatureDescriptor().getId());
        }
    }
    // $NON-NLS-1$
    String message = "";
    // $NON-NLS-1$
    String detailedMessage = "";
    for (CatalogItem descriptor : items) {
        StringBuilder unavailableIds = null;
        for (String id : getFeatureIds(descriptor)) {
            if (!foundIds.contains(id) && installFeatureIds.contains(id)) {
                if (unavailableIds == null) {
                    unavailableIds = new StringBuilder();
                } else {
                    unavailableIds.append(Messages.ProvisioningOperation_commaSeparator);
                }
                unavailableIds.append(id);
            }
        }
        if (unavailableIds != null) {
            if (message.length() > 0) {
                message += Messages.ProvisioningOperation_commaSeparator;
            }
            message += descriptor.getName();
            if (detailedMessage.length() > 0) {
                detailedMessage += Messages.ProvisioningOperation_commaSeparator;
            }
            detailedMessage += NLS.bind(Messages.ProvisioningOperation_unavailableFeatures, new Object[] { descriptor.getName(), unavailableIds.toString(), descriptor.getSiteUrl() });
        }
    }
    if (message.length() > 0) {
        // instead of aborting here we ask the user if they wish to proceed anyways
        final boolean[] okayToProceed = new boolean[1];
        final String finalMessage = message;
        Display.getDefault().syncExec(new Runnable() {

            public void run() {
                okayToProceed[0] = MessageDialog.openQuestion(WorkbenchUtil.getShell(), Messages.ProvisioningOperation_proceedQuestion, NLS.bind(Messages.ProvisioningOperation_unavailableSolutions_proceedQuestion, new Object[] { finalMessage }));
            }
        });
        if (!okayToProceed[0]) {
            throw new CoreException(new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, NLS.bind(Messages.ProvisioningOperation_unavailableSolutions, detailedMessage), null));
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) RemediationOperation(org.eclipse.equinox.p2.operations.RemediationOperation) ProfileChangeOperation(org.eclipse.equinox.p2.operations.ProfileChangeOperation) UninstallOperation(org.eclipse.equinox.p2.operations.UninstallOperation) Operation(org.eclipse.epp.mpc.ui.Operation) InstallOperation(org.eclipse.equinox.p2.operations.InstallOperation) CatalogItem(org.eclipse.equinox.internal.p2.discovery.model.CatalogItem) FeatureEntry(org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry) CoreException(org.eclipse.core.runtime.CoreException) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) HashSet(java.util.HashSet)

Example 9 with FeatureEntry

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

the class FeatureDependenciesAction method getRequiredCapabilities.

@Override
protected Set<IRequirement> getRequiredCapabilities() {
    Set<IRequirement> required = new LinkedHashSet<>();
    if (feature.getLicenseFeature() != null) {
        String id = feature.getLicenseFeature() + FEATURE_GROUP_IU_SUFFIX;
        VersionRange range = getVersionRange(createVersion(feature.getLicenseFeatureVersion()));
        required.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, null, false, /* optional */
        false));
    }
    for (FeatureEntry entry : feature.getEntries()) {
        if (entry.isPatch()) {
            // target platform
            continue;
        }
        VersionRange range;
        if (entry.isRequires()) {
            range = getVersionRange(entry);
        } else {
            range = getVersionRange(createVersion(entry.getVersion()));
        }
        String id = getInstallableUnitId(entry);
        // TODO 391283 without enhancement 391283, additional filters will always evaluate to false -> ignore for now
        boolean optional = entry.isOptional();
        required.add(MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, id, range, createFilter(entry), optional, false));
    }
    return required;
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) LinkedHashSet(java.util.LinkedHashSet) FeatureEntry(org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry) VersionRange(org.eclipse.equinox.p2.metadata.VersionRange)

Example 10 with FeatureEntry

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

the class FeatureDependenciesAction method addProperties.

@Override
protected void addProperties(InstallableUnitDescription iud) {
    iud.setProperty(QueryUtil.PROP_TYPE_GROUP, "true");
    StringBuilder includedIUs = new StringBuilder();
    for (FeatureEntry entry : feature.getEntries()) {
        String id = getInstallableUnitId(entry);
        if (includedIUs.length() > 0) {
            includedIUs.append(',');
        }
        includedIUs.append(id);
    }
    iud.setProperty(INCLUDED_IUS, includedIUs.toString());
}
Also used : FeatureEntry(org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry)

Aggregations

HashSet (java.util.HashSet)5 FeatureEntry (org.eclipse.epp.internal.mpc.ui.wizards.SelectionModel.FeatureEntry)5 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)4 FeatureEntry (org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry)4 Operation (org.eclipse.epp.mpc.ui.Operation)3 CatalogItem (org.eclipse.equinox.internal.p2.discovery.model.CatalogItem)3 ProfileChangeOperation (org.eclipse.equinox.p2.operations.ProfileChangeOperation)3 RemediationOperation (org.eclipse.equinox.p2.operations.RemediationOperation)3 UninstallOperation (org.eclipse.equinox.p2.operations.UninstallOperation)3 HashMap (java.util.HashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 CoreException (org.eclipse.core.runtime.CoreException)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)2 Version (org.eclipse.equinox.p2.metadata.Version)2 VersionRange (org.eclipse.equinox.p2.metadata.VersionRange)2 InstallOperation (org.eclipse.equinox.p2.operations.InstallOperation)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 URI (java.net.URI)1