use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class ProfileChangeOperationComputer method resolve.
private ProfileChangeOperation resolve(IProgressMonitor monitor, ProfileChangeOperationFactory operationFactory, IInstallableUnit[] ius, URI[] repositories) throws CoreException {
List<IInstallableUnit> installableUnits = Arrays.asList(ius);
List<ResolutionStrategy> strategies = new ArrayList<ProfileChangeOperationComputer.ResolutionStrategy>(2);
switch(resolutionStrategy) {
case FALLBACK_STRATEGY:
strategies.add(ResolutionStrategy.SELECTED_REPOSITORIES);
strategies.add(ResolutionStrategy.ALL_REPOSITORIES);
break;
default:
strategies.add(resolutionStrategy);
}
ProvisioningSession session = ProvisioningUI.getDefaultUI().getSession();
RepositoryTracker repositoryTracker = ProvisioningUI.getDefaultUI().getRepositoryTracker();
URI[] knownRepositories = repositoryTracker.getKnownRepositories(session);
ProfileChangeOperation operation = null;
final int workPerStrategy = 1000;
SubMonitor subMonitor = SubMonitor.convert(monitor, strategies.size() * workPerStrategy + workPerStrategy);
Set<URI> previousRepositoryLocations = null;
for (ResolutionStrategy strategy : strategies) {
Set<URI> repositoryLocations = new HashSet<URI>(Arrays.asList(repositories));
if (strategy == ResolutionStrategy.SELECTED_REPOSITORIES) {
repositoryLocations.addAll(Arrays.asList(repositories));
}
if (dependenciesRepository != null) {
repositoryLocations.add(dependenciesRepository);
}
if (strategy == ResolutionStrategy.ALL_REPOSITORIES && !repositoryLocations.isEmpty()) {
repositoryLocations.addAll(Arrays.asList(knownRepositories));
}
if (repositoryLocations.equals(previousRepositoryLocations)) {
continue;
}
operation = operationFactory.create(installableUnits);
if (!repositoryLocations.isEmpty()) {
URI[] locations = repositoryLocations.toArray(new URI[repositoryLocations.size()]);
operation.getProvisioningContext().setMetadataRepositories(locations);
operation.getProvisioningContext().setArtifactRepositories(locations);
}
resolveModal(subMonitor.newChild(workPerStrategy), operation);
if (operation.getResolutionResult() != null && operation.getResolutionResult().getSeverity() != IStatus.ERROR) {
break;
}
previousRepositoryLocations = repositoryLocations;
}
return operation;
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project epp.mpc by eclipse.
the class MarketplaceCatalog method checkForUpdates.
public IStatus checkForUpdates(final IProgressMonitor monitor) {
SubMonitor progress = SubMonitor.convert(monitor, Messages.MarketplaceCatalog_checkingForUpdates, 10000000);
try {
Map<String, IInstallableUnit> installedIUs = calculateInstalledIUs(progress.newChild(100000));
List<MarketplaceNodeCatalogItem> updateCheckNeeded = new ArrayList<MarketplaceNodeCatalogItem>();
for (CatalogItem item : getItems()) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (!(item instanceof MarketplaceNodeCatalogItem)) {
continue;
}
MarketplaceNodeCatalogItem catalogItem = (MarketplaceNodeCatalogItem) item;
if (catalogItem.isInstalled()) {
if (setUpdatesAvailable(installedIUs, catalogItem)) {
updateCheckNeeded.add(catalogItem);
}
}
}
if (!updateCheckNeeded.isEmpty()) {
checkForUpdates(updateCheckNeeded, installedIUs, progress.newChild(10000000 - 100000));
}
return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
} finally {
monitor.done();
}
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project webtools.servertools by eclipse.
the class ExtensionUpdateSite method getInstallableUnits.
// Get the list of InstallableUnits and all its requirements
protected List<IServerExtension> getInstallableUnits(IMetadataRepository repo, IQuery<IInstallableUnit> query, URI url, IProgressMonitor monitor) {
List<IServerExtension> list = new ArrayList<IServerExtension>();
IQueryResult<IInstallableUnit> collector = repo.query(query, monitor);
for (IInstallableUnit iu : collector.toUnmodifiableSet()) {
Collection<IRequirement> req = iu.getRequirements();
if (req != null) {
for (IRequirement requirement : req) {
IMatchExpression<IInstallableUnit> matches = requirement.getMatches();
query = new ExpressionMatchQuery<IInstallableUnit>(IInstallableUnit.class, matches);
IQueryResult<IInstallableUnit> collector2 = repo.query(query, monitor);
Iterator<IInstallableUnit> iter2 = collector2.iterator();
while (iter2.hasNext()) {
IInstallableUnit iu2 = iter2.next();
if (!list.contains(iu2)) {
Extension ext = new Extension(iu2, url);
list.add(ext);
}
}
}
}
}
return list;
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project webtools.servertools by eclipse.
the class ExtensionWizardPage method handleSelection.
protected void handleSelection(Extension sel) {
extension = sel;
if (extension == null)
licensePage.updateForPlan(new IInstallableUnit[0], null);
else {
try {
getContainer().run(true, true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
final IProvisioningPlan plan = extension.getProvisioningPlan(true, monitor);
if (plan != null && plan.getStatus().isOK()) {
getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
licensePage.updateForPlan(extension.getIUs(), plan);
nextPage = licensePage;
((ExtensionWizard) getWizard()).setSecondPage(nextPage);
}
});
} else {
getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
errorPage.setStatus(plan.getStatus());
}
});
nextPage = errorPage;
((ExtensionWizard) getWizard()).setSecondPage(nextPage);
}
monitor.done();
}
});
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error verifying license", e);
}
}
setPageComplete(extension != null);
}
use of org.eclipse.equinox.p2.metadata.IInstallableUnit in project azure-tools-for-java by Microsoft.
the class PluginUtil method forceInstallPluginUsingP2.
private static void forceInstallPluginUsingP2(String pluginGroupID) {
URI repoURI = getEclipseP2Repository();
ProvisioningUI provisioningUI = ProvisioningUI.getDefaultUI();
if (provisioningUI != null && repoURI != null) {
ProvisioningSession provisioningSession = provisioningUI.getSession();
IProvisioningAgent provisioningAgent = null;
if (provisioningSession != null && (provisioningAgent = provisioningSession.getProvisioningAgent()) != null) {
IMetadataRepositoryManager manager = (IMetadataRepositoryManager) provisioningAgent.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (manager != null) {
try {
IMetadataRepository repository = manager.loadRepository(repoURI, null);
if (repository != null) {
IQueryResult<IInstallableUnit> iqr = repository.query(QueryUtil.createIUQuery(pluginGroupID), null);
if (iqr != null) {
Collection<IInstallableUnit> iuList = StreamSupport.stream(iqr.spliterator(), false).collect(Collectors.toList());
if (iuList.size() > 0) {
InstallOperation io = new InstallOperation(provisioningSession, iuList);
provisioningUI.openInstallWizard(iuList, io, null);
return;
}
}
}
} catch (Exception e) {
String errorMsg = "Error installing " + pluginGroupID + "! Please manually install using Eclipse P2 repository from: Help -> Install New Software.... Click OK to continue.";
PluginUtil.displayErrorDialogAndLog(getParentShell(), "Fail to install", errorMsg, e);
}
}
}
}
String errorMsg = "Error installing " + pluginGroupID + "! In the following installation wizard, please select the right repository and then filter by " + pluginGroupID + "! Click OK to continue.";
PluginUtil.displayErrorDialogAndLog(getParentShell(), "Fail to install", errorMsg, null);
provisioningUI.openInstallWizard(null, null, null);
}
Aggregations