use of org.eclipse.equinox.p2.operations.RemediationOperation in project epp.mpc by eclipse.
the class MarketplaceWizard method getNextPage.
IWizardPage getNextPage(IWizardPage page, boolean nextpressed) {
boolean skipFeatureSelection = false;
MarketplacePage catalogPage = getCatalogPage();
if (page == catalogPage && nextpressed) {
profileChangeOperation = null;
featureSelectionWizardPage.updateMessage();
if (catalogPage.canSkipFeatureSelection()) {
skipFeatureSelection = true;
}
}
if (page == featureSelectionWizardPage || (page == catalogPage && skipFeatureSelection)) {
IWizardContainer container = getContainer();
if (nextpressed && profileChangeOperation != null && profileChangeOperation instanceof RemediationOperation) {
try {
container.run(true, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
((RemediationOperation) profileChangeOperation).setCurrentRemedy(featureSelectionWizardPage.getRemediationGroup().getCurrentRemedy());
profileChangeOperation.resolveModal(monitor);
}
});
} catch (InterruptedException e) {
// Nothing to report if thread was interrupted
} catch (InvocationTargetException e) {
ProvUI.handleException(e.getCause(), null, StatusManager.SHOW | StatusManager.LOG);
}
}
IWizardPage nextPage = null;
boolean operationUpdated = false;
if (profileChangeOperation == null) {
if (nextpressed) {
updateProfileChangeOperation();
operationUpdated = true;
}
if (profileChangeOperation == null || !profileChangeOperation.getResolutionResult().isOK()) {
// can't compute a change operation, so there must be some kind of error
// we show these on the the feature selection wizard page
nextPage = featureSelectionWizardPage;
} else if (profileChangeOperation instanceof UninstallOperation) {
// next button was used to resolve errors on an uninstall.
// by returning the same page the finish button will be enabled, allowing the user to finish.
nextPage = featureSelectionWizardPage;
} else if (profileChangeOperation instanceof RemediationOperation) {
nextPage = featureSelectionWizardPage;
}
}
if (nextPage == null && nextpressed && profileChangeOperation instanceof RemediationOperation && !featureSelectionWizardPage.isInRemediationMode()) {
featureSelectionWizardPage.flipToRemediationComposite();
nextPage = featureSelectionWizardPage;
}
if (nextPage == null && computeMustCheckLicenseAcceptance()) {
if (acceptLicensesPage == null) {
acceptLicensesPage = new AcceptLicensesWizardPage(ProvisioningUI.getDefaultUI().getLicenseManager(), operationIUs, profileChangeOperation);
addPage(acceptLicensesPage);
} else {
acceptLicensesPage.update(operationIUs, profileChangeOperation);
}
if (nextpressed || acceptLicensesPage.hasLicensesToAccept() || profileChangeOperation instanceof RemediationOperation) {
nextPage = acceptLicensesPage;
}
}
if (nextPage == null && page == catalogPage) {
nextPage = featureSelectionWizardPage;
}
if (operationUpdated && nextPage == container.getCurrentPage()) {
container.updateButtons();
}
return nextPage;
}
if (page instanceof ImportFavoritesPage) {
return catalogPage;
}
return getNextPageInList(page);
}
use of org.eclipse.equinox.p2.operations.RemediationOperation in project epp.mpc by eclipse.
the class ProfileChangeOperationComputer method run.
public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
try {
boolean hasInstall = hasInstall();
boolean hasUninstall = hasUninstall();
SubMonitor monitor = SubMonitor.convert(progressMonitor, Messages.ProvisioningOperation_configuringProvisioningOperation, 1000 + (hasInstall ? 500 : 0) + (hasUninstall ? 100 : 0));
try {
IInstallableUnit[] uninstallIUs = null;
if (hasInstall) {
ius = computeInstallableUnits(monitor.newChild(500));
} else {
ius = new IInstallableUnit[0];
}
if (hasUninstall) {
uninstallIUs = computeUninstallUnits(monitor.newChild(100));
}
checkCancelled(monitor);
URI[] repositories = repositoryLocations == null ? new URI[0] : repositoryLocations.toArray(new URI[0]);
switch(operationType) {
case INSTALL:
operation = resolveInstall(monitor.newChild(500), ius, repositories);
break;
case UPDATE:
operation = resolveUpdate(monitor.newChild(500), computeInstalledIus(ius), repositories);
break;
case UNINSTALL:
operation = resolveUninstall(monitor.newChild(500), uninstallIUs, repositories);
break;
case CHANGE:
operation = resolveChange(monitor.newChild(500), ius, uninstallIUs, repositories);
break;
default:
throw new UnsupportedOperationException(operationType.name());
}
if (withRemediation && operation != null && operation.getResolutionResult().getSeverity() == IStatus.ERROR) {
RemediationOperation remediationOperation = new RemediationOperation(ProvisioningUI.getDefaultUI().getSession(), operation.getProfileChangeRequest());
remediationOperation.resolveModal(monitor.newChild(500));
if (remediationOperation.getResolutionResult() == Status.OK_STATUS) {
errorMessage = operation.getResolutionDetails();
operation = remediationOperation;
}
}
checkCancelled(monitor);
} finally {
monitor.done();
}
} catch (OperationCanceledException e) {
throw new InterruptedException();
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
use of org.eclipse.equinox.p2.operations.RemediationOperation in project epp.mpc by eclipse.
the class FeatureSelectionWizardPage method updateMessage.
void updateMessage() {
ProfileChangeOperation profileChangeOperation = getWizard().getProfileChangeOperation();
if (profileChangeOperation != null) {
if (profileChangeOperation instanceof RemediationOperation && ((RemediationOperation) profileChangeOperation).getResolutionResult() == Status.OK_STATUS) {
if (remediationGroup == null) {
remediationGroup = new RemediationGroup(this);
remediationGroup.createRemediationControl(container);
}
setMessage(remediationGroup.getMessage(), IStatus.WARNING);
remediationGroup.getDetailsGroup().setDetailText(getWizard().getErrorMessage());
remediationGroup.update((RemediationOperation) profileChangeOperation);
flipToRemediationComposite();
} else {
IStatus resolutionResult = profileChangeOperation.getResolutionResult();
if (!resolutionResult.isOK()) {
String message = resolutionResult.getMessage();
if (resolutionResult.getSeverity() == IStatus.ERROR) {
message = Messages.FeatureSelectionWizardPage_provisioningErrorAdvisory;
} else if (resolutionResult.getSeverity() == IStatus.WARNING) {
message = Messages.FeatureSelectionWizardPage_provisioningWarningAdvisory;
}
setMessage(message, Util.computeMessageType(resolutionResult));
// avoid gratuitous scrolling
String originalText = detailStatusText.getText();
String newText;
try {
newText = profileChangeOperation.getResolutionDetails();
} catch (Exception e) {
// sometimes p2 might throw an exception
MarketplaceClientUi.error(e);
newText = Messages.FeatureSelectionWizardPage_detailsUnavailable;
}
if (newText != originalText || (newText != null && !newText.equals(originalText))) {
detailStatusText.setText(newText);
}
((GridData) detailsControl.getLayoutData()).exclude = false;
} else {
setMessage(null, IMessageProvider.NONE);
((GridData) detailsControl.getLayoutData()).exclude = true;
}
}
} else {
setMessage(null, IMessageProvider.NONE);
((GridData) detailsControl.getLayoutData()).exclude = true;
}
((Composite) getControl()).layout(true);
defaultComposite.layout(true);
}
Aggregations