use of org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry in project epp.mpc by eclipse.
the class MarketplaceWizard method computeNewInstallCatalogItems.
private Set<CatalogItem> computeNewInstallCatalogItems() {
Set<CatalogItem> items = new HashSet<CatalogItem>();
Map<CatalogItem, Collection<String>> iusByCatalogItem = new HashMap<CatalogItem, Collection<String>>();
for (CatalogItemEntry entry : getSelectionModel().getCatalogItemEntries()) {
List<FeatureEntry> features = entry.getChildren();
Collection<String> featureIds = new ArrayList<String>(features.size());
for (FeatureEntry feature : features) {
if (feature.computeChangeOperation() == Operation.INSTALL) {
featureIds.add(feature.getFeatureDescriptor().getId());
}
}
if (!featureIds.isEmpty()) {
iusByCatalogItem.put(entry.getItem(), featureIds);
}
}
for (IInstallableUnit unit : operationIUs) {
for (Entry<CatalogItem, Collection<String>> entry : iusByCatalogItem.entrySet()) {
if (entry.getValue().contains(unit.getId())) {
items.add(entry.getKey());
}
}
}
return items;
}
use of org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry in project tycho by eclipse.
the class FeatureDependenciesAction method getVersionRange.
/**
* Copy&Paste from 3.7
* org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction.getVersionRange(FeatureEntry)
*/
private VersionRange getVersionRange(FeatureEntry entry) {
String versionSpec = entry.getVersion();
if (versionSpec == null)
return VersionRange.emptyRange;
String match = entry.getMatch();
if (// $NON-NLS-1$
"versionRange".equals(match))
return new VersionRange(versionSpec);
Version version = Version.parseVersion(versionSpec);
if (version.equals(Version.emptyVersion))
return VersionRange.emptyRange;
if (!entry.isRequires())
return new VersionRange(version, true, version, true);
if (match == null)
// TODO should really be returning VersionRange.emptyRange here...
return null;
if (// $NON-NLS-1$
match.equals("perfect"))
return new VersionRange(version, true, version, true);
org.osgi.framework.Version osgiVersion = PublisherHelper.toOSGiVersion(version);
if (match.equals("equivalent")) {
// $NON-NLS-1$
Version upper = Version.createOSGi(osgiVersion.getMajor(), osgiVersion.getMinor() + 1, 0);
return new VersionRange(version, true, upper, false);
}
if (match.equals("compatible")) {
// $NON-NLS-1$
Version upper = Version.createOSGi(osgiVersion.getMajor() + 1, 0, 0);
return new VersionRange(version, true, upper, false);
}
if (// $NON-NLS-1$
match.equals("greaterOrEqual"))
return new VersionRange(version, true, new VersionRange(null).getMaximum(), true);
return null;
}
use of org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry in project tycho by eclipse.
the class ProductDependenciesAction method getRequiredCapabilities.
@Override
protected Set<IRequirement> getRequiredCapabilities() {
Set<IRequirement> required = new LinkedHashSet<>();
if (product.useFeatures()) {
for (IVersionedId feature : product.getFeatures()) {
// $NON-NLS-1$
String id = feature.getId() + FEATURE_GROUP_IU_SUFFIX;
Version version = feature.getVersion();
addRequiredCapability(required, id, version, null, false);
}
} else {
for (FeatureEntry plugin : ((ProductFile) product).getProductEntries()) {
addRequiredCapability(required, plugin.getId(), Version.parseVersion(plugin.getVersion()), null, true);
}
}
if (product.includeLaunchers()) {
addRequiredCapability(required, "org.eclipse.equinox.executable.feature.group", null, null, false);
}
return required;
}
use of org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry in project tycho by eclipse.
the class ProductFile2 method processPlugin.
@Override
protected void processPlugin(Attributes attributes) {
String fragment = attributes.getValue(ATTRIBUTE_FRAGMENT);
String pluginId = attributes.getValue(ATTRIBUTE_ID);
String pluginVersion = attributes.getValue(ATTRIBUTE_VERSION);
boolean isFragment = Boolean.valueOf(fragment);
FeatureEntry entry = new FeatureEntry(pluginId, pluginVersion != null ? pluginVersion : GENERIC_VERSION_NUMBER, true);
entry.setFragment(isFragment);
String os = attributes.getValue(ATTRIBUTE_OS);
String ws = attributes.getValue(ATTRIBUTE_WS);
String arch = attributes.getValue(ATTRIBUTE_ARCH);
if (os != null || ws != null || arch != null) {
entry.setEnvironment(os, ws, arch, null);
}
if (isFragment) {
fragments.add(entry);
} else {
plugins.add(entry);
}
}
use of org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry in project epp.mpc by eclipse.
the class MarketplaceWizard method updateProfileChangeOperation.
public void updateProfileChangeOperation() {
removeAddedRepositoryLocations();
addedRepositoryLocations = null;
profileChangeOperation = null;
operationIUs = null;
IWizardContainer wizardContainer = getContainer();
if (getSelectionModel().computeProvisioningOperationViable()) {
ProfileChangeOperationComputer provisioningOperation = null;
try {
final Map<CatalogItem, Operation> itemToOperation = getSelectionModel().getItemToSelectedOperation();
final Set<CatalogItem> selectedItems = getSelectionModel().getSelectedCatalogItems();
OperationType operationType = null;
for (Map.Entry<CatalogItem, Operation> entry : itemToOperation.entrySet()) {
if (!selectedItems.contains(entry.getKey())) {
continue;
}
OperationType entryOperationType = OperationType.map(entry.getValue());
if (entryOperationType != null) {
if (operationType == null || operationType == OperationType.UPDATE || entryOperationType == OperationType.CHANGE) {
operationType = entryOperationType;
}
}
}
Map<FeatureEntry, Operation> featureEntries = getSelectionModel().getFeatureEntryToOperation(false, false);
if (operationType == OperationType.CHANGE || operationType == OperationType.UPDATE) {
Set<OperationType> featureOperations = EnumSet.noneOf(OperationType.class);
for (Entry<FeatureEntry, Operation> entry : featureEntries.entrySet()) {
OperationType operation = OperationType.map(entry.getValue());
if (operation != null) {
featureOperations.add(operation);
}
}
if (featureOperations.contains(OperationType.INSTALL) && featureOperations.contains(OperationType.UPDATE)) {
// just perform install instead, which covers update
featureOperations.remove(OperationType.UPDATE);
}
if (featureOperations.size() == 1) {
operationType = featureOperations.iterator().next();
}
}
URI dependenciesRepository = null;
if (getConfiguration().getCatalogDescriptor().getDependenciesRepository() != null) {
try {
dependenciesRepository = getConfiguration().getCatalogDescriptor().getDependenciesRepository().toURI();
} catch (URISyntaxException e) {
throw new InvocationTargetException(e);
}
}
provisioningOperation = new ProfileChangeOperationComputer(operationType, selectedItems, featureEntries.keySet(), dependenciesRepository, getConfiguration().getCatalogDescriptor().isInstallFromAllRepositories() ? ProfileChangeOperationComputer.ResolutionStrategy.FALLBACK_STRATEGY : ProfileChangeOperationComputer.ResolutionStrategy.SELECTED_REPOSITORIES, withRemediation);
wizardContainer.run(true, true, provisioningOperation);
profileChangeOperation = provisioningOperation.getOperation();
operationIUs = provisioningOperation.getIus();
addedRepositoryLocations = provisioningOperation.getAddedRepositoryLocations();
operationNewInstallItems = computeNewInstallCatalogItems();
errorMessage = provisioningOperation.getErrorMessage();
final IStatus result = profileChangeOperation.getResolutionResult();
if (result != null && operationIUs != null && operationIUs.length > 0 && operationType == OperationType.INSTALL) {
switch(result.getSeverity()) {
case IStatus.ERROR:
Job job = new Job(Messages.MarketplaceWizard_errorNotificationJob) {
IStatus r = result;
Set<CatalogItem> items = new HashSet<CatalogItem>(itemToOperation.keySet());
IInstallableUnit[] ius = operationIUs;
String details = profileChangeOperation.getResolutionDetails();
{
setSystem(false);
setUser(false);
setPriority(LONG);
}
@Override
protected IStatus run(IProgressMonitor monitor) {
getCatalog().installErrorReport(monitor, r, items, ius, details);
return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
}
};
job.schedule();
}
}
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
IStatus status;
if (cause instanceof CoreException) {
status = ((CoreException) cause).getStatus();
} else {
status = new Status(IStatus.ERROR, MarketplaceClientUi.BUNDLE_ID, NLS.bind(Messages.MarketplaceWizard_problemsPerformingProvisioningOperation, new Object[] { cause.getMessage() }), cause);
}
MarketplaceClientUi.handle(status, StatusManager.SHOW | StatusManager.BLOCK | StatusManager.LOG);
} catch (InterruptedException e) {
// canceled
MarketplaceClientUi.log(IStatus.CANCEL, MarketplaceClientUi.BUNDLE_ID, Messages.MarketplaceWizard_ProvisioningOperationCancelled, e);
} finally {
if (provisioningOperation != null) {
addedRepositoryLocations = provisioningOperation.getAddedRepositoryLocations();
}
}
}
// re-get the container - in case the wizard was closed in the meantime, this will be null...
wizardContainer = getContainer();
if (wizardContainer != null && wizardContainer.getCurrentPage() == featureSelectionWizardPage) {
featureSelectionWizardPage.updateMessage();
}
}
Aggregations