org.eclipse.equinox.p2.operations.ProvisioningSession Java Examples
The following examples show how to use
org.eclipse.equinox.p2.operations.ProvisioningSession.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UpdateManager.java From developer-studio with Apache License 2.0 | 6 votes |
protected void initProvisioningAgent() throws RuntimeException { try { // Inject references BundleContext bundleContext = FrameworkUtil.getBundle(UpdateManager.class).getBundleContext(); IEclipseContext serviceContext = EclipseContextFactory.getServiceContext(bundleContext); ContextInjectionFactory.inject(this, serviceContext); // get p2 agent for current system(Eclipse instance in this // case) // the location for the currently running system is null (see // docs) p2Agent = agentProvider.createAgent(null); session = new ProvisioningSession(p2Agent); artifactRepoManager = (IArtifactRepositoryManager) p2Agent .getService(IArtifactRepositoryManager.class.getName()); metadataRepoManager = (IMetadataRepositoryManager) p2Agent .getService(IMetadataRepositoryManager.class.getName()); } catch (Exception e) { throw new RuntimeException(Messages.UpdateManager_14, e); } }
Example #2
Source File: P2Util.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * Check for application updates. * * @param agent * @param monitor * @return * @throws OperationCanceledException */ public static IStatus checkForUpdates(IProvisioningAgent agent, IProgressMonitor monitor) throws OperationCanceledException{ System.out.println(">> checkForUpdates"); ProvisioningSession session = new ProvisioningSession(agent); UpdateOperation operation = new UpdateOperation(session); SubMonitor sub = SubMonitor.convert(monitor, "Checking for application updates...", 200); return operation.resolveModal(sub.newChild(100)); }
Example #3
Source File: P2Util.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * Download and install application updates. * * @param agent * @param monitor * @return * @throws OperationCanceledException */ public static IStatus installUpdates(IProvisioningAgent agent, IProgressMonitor monitor) throws OperationCanceledException{ ProvisioningSession session = new ProvisioningSession(agent); UpdateOperation operation = new UpdateOperation(session); SubMonitor sub = SubMonitor.convert(monitor, "Installing updates ...", 200); operation.resolveModal(sub.newChild(100)); ProvisioningJob job = operation.getProvisioningJob(monitor); return job.runModal(sub.newChild(100)); }
Example #4
Source File: UpdateManager.java From developer-studio with Apache License 2.0 | 4 votes |
/** * Install selected updates in to developer studio. Note: call * {@link #setSelectedUpdates(List) setSelectedUpdates} first. * * @param monitor */ public void installSelectedUpdates(IProgressMonitor monitor) { SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_26, 2); URI[] repos = new URI[] { getDevStudioUpdateSite() }; session = new ProvisioningSession(p2Agent); updateOperation = new UpdateOperation(session); updateOperation.getProvisioningContext().setArtifactRepositories(repos); updateOperation.getProvisioningContext().setMetadataRepositories(repos); updateOperation.setSelectedUpdates(selectedUpdates); IStatus status = updateOperation.resolveModal(progress.newChild(1)); if (status.getSeverity() == IStatus.CANCEL) { throw new OperationCanceledException(); } else if (status.getSeverity() == IStatus.ERROR) { String message = status.getChildren()[0].getMessage(); UpdateMetaFileReaderJob.promptUserError(message, Messages.UpdateManager_27); log.error(Messages.UpdateManager_27 + message); } else { final ProvisioningJob provisioningJob = updateOperation.getProvisioningJob(progress.newChild(1)); if (provisioningJob != null) { provisioningJob.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent arg0) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { boolean restart = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), Messages.UpdateManager_28, Messages.UpdateManager_29 + Messages.UpdateManager_30); if (restart) { PlatformUI.getWorkbench().restart(); } } }); } }); provisioningJob.schedule(); Display.getDefault().syncExec(new Runnable() { @Override public void run() { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView(IProgressConstants.PROGRESS_VIEW_ID); } catch (PartInitException e) { log.error(e); } } }); } else { log.error(Messages.UpdateManager_31); } } }
Example #5
Source File: UpdateManager.java From developer-studio with Apache License 2.0 | 4 votes |
/** * Install selected features in to developer studio. Note: call * {@link #setSelectedFeaturesToInstall(List) setSelectedFeaturesToInstall} * first. * * @param monitor */ public void installSelectedFeatures(IProgressMonitor monitor) { SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_32, 2); URI[] repos = new URI[] { getDevStudioReleaseSite() }; session = new ProvisioningSession(p2Agent); installOperation = new InstallOperation(session, selectedFeatures); installOperation.getProvisioningContext().setArtifactRepositories(repos); installOperation.getProvisioningContext().setMetadataRepositories(repos); IStatus status = installOperation.resolveModal(progress.newChild(1)); if (status.getSeverity() == IStatus.CANCEL || progress.isCanceled()) { throw new OperationCanceledException(); } else if (status.getSeverity() == IStatus.ERROR) { String message = status.getChildren()[0].getMessage(); log.error(Messages.UpdateManager_33 + message); UpdateMetaFileReaderJob.promptUserError(message, Messages.UpdateManager_33); } else { ProvisioningJob provisioningJob = installOperation.getProvisioningJob(progress.newChild(1)); if (provisioningJob != null) { provisioningJob.addJobChangeListener(new JobChangeAdapter() { @Override public void done(IJobChangeEvent arg0) { Display.getDefault().syncExec(new Runnable() { @Override public void run() { boolean restart = MessageDialog.openQuestion(Display.getDefault().getActiveShell(), Messages.UpdateManager_34, Messages.UpdateManager_35 + Messages.UpdateManager_36); if (restart) { PlatformUI.getWorkbench().restart(); } } }); } }); provisioningJob.schedule(); Display.getDefault().syncExec(new Runnable() { @Override public void run() { try { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .showView(IProgressConstants.PROGRESS_VIEW_ID); } catch (PartInitException e) { log.error(e); } } }); } else { log.error(Messages.UpdateManager_37); } } }