本文整理汇总了Java中org.eclipse.equinox.p2.operations.UpdateOperation.getProvisioningJob方法的典型用法代码示例。如果您正苦于以下问题:Java UpdateOperation.getProvisioningJob方法的具体用法?Java UpdateOperation.getProvisioningJob怎么用?Java UpdateOperation.getProvisioningJob使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.equinox.p2.operations.UpdateOperation
的用法示例。
在下文中一共展示了UpdateOperation.getProvisioningJob方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installUpdates
import org.eclipse.equinox.p2.operations.UpdateOperation; //导入方法依赖的package包/类
/**
* 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));
}
示例2: checkForUpdates
import org.eclipse.equinox.p2.operations.UpdateOperation; //导入方法依赖的package包/类
public static IStatus checkForUpdates(IProvisioningAgent agent, IProgressMonitor monitor) throws Exception {
try {
addUpdateSite(agent);
ProvisioningSession session = new ProvisioningSession(agent);
// the default update operation looks for updates to the currently
// running profile, using the default profile root marker. To change
// which installable units are being updated, use the more detailed
// constructors.
UpdateOperation operation = new UpdateOperation(session);
SubMonitor sub = SubMonitor.convert(monitor, "Checking for application updates...", 200);
IStatus status = operation.resolveModal(sub.newChild(100));
if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
return status;
}
if (status.getSeverity() == IStatus.CANCEL)
throw new OperationCanceledException();
if (status.getSeverity() != IStatus.ERROR) {
// More complex status handling might include showing the user what updates
// are available if there are multiples, differentiating patches vs. updates, etc.
// In this example, we simply update as suggested by the operation.
ProvisioningJob job = operation.getProvisioningJob(null);
status = job.runModal(sub.newChild(100));
if (status.getSeverity() == IStatus.CANCEL)
throw new OperationCanceledException();
}
return status;
} catch (Throwable ex) {
// LOG.error(ex);
return null;
} finally {
// if (useProxy) {
// proxySettings.resetProxy();
// }
}
}
示例3: installSelectedUpdates
import org.eclipse.equinox.p2.operations.UpdateOperation; //导入方法依赖的package包/类
/**
* 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);
}
}
}