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;
}
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);
}
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;
}
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);
}
}
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;
}
Aggregations