diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java index 823bfc6479..6ad2d3f63f 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/RawMirrorRequest.java @@ -46,11 +46,11 @@ public RawMirrorRequest(IArtifactDescriptor sourceDescriptor, IArtifactDescripto @Override public void perform(IArtifactRepository sourceRepository, IProgressMonitor monitor) { - monitor.subTask(NLS.bind(Messages.downloading, getArtifactKey().getId())); + SubMonitor subMon = SubMonitor.convert(monitor, NLS.bind(Messages.downloading, getArtifactKey().getId()), 1); setSourceRepository(sourceRepository); // Do we already have the descriptor in the target? if (target.contains(targetDescriptor)) { - setResult(new Status(IStatus.INFO, Activator.ID, NLS.bind(Messages.mirror_alreadyExists, targetDescriptor, target))); + setResult(Status.info(NLS.bind(Messages.mirror_alreadyExists, targetDescriptor, target))); return; } // Does the source actually have the descriptor? @@ -58,7 +58,7 @@ public void perform(IArtifactRepository sourceRepository, IProgressMonitor monit setResult(new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.artifact_not_found, getArtifactKey()))); return; } - IStatus status = transfer(targetDescriptor, sourceDescriptor, monitor); + IStatus status = transfer(targetDescriptor, sourceDescriptor, subMon.newChild(1)); // if ok, cancelled or transfer has already been done with the canonical form return with status set if (status.getSeverity() == IStatus.CANCEL) { @@ -88,6 +88,7 @@ public IArtifactDescriptor getArtifactDescriptor() { // Perform the mirror operation without any processing steps @Override protected IStatus getArtifact(IArtifactDescriptor artifactDescriptor, OutputStream destination, IProgressMonitor monitor) { + SubMonitor subMon = SubMonitor.convert(monitor, 2); if (SimpleArtifactRepository.CHECKSUMS_ENABLED) { Collection steps = ChecksumUtilities.getChecksumVerifiers(artifactDescriptor, IArtifactDescriptor.DOWNLOAD_CHECKSUM, Collections.emptySet()); @@ -98,9 +99,9 @@ protected IStatus getArtifact(IArtifactDescriptor artifactDescriptor, OutputStre ProcessingStep[] stepArray = steps.toArray(new ProcessingStep[steps.size()]); // TODO should probably be using createAndLink here ProcessingStepHandler handler = new ProcessingStepHandler(); - destination = handler.link(stepArray, destination, monitor); + destination = handler.link(stepArray, destination, subMon.split(1)); } - - return getSourceRepository().getRawArtifact(artifactDescriptor, destination, monitor); + subMon.setWorkRemaining(1); + return getSourceRepository().getRawArtifact(artifactDescriptor, destination, subMon.split(1)); } } diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java index 56f1c786f6..0c9037cb6d 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java @@ -617,7 +617,7 @@ private boolean doRemoveArtifact(IArtifactDescriptor descriptor) { } protected IStatus downloadArtifact(IArtifactDescriptor descriptor, OutputStream destination, IProgressMonitor monitor) { - monitor = IProgressMonitor.nullSafe(monitor); + SubMonitor subMon = SubMonitor.convert(monitor, 2); if (isFolderBased(descriptor)) { File artifactFolder = getArtifactFile(descriptor); if (artifactFolder == null) { @@ -655,8 +655,8 @@ protected IStatus downloadArtifact(IArtifactDescriptor descriptor, OutputStream URI baseLocation = getLocation(descriptor); if (baseLocation == null) return new Status(IStatus.ERROR, Activator.ID, NLS.bind(Messages.no_location, descriptor)); - URI mirrorLocation = getMirror(baseLocation, monitor); - IStatus status = downloadArtifact(mirrorLocation, destination, monitor); + URI mirrorLocation = getMirror(baseLocation, subMon.split(1)); + IStatus status = downloadArtifact(mirrorLocation, destination, subMon.split(1)); IStatus result = reportStatus(descriptor, destination, status); // if the original download went reasonably but the reportStatus found some issues // (e..g, in the processing steps/validators) then mark the mirror as bad and return diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java index 481705f531..3669861af9 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/Engine.java @@ -71,6 +71,7 @@ public IStatus perform(IProfile iprofile, IPhaseSet phases, Operand[] operands, Profile profile = profileRegistry.validate(iprofile); profileRegistry.lockProfile(profile); + SubMonitor subMon = SubMonitor.convert(monitor, 3); try { eventBus.publishEvent(new BeginOperationEvent(profile, phaseSet, operands, this)); if (DebugHelper.DEBUG_ENGINE) @@ -91,17 +92,17 @@ public IStatus perform(IProfile iprofile, IPhaseSet phases, Operand[] operands, } context.setProperty(ProvisioningContext.CHECK_AUTHORITIES, property); } - - MultiStatus result = phaseSet.perform(session, operands, monitor); + MultiStatus result = phaseSet.perform(session, operands, subMon.split(1)); if (result.isOK() || result.matches(IStatus.INFO | IStatus.WARNING)) { if (DebugHelper.DEBUG_ENGINE) DebugHelper.debug(ENGINE, "Preparing to commit engine operation for profile=" + profile.getProfileId()); //$NON-NLS-1$ - result.merge(session.prepare(monitor)); + result.merge(session.prepare(subMon.split(1))); } + subMon.setWorkRemaining(1); if (result.matches(IStatus.ERROR | IStatus.CANCEL)) { if (DebugHelper.DEBUG_ENGINE) DebugHelper.debug(ENGINE, "Rolling back engine operation for profile=" + profile.getProfileId() + ". Reason was: " + result.toString()); //$NON-NLS-1$ //$NON-NLS-2$ - IStatus status = session.rollback(monitor, result.getSeverity()); + IStatus status = session.rollback(subMon.split(1), result.getSeverity()); if (status.matches(IStatus.ERROR)) LogHelper.log(status); eventBus.publishEvent(new RollbackOperationEvent(profile, phaseSet, operands, this, result)); @@ -110,7 +111,7 @@ public IStatus perform(IProfile iprofile, IPhaseSet phases, Operand[] operands, DebugHelper.debug(ENGINE, "Committing engine operation for profile=" + profile.getProfileId()); //$NON-NLS-1$ if (profile.isChanged()) profileRegistry.updateProfile(profile); - IStatus status = session.commit(monitor); + IStatus status = session.commit(subMon.split(1)); if (status.matches(IStatus.ERROR)) LogHelper.log(status); eventBus.publishEvent(new CommitOperationEvent(profile, phaseSet, operands, this)); @@ -121,6 +122,7 @@ public IStatus perform(IProfile iprofile, IPhaseSet phases, Operand[] operands, } finally { profileRegistry.unlockProfile(profile); profile.setChanged(false); + monitor.done(); } } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java index 48e9a7658e..05f4779c2c 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileChangeOperation.java @@ -28,7 +28,7 @@ * resolution status to be reported to a client to determine whether the operation * should proceed. Each phase of the operation can be performed synchronously or in * the background as a job. To perform the operation synchronously: - * + * *
  *     IStatus result = op.resolveModal(monitor);
  *     if (result.isOK())
@@ -37,10 +37,10 @@
  *       // interpret the result
  *     }
  *  
- * + * * To perform the resolution synchronously and the provisioning job in the * background: - * + * *
  *     IStatus status = op.resolveModal(monitor);
  *     if (status.isOK()) {
@@ -50,9 +50,9 @@
  *       // interpret the result
  *     }
  *  
- * + * * To resolve in the background and perform the job when it is complete: - * + * *
  *     ProvisioningJob job = op.getResolveJob(monitor);
  *     job.addJobChangeListener(new JobChangeAdapter() {
@@ -65,18 +65,18 @@
  *       }
  *     });
  *     job.schedule();
- *     
+ *
  *  
- * - * In general, it is expected that clients create a new ProfileChangeOperation if + * + * In general, it is expected that clients create a new ProfileChangeOperation if * the resolution result of the current operation is not satisfactory. However, * subclasses may prescribe a different life cycle where appropriate. - * - * When retrieving the resolution and provisioning jobs managed by this operation, + * + * When retrieving the resolution and provisioning jobs managed by this operation, * a client may supply a progress monitor to be used by the job. When the job is - * run by the platform job manager, both the platform job manager progress indicator + * run by the platform job manager, both the platform job manager progress indicator * and the monitor supplied by the client will be updated. - * + * * @noextend This class is not intended to be subclassed by clients. * @since 2.0 */ @@ -93,7 +93,7 @@ public abstract class ProfileChangeOperation implements IProfileChangeJob { * Create an operation using the provided provisioning session. * Unless otherwise specified by the client, the operation is * performed on the currently running profile. - * + * * @param session the provisioning session providing the services */ protected ProfileChangeOperation(ProvisioningSession session) { @@ -105,20 +105,20 @@ protected ProfileChangeOperation(ProvisioningSession session) { /** * Resolve the operation in the current thread using the specified progress * monitor. Return a status describing the result of the resolution. - * + * * @param monitor the progress monitor to use * @return a status describing the resolution results */ public final IStatus resolveModal(IProgressMonitor monitor) { - if (monitor == null) - monitor = new NullProgressMonitor(); + SubMonitor subMon = SubMonitor.convert(monitor, 2); prepareToResolve(); - makeResolveJob(monitor); + makeResolveJob(subMon.split(1)); if (job != null) { - IStatus status = job.runModal(monitor); + IStatus status = job.runModal(subMon.split(1)); if (status.getSeverity() == IStatus.CANCEL) return Status.CANCEL_STATUS; } + monitor.done(); // For anything other than cancellation, we examine the artifacts of the resolution and come // up with an overall summary. return getResolutionResult(); @@ -135,11 +135,11 @@ public void setProfileId(String id) { /** * Return a job that can be used to resolve this operation in the background. - * + * * @param monitor a progress monitor that should be used to report the job's progress in addition - * to the standard job progress reporting. Can be null. If provided, this monitor + * to the standard job progress reporting. Can be null. If provided, this monitor * will be called from a background thread. - * + * * @return a job that can be scheduled to perform the provisioning operation. */ public final ProvisioningJob getResolveJob(IProgressMonitor monitor) { @@ -178,11 +178,11 @@ void makeResolveJob(IProgressMonitor monitor) { /** * Compute the profile change request for this operation, adding any relevant intermediate status - * to the supplied status. - * + * to the supplied status. + * * @param status a multi-status to be used to add relevant status. If a profile change request cannot * be computed for any reason, a status should be added to explain the problem. - * + * * @param monitor the progress monitor to use for computing the profile change request */ protected abstract void computeProfileChangeRequest(MultiStatus status, IProgressMonitor monitor); @@ -193,14 +193,14 @@ private void createPlannerResolutionJob() { /** * Return an appropriate name for the resolution job. - * + * * @return the resolution job name. */ protected abstract String getResolveJobName(); /** * Return an appropriate name for the provisioning job. - * + * * @return the provisioning job name. */ protected abstract String getProvisioningJobName(); @@ -209,7 +209,7 @@ private void createPlannerResolutionJob() { * Return a status indicating the result of resolving this * operation. A null return indicates that * resolving has not occurred yet. - * + * * @return the status of the resolution, or null * if resolution has not yet occurred. */ @@ -231,7 +231,7 @@ public IStatus getResolutionResult() { /** * Return a string that can be used to describe the results of the resolution * to a client. - * + * * @return a string describing the resolution details, or null if the * operation has not been resolved. */ @@ -250,9 +250,9 @@ public String getResolutionDetails() { /** * Return a string that describes the specific resolution results * related to the supplied {@link IInstallableUnit}. - * + * * @param iu the IInstallableUnit for which resolution details are requested - * + * * @return a string describing the results for the installable unit, or null if * there are no specific results available for the installable unit. */ @@ -265,12 +265,12 @@ public String getResolutionDetails(IInstallableUnit iu) { /** * Return the provisioning plan obtained by resolving the receiver. - * + * * @return the provisioning plan. This may be null if the operation * has not been resolved, or if a plan could not be obtained when attempting to * resolve. If the plan is null and the operation has been resolved, then the * resolution result will explain the problem. - * + * * @see #hasResolved() * @see #getResolutionResult() */ @@ -282,12 +282,12 @@ public IProvisioningPlan getProvisioningPlan() { /** * Return the profile change request that describes the receiver. - * + * * @return the profile change request. This may be null if the operation * has not been resolved, or if a profile change request could not be assembled given * the operation's state. If the profile change request is null and the operation has * been resolved, the the resolution result will explain the problem. - * + * * @see #hasResolved() * @see #getResolutionResult() * @since 2.1 @@ -299,22 +299,22 @@ public IProfileChangeRequest getProfileChangeRequest() { } /** - * Return a provisioning job that can be used to perform the resolved operation. The job is + * Return a provisioning job that can be used to perform the resolved operation. The job is * created using the default values associated with a new job. It is up to clients to configure * the priority of the job and set any appropriate properties, such as - * {@link Job#setUser(boolean)}, + * {@link Job#setUser(boolean)}, * {@link Job#setSystem(boolean)}, or {@link Job#setProperty(QualifiedName, Object)}, * before scheduling it. - * + * * @param monitor a progress monitor that should be used to report the job's progress in addition - * to the standard job progress reporting. Can be null. If provided, this monitor + * to the standard job progress reporting. Can be null. If provided, this monitor * will be called from a background thread. - * - * @return a job that can be used to perform the provisioning operation. This may be null + * + * @return a job that can be used to perform the provisioning operation. This may be null * if the operation has not been resolved, or if a plan could not be obtained when attempting to - * resolve. If the job is null and the operation has been resolved, then the resolution result + * resolve. If the job is null and the operation has been resolved, then the resolution result * will explain the problem. - * + * * @see #hasResolved() * @see #getResolutionResult() */ @@ -337,7 +337,7 @@ public ProvisioningJob getProvisioningJob(IProgressMonitor monitor) { * Set the provisioning context that should be used to resolve and perform the provisioning for * the operation. This must be set before an attempt is made to resolve the operation * for it to have any effect. - * + * * @param context the provisioning context. */ public void setProvisioningContext(ProvisioningContext context) { @@ -349,7 +349,7 @@ public void setProvisioningContext(ProvisioningContext context) { /** * Get the provisioning context that will be used to resolve and perform the provisioning for * the operation. - * + * * @return the provisioning context */ public ProvisioningContext getProvisioningContext() { @@ -367,7 +367,7 @@ public String getProfileId() { * change request, provisioning plan, or resolution result. It is possible that this * method return false while resolution is taking place if it is performed * in the background. - * + * * @return true if the operation has been resolved, false * if it has not resolved. */ diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileModificationJob.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileModificationJob.java index 27e73c8405..7ad3638a23 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileModificationJob.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProfileModificationJob.java @@ -71,9 +71,9 @@ public IStatus runModal(IProgressMonitor monitor) { IStatus status = Status.OK_STATUS; if (task == null) task = getName(); - monitor.beginTask(task, 1000); try { - status = getSession().performProvisioningPlan(plan, phaseSet, provisioningContext, SubMonitor.convert(monitor, 1000)); + SubMonitor subMonitor = SubMonitor.convert(monitor, task, 1000); + status = getSession().performProvisioningPlan(plan, phaseSet, provisioningContext, subMonitor); } finally { monitor.done(); } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java index b597b82c6c..8abaa2bd06 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/ProvisioningSession.java @@ -21,7 +21,6 @@ import org.eclipse.core.runtime.*; import org.eclipse.core.runtime.jobs.*; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; -import org.eclipse.equinox.internal.p2.operations.Constants; import org.eclipse.equinox.internal.p2.operations.Messages; import org.eclipse.equinox.internal.provisional.configurator.Configurator; import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus; @@ -128,11 +127,7 @@ IPlanner getPlanner() { * @return a status describing the result of performing the plan */ public IStatus performProvisioningPlan(IProvisioningPlan plan, IPhaseSet phaseSet, ProvisioningContext context, IProgressMonitor monitor) { - IPhaseSet set; - if (phaseSet == null) - set = PhaseSetFactory.createDefaultPhaseSet(); - else - set = phaseSet; + IPhaseSet set = phaseSet == null ? PhaseSetFactory.createDefaultPhaseSet() : phaseSet; // 300 ticks for download, 100 to install handlers, 100 to compute the plan, 100 to install the rest SubMonitor mon = SubMonitor.convert(monitor, 600); @@ -174,10 +169,12 @@ public IStatus performProvisioningPlan(IProvisioningPlan plan, IPhaseSet phaseSe configChanger.applyConfiguration(); } catch (IOException e) { mon.done(); - return new Status(IStatus.ERROR, Constants.BUNDLE_ID, Messages.ProvisioningSession_InstallPlanConfigurationError, e); + return Status.error(Messages.ProvisioningSession_InstallPlanConfigurationError, e); } } - return getEngine().perform(plan, set, mon.newChild(500 - ticksUsed)); + IStatus status = getEngine().perform(plan, set, mon.newChild(500 - ticksUsed)); + mon.done(); + return status; } private boolean doesPhaseSetIncludeDownload(IPhaseSet set) { diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java index e68ea79d80..2d37de31b8 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/AbstractProvisioningUITest.java @@ -18,6 +18,7 @@ import java.util.Dictionary; import java.util.Hashtable; import org.eclipse.core.runtime.*; +import org.eclipse.core.tests.harness.FussyProgressMonitor; import org.eclipse.equinox.internal.p2.director.ProfileChangeRequest; import org.eclipse.equinox.internal.p2.ui.model.ProfileElement; import org.eclipse.equinox.internal.p2.ui.sdk.SimpleLicenseManager; @@ -146,12 +147,19 @@ protected IStatus install(IInstallableUnit iu, boolean root, boolean lock) { // Use an empty provisioning context to prevent repo access ProvisioningContext context = new ProvisioningContext(getAgent()); context.setMetadataRepositories(new URI[] {}); + FussyProgressMonitor monitor = new FussyProgressMonitor(); IProvisioningPlan plan = getPlanner(getSession().getProvisioningAgent()).getProvisioningPlan(req, context, - getMonitor()); + monitor); + monitor.assertUsedUp(); if (plan.getStatus().getSeverity() == IStatus.ERROR || plan.getStatus().getSeverity() == IStatus.CANCEL) return plan.getStatus(); - return getSession().performProvisioningPlan(plan, PhaseSetFactory.createDefaultPhaseSet(), - new ProvisioningContext(getAgent()), getMonitor()); + FussyProgressMonitor monitor2 = new FussyProgressMonitor(); + try { + return getSession().performProvisioningPlan(plan, PhaseSetFactory.createDefaultPhaseSet(), + new ProvisioningContext(getAgent()), monitor2); + } finally { + monitor2.assertUsedUp(); + } } protected IInstallableUnit createNamedIU(String id, String name, Version version, boolean isCategory) { diff --git a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java index 2b81f21f8d..1038b924fa 100644 --- a/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java +++ b/bundles/org.eclipse.equinox.p2.tests.ui/src/org/eclipse/equinox/p2/tests/ui/dialogs/UpdateWizardTest.java @@ -14,6 +14,7 @@ package org.eclipse.equinox.p2.tests.ui.dialogs; import java.util.ArrayList; +import org.eclipse.core.tests.harness.FussyProgressMonitor; import org.eclipse.equinox.internal.p2.metadata.License; import org.eclipse.equinox.internal.p2.ui.ProvUI; import org.eclipse.equinox.internal.p2.ui.dialogs.*; @@ -183,7 +184,9 @@ public void testBug277554MultipleVersions() { ArrayList iusInvolved = new ArrayList<>(); iusInvolved.add(main); UpdateOperation op = getProvisioningUI().getUpdateOperation(iusInvolved, null); - op.resolveModal(getMonitor()); + FussyProgressMonitor monitor = new FussyProgressMonitor(); + op.resolveModal(monitor); + monitor.assertUsedUp(); UpdateWizard wizard = new UpdateWizard(getProvisioningUI(), op, op.getSelectedUpdates(), null); ProvisioningWizardDialog dialog = new ProvisioningWizardDialog(ProvUI.getDefaultParentShell(), wizard); dialog.setBlockOnOpen(false); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java index 6ba8d457b5..50d1a0947f 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/AbstractProvisioningTest.java @@ -55,9 +55,9 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.URIUtil; +import org.eclipse.core.tests.harness.FussyProgressMonitor; import org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository; import org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper; import org.eclipse.equinox.internal.p2.core.helpers.URLUtil; @@ -842,7 +842,7 @@ public IProfile createProfile(String name, Map properties) { } protected IProgressMonitor getMonitor() { - return new NullProgressMonitor(); + return new FussyProgressMonitor(); } protected IProfile getProfile(String profileId) { diff --git a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportWizard.java b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportWizard.java index 1eb6d36d01..cdde18cb4b 100644 --- a/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportWizard.java +++ b/bundles/org.eclipse.equinox.p2.ui.importexport/src/org/eclipse/equinox/internal/p2/importexport/internal/wizard/ImportWizard.java @@ -96,8 +96,8 @@ public void recomputePlan(IRunnableContext runnableContext, final boolean withRe if (((ImportPage) mainPage).hasUnloadedRepo()) { try { runnableContext.run(true, true, monitor -> { - final SubMonitor sub = SubMonitor.convert(monitor, 1000); - ((ImportPage) mainPage).recompute(sub.newChild(800)); + final SubMonitor sub = SubMonitor.convert(monitor, withRemediation ? 15 : 10); + ((ImportPage) mainPage).recompute(sub.newChild(8)); if (sub.isCanceled()) throw new InterruptedException(); Display.getDefault().syncExec(() -> { @@ -127,12 +127,12 @@ public IStatus getResolutionResult() { }); if (sub.isCanceled()) throw new InterruptedException(); - if (operation.resolveModal(sub.newChild(200)).getSeverity() == IStatus.CANCEL) + if (operation.resolveModal(sub.newChild(2)).getSeverity() == IStatus.CANCEL) throw new InterruptedException(); if (withRemediation) { IStatus status = operation.getResolutionResult(); if (remediationPage != null && shouldRemediate(status)) { - computeRemediationOperation(operation, ui, monitor); + computeRemediationOperation(operation, ui, sub.newChild(5)); } } Display.getDefault().asyncExec(this::planChanged); diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java index 47901c6528..4ea759c118 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/dialogs/ProvisioningOperationWizard.java @@ -27,7 +27,8 @@ import org.eclipse.equinox.p2.engine.IProvisioningPlan; import org.eclipse.equinox.p2.engine.ProvisioningContext; import org.eclipse.equinox.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.p2.operations.*; +import org.eclipse.equinox.p2.operations.ProfileChangeOperation; +import org.eclipse.equinox.p2.operations.RemediationOperation; import org.eclipse.equinox.p2.ui.*; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.wizard.*; @@ -311,12 +312,10 @@ public void recomputePlan(IRunnableContext runnableContext) { } public void computeRemediationOperation(ProfileChangeOperation op, ProvisioningUI ui, IProgressMonitor monitor) { - SubMonitor sub = SubMonitor.convert(monitor, ProvUIMessages.ProvisioningOperationWizard_Remediation_Operation, - RemedyConfig.getAllRemedyConfigs().length); monitor.setTaskName(ProvUIMessages.ProvisioningOperationWizard_Remediation_Operation); remediationOperation = new RemediationOperation(ui.getSession(), op.getProfileChangeRequest()); remediationOperation.resolveModal(monitor); - sub.done(); + monitor.done(); } /** diff --git a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/P2Util.java b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/P2Util.java index 8c7943ba9a..48f4a3d869 100644 --- a/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/P2Util.java +++ b/examples/org.eclipse.equinox.p2.examples.rcp.prestartupdate/src/org/eclipse/equinox/p2/examples/rcp/prestartupdate/P2Util.java @@ -47,9 +47,8 @@ static IStatus checkForUpdates(IProvisioningAgent agent, IProgressMonitor monito // 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)); + SubMonitor sub = SubMonitor.convert(monitor, "Checking for application updates...", 2); + IStatus status = operation.resolveModal(sub.split(1)); if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) { return status; } @@ -61,9 +60,8 @@ static IStatus checkForUpdates(IProvisioningAgent agent, IProgressMonitor monito // 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(); + status = job.runModal(sub.split(1)); + sub.checkCanceled(); } return status; }