Java Code Examples for org.eclipse.equinox.p2.operations.UpdateOperation#resolveModal()
The following examples show how to use
org.eclipse.equinox.p2.operations.UpdateOperation#resolveModal() .
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: UpdateHandler.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
protected void doExecute(LoadMetadataRepositoryJob job){ if (hasNoRepos) { return; } UpdateOperation operation = getProvisioningUI().getUpdateOperation(null, null); // check for updates operation.resolveModal(null); if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) { if (UpdateSingleIUWizard.validFor(operation)) { // Special case for only updating a single root UpdateSingleIUWizard wizard = new UpdateSingleIUWizard(getProvisioningUI(), operation); WizardDialog dialog = new WizardDialog(getShell(), wizard); dialog.create(); dialog.open(); } else { // Open the normal version of the update wizard getProvisioningUI().openUpdateWizard(false, operation, job); } } }
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); } } }