本文整理汇总了Java中org.eclipse.equinox.p2.operations.UpdateOperation.resolveModal方法的典型用法代码示例。如果您正苦于以下问题:Java UpdateOperation.resolveModal方法的具体用法?Java UpdateOperation.resolveModal怎么用?Java UpdateOperation.resolveModal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.equinox.p2.operations.UpdateOperation
的用法示例。
在下文中一共展示了UpdateOperation.resolveModal方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doExecute
import org.eclipse.equinox.p2.operations.UpdateOperation; //导入方法依赖的package包/类
@Override
protected void doExecute(LoadMetadataRepositoryJob job) {
if (hasNoRepos) {
MessageDialog.openInformation(null, "Update Yamcs Studio", "Could not check for updates since no repository is configured");
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);
}
}
}
示例2: doExecute
import org.eclipse.equinox.p2.operations.UpdateOperation; //导入方法依赖的package包/类
protected void doExecute(LoadMetadataRepositoryJob job) {
if (hasNoRepos) {
System.out.println("no repos");
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);
}
}
}
示例3: doExecute
import org.eclipse.equinox.p2.operations.UpdateOperation; //导入方法依赖的package包/类
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);
}
}
}
示例4: doExecute
import org.eclipse.equinox.p2.operations.UpdateOperation; //导入方法依赖的package包/类
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);
}
}
}
示例5: checkForUpdates
import org.eclipse.equinox.p2.operations.UpdateOperation; //导入方法依赖的package包/类
/**
* 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));
}
示例6: 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));
}
示例7: 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();
// }
}
}
示例8: checkForAvailableUpdates
import org.eclipse.equinox.p2.operations.UpdateOperation; //导入方法依赖的package包/类
/**
* Finds available WSO2 features in current profile and search for updates
* to them in WSO2 p2 repository for updates.
*
* @param monitor
* @throws Exception
*/
public void checkForAvailableUpdates(IProgressMonitor monitor) throws Exception {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
SubMonitor progress = SubMonitor.convert(monitor, Messages.UpdateManager_18, 6);
// get all available IUs in update repository
IMetadataRepository metadataRepo = null;
try {
metadataRepo = metadataRepoManager.loadRepository(getDevStudioUpdateSite(), progress.newChild(1));
} catch (ProvisionException e) {
UpdateMetaFileReaderJob.promptUserError(
"The P2 Does not existed at the given location, please set the update/releases P2 for Developer Studio in the Preference Store",
"P2 Repository Error");
throw e;
}
IQuery<IInstallableUnit> allIUQuery = QueryUtil.createIUAnyQuery();
IQueryResult<IInstallableUnit> allIUQueryResult = metadataRepo.query(allIUQuery, progress.newChild(1));
// read artifact repository for updates
IArtifactRepository artifactRepo = artifactRepoManager.loadRepository(getDevStudioUpdateSite(),
progress.newChild(1));
// read meta-data of all available features
Map<String, EnhancedFeature> unsortedMap = loadWSO2FeaturesInRepo(artifactRepo, allIUQueryResult,
progress.newChild(1));
// sort the map in alphabetical order
Map<String, EnhancedFeature> allFeaturesInUpdateRepo = new TreeMap<String, EnhancedFeature>(unsortedMap);
// get all installed wso2 features
Collection<IInstallableUnit> installedWSO2Features = getInstalledWSO2Features(progress.newChild(1));
installedWSO2FeaturesMap = new HashMap<String, IInstallableUnit>();
for (IInstallableUnit iInstallableUnit : installedWSO2Features) {
installedWSO2FeaturesMap.put(iInstallableUnit.getId(), iInstallableUnit);
}
if (progress.isCanceled()) {
throw new OperationCanceledException();
}
URI[] repos = new URI[] { getDevStudioUpdateSite() };
updateOperation = new UpdateOperation(session, installedWSO2Features);
updateOperation.getProvisioningContext().setArtifactRepositories(repos);
updateOperation.getProvisioningContext().setMetadataRepositories(repos);
// resolve update operation
IStatus status = updateOperation.resolveModal(progress.newChild(1));
// user cancelled the job while resolving
if (status.getSeverity() == IStatus.CANCEL || progress.isCanceled()) {
throw new OperationCanceledException();
}
// there is nothing to update
if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
featuresWithPossibleUpdates = new HashMap<String, EnhancedFeature>();
log.info(Messages.UpdateManager_19);
} else if (status.getSeverity() == IStatus.ERROR) { // resolution errors
// something wrong with the updates
log.info(Messages.UpdateManager_20);
} else {
// good to proceed installing updates
setPossibleUpdates(updateOperation.getPossibleUpdates(), allFeaturesInUpdateRepo);
}
// sort the available updates in alphabetical order
}
示例9: 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);
}
}
}
示例10: shouldUpdate
import org.eclipse.equinox.p2.operations.UpdateOperation; //导入方法依赖的package包/类
public boolean shouldUpdate() {
try {
IProvisioningAgentProvider agentProvider= Activator.getDefault().getProvisioningAgentProvider();
if (agentProvider == null) {
Activator.getDefault().logErrorStatus("Could not find a provisioning agent provider.", new RuntimeException());
return false;
}
final IProvisioningAgent agent= agentProvider.createAgent(null);
IMetadataRepositoryManager metadataRepositoryManager= (IMetadataRepositoryManager)agent.getService(IMetadataRepositoryManager.SERVICE_NAME);
if (metadataRepositoryManager == null) {
Activator.getDefault().logErrorStatus("Could not find the meta data repository manager.", new RuntimeException());
return false;
}
IArtifactRepositoryManager artifactRepositoryManager= (IArtifactRepositoryManager)agent.getService(IArtifactRepositoryManager.SERVICE_NAME);
if (artifactRepositoryManager == null) {
Activator.getDefault().logErrorStatus("Could not find the artifact repository manager.", new RuntimeException());
return false;
}
metadataRepositoryManager.addRepository(getUpdateSiteURI(updateSite));
artifactRepositoryManager.addRepository(getUpdateSiteURI(updateSite));
metadataRepositoryManager.loadRepository(getUpdateSiteURI(updateSite), new NullProgressMonitor());
final IProfileRegistry registry= (IProfileRegistry)agent.getService(IProfileRegistry.SERVICE_NAME);
if (registry == null) {
Activator.getDefault().logErrorStatus("Could not find the profile registry.", new RuntimeException());
return false;
}
final IProfile profile= registry.getProfile(IProfileRegistry.SELF);
if (profile == null) {
Activator.getDefault().logErrorStatus("Could not find the profile.", new RuntimeException());
return false;
}
IQuery<IInstallableUnit> query= QueryUtil.createIUQuery(pluginID);
Collection<IInstallableUnit> iusToUpdate= profile.query(query, null).toUnmodifiableSet();
ProvisioningSession provisioningSession= new ProvisioningSession(agent);
final UpdateOperation updateOperation= new UpdateOperation(provisioningSession, iusToUpdate);
IStatus modalResolution= updateOperation.resolveModal(new NullProgressMonitor());
if (modalResolution.isOK())
return true;
} catch (ProvisionException e) {
Activator.getDefault().logErrorStatus("A provisioning exception occured while checking for updates.", e);
}
return false;
}