Search in sources :

Example 1 with RemediationOperation

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);
}
Also used : IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) AcceptLicensesWizardPage(org.eclipse.equinox.p2.ui.AcceptLicensesWizardPage) RemediationOperation(org.eclipse.equinox.p2.operations.RemediationOperation) UninstallOperation(org.eclipse.equinox.p2.operations.UninstallOperation) IWizardPage(org.eclipse.jface.wizard.IWizardPage) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 2 with RemediationOperation

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);
    }
}
Also used : RemediationOperation(org.eclipse.equinox.p2.operations.RemediationOperation) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) SubMonitor(org.eclipse.core.runtime.SubMonitor) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 3 with RemediationOperation

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);
}
Also used : ProfileChangeOperation(org.eclipse.equinox.p2.operations.ProfileChangeOperation) IStatus(org.eclipse.core.runtime.IStatus) Composite(org.eclipse.swt.widgets.Composite) RemediationOperation(org.eclipse.equinox.p2.operations.RemediationOperation) StyledString(org.eclipse.jface.viewers.StyledString) RemediationGroup(org.eclipse.equinox.internal.p2.ui.dialogs.RemediationGroup) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)3 RemediationOperation (org.eclipse.equinox.p2.operations.RemediationOperation)3 CoreException (org.eclipse.core.runtime.CoreException)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 RemediationGroup (org.eclipse.equinox.internal.p2.ui.dialogs.RemediationGroup)1 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)1 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)1 ProfileChangeOperation (org.eclipse.equinox.p2.operations.ProfileChangeOperation)1 UninstallOperation (org.eclipse.equinox.p2.operations.UninstallOperation)1 AcceptLicensesWizardPage (org.eclipse.equinox.p2.ui.AcceptLicensesWizardPage)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 StyledString (org.eclipse.jface.viewers.StyledString)1 IWizardContainer (org.eclipse.jface.wizard.IWizardContainer)1 IWizardPage (org.eclipse.jface.wizard.IWizardPage)1 Composite (org.eclipse.swt.widgets.Composite)1