diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Explanation.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Explanation.java index 780dd229ec..5a9a7ff1b0 100644 --- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Explanation.java +++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Explanation.java @@ -48,8 +48,8 @@ public int orderValue() { public IStatus toStatus() { MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Explanation_unsatisfied, null); final String fromString = patch.toString() + ' ' + getUserReadableName(iu); - result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Explanation_fromPatch, fromString))); - result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Explanation_to, req))); + result.add(Status.error(NLS.bind(Messages.Explanation_fromPatch, fromString))); + result.add(Status.error(NLS.bind(Messages.Explanation_to, req))); return result; } @@ -82,8 +82,8 @@ public int orderValue() { @Override public IStatus toStatus() { MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, Messages.Explanation_unsatisfied, null); - result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Explanation_from, getUserReadableName(iu)))); - result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Explanation_to, req))); + result.add(Status.error(NLS.bind(Messages.Explanation_from, getUserReadableName(iu)))); + result.add(Status.error(NLS.bind(Messages.Explanation_to, req))); return result; } @@ -118,7 +118,7 @@ public String toString() { @Override public IStatus toStatus() { - return new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Explanation_alreadyInstalled, getUserReadableName(iu))); + return Status.error(NLS.bind(Messages.Explanation_alreadyInstalled, getUserReadableName(iu))); } @Override @@ -146,7 +146,7 @@ public String toString() { @Override public IStatus toStatus() { - return new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Explanation_toInstall, getUserReadableName(iu))); + return Status.error(NLS.bind(Messages.Explanation_toInstall, getUserReadableName(iu))); } @Override @@ -169,7 +169,7 @@ public String toString() { @Override public IStatus toStatus() { - return new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Explanation_missingRootFilter, req)); + return Status.error(NLS.bind(Messages.Explanation_missingRootFilter, req)); } @Override @@ -218,12 +218,13 @@ public String toString() { @Override public IStatus toStatus() { if (isEntryPoint) { - return new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Explanation_missingRootRequired, req)); + return Status.error(NLS.bind(Messages.Explanation_missingRootRequired, req)); } if (req.getFilter() == null) { - return new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Explanation_missingRequired, getUserReadableName(iu), req)); + return Status.error(NLS.bind(Messages.Explanation_missingRequired, getUserReadableName(iu), req)); } - return new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Explanation_missingRequiredFilter, new Object[] {req.getFilter(), getUserReadableName(iu), req})); + return Status.error(NLS.bind(Messages.Explanation_missingRequiredFilter, + new Object[] { req.getFilter(), getUserReadableName(iu), req })); } } @@ -251,7 +252,7 @@ public String toString() { @Override public IStatus toStatus() { - return new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Explanation_missingNonGreedyRequired, getUserReadableName(iu))); + return Status.error(NLS.bind(Messages.Explanation_missingNonGreedyRequired, getUserReadableName(iu))); } } @@ -276,7 +277,7 @@ public int shortAnswer() { public IStatus toStatus() { MultiStatus result = new MultiStatus(DirectorActivator.PI_DIRECTOR, 1, NLS.bind(Messages.Explanation_singleton, ""), null); //$NON-NLS-1$ for (IInstallableUnit iu : ius) - result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, getUserReadableName(iu))); + result.add(Status.error(getUserReadableName(iu))); return result; } @@ -334,7 +335,7 @@ public int compareTo(Explanation exp) { * Returns a representation of this explanation as a status object. */ public IStatus toStatus() { - return new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, toString()); + return Status.error(toString()); } protected static String getUserReadableName(IInstallableUnit iu) { diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java index 670bd5d2ba..4a17ee79cf 100644 --- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java +++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Projector.java @@ -259,9 +259,9 @@ public void encode(IInstallableUnit entryPointIU, IInstallableUnit[] alreadyExis System.out.println(solver.toString()); } } catch (IllegalStateException e) { - result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, e.getMessage(), e)); + result.add(Status.error(e.getMessage(), e)); } catch (ContradictionException e) { - result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, Messages.Planner_Unsatisfiable_problem)); + result.add(Status.error(Messages.Planner_Unsatisfiable_problem)); } } @@ -798,7 +798,7 @@ private void expandLifeCycle(IInstallableUnit iu, boolean isRootIu) throws Contr } private void missingRequirement(IInstallableUnit iu, IRequirement req) throws ContradictionException { - result.add(new Status(IStatus.WARNING, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Planner_Unsatisfied_dependency, iu, req))); + result.add(Status.warning(NLS.bind(Messages.Planner_Unsatisfied_dependency, iu, req))); createNegation(iu, req); } @@ -986,9 +986,9 @@ public IStatus invokeSolver(IProgressMonitor monitor) { result.merge(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, SimplePlanner.UNSATISFIABLE, Messages.Planner_Unsatisfiable_problem, null)); } } catch (TimeoutException e) { - result.merge(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, Messages.Planner_Timeout)); + result.merge(Status.error(Messages.Planner_Timeout)); } catch (Exception e) { - result.merge(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, Messages.Planner_Unexpected_problem, e)); + result.merge(Status.error(Messages.Planner_Unexpected_problem, e)); } if (DEBUG) System.out.println(); diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java index ece0a6cd36..f06d4ea241 100644 --- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java +++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/SimplePlanner.java @@ -163,13 +163,13 @@ private static IStatus convertExplanationToStatus(Set explanations) && "A.PDE.Target.Platform".equals(((IRequiredCapability) missingIU.req).getNamespace())) {//$NON-NLS-1$ // This IU requires the PDE target platform IU and it is missing. // I.e. this IU is intended only for the PDE target platform. - forTargets.add(new Status(ERROR, PI_DIRECTOR, Explanation.getUserReadableName(missingIU.iu))); + forTargets.add(Status.error(Explanation.getUserReadableName(missingIU.iu))); } } } if (!forTargets.isEmpty()) { // The following line could be removed if Bug 309863 is fixed - forTargets.add(new Status(ERROR, PI_DIRECTOR, Messages.Director_For_Target_Unselect_Required)); + forTargets.add(Status.error(Messages.Director_For_Target_Unselect_Required)); // Return a multi status with all the IUs that require A.PDE.Target.Platform return new MultiStatus(PI_DIRECTOR, 1, forTargets.toArray(IStatus[]::new), Messages.Director_For_Target, null); @@ -614,7 +614,7 @@ private IProvisioningPlan createInstallerPlan(IProfile profile, ProfileChangeReq sub.setTaskName(Messages.Director_Task_installer_plan); if (profileRegistry == null) { IProvisioningPlan plan = engine.createPlan(initialRequest.getProfile(), initialContext); - plan.setStatus(new Status(ERROR, PI_DIRECTOR, Messages.Planner_no_profile_registry)); + plan.setStatus(Status.error(Messages.Planner_no_profile_registry)); return plan; } @@ -635,8 +635,8 @@ private IProvisioningPlan createInstallerPlan(IProfile profile, ProfileChangeReq if (profile.getProfileId().equals(installerProfile.getProfileId())) { if (profile.getTimestamp() != installerProfile.getTimestamp()) { IProvisioningPlan plan = engine.createPlan(initialRequest.getProfile(), initialContext); - plan.setStatus(new Status(ERROR, PI_DIRECTOR, - NLS.bind(Messages.Planner_profile_out_of_sync, profile.getProfileId()))); + plan.setStatus( + Status.error(NLS.bind(Messages.Planner_profile_out_of_sync, profile.getProfileId()))); return plan; } return createInstallerPlanForCohostedCase(profile, initialRequest, initialPlan, unattachedState, @@ -792,7 +792,7 @@ private IProvisioningPlan createInstallerPlanForCohostedCase(IProfile profile, P new ProfileChangeRequest(new EverythingOptionalProfile(initialRequest.getProfile())), noRepoContext, new NullProgressMonitor()); if (initialSolution instanceof IProvisioningPlan) { - LogHelper.log(new Status(ERROR, PI_DIRECTOR, "The resolution of the previous state contained in profile " //$NON-NLS-1$ + LogHelper.log(Status.error("The resolution of the previous state contained in profile " //$NON-NLS-1$ + initialRequest.getProfile().getProfileId() + " version " //$NON-NLS-1$ + initialRequest.getProfile().getTimestamp() + " failed.")); //$NON-NLS-1$ return (IProvisioningPlan) initialSolution; @@ -825,7 +825,7 @@ private IProvisioningPlan generatePlan(Projector newSolution, Collection slice(IInstallableUnit[] ius, IProgressMonit System.out.println("Slicing complete: " + (stop - start)); //$NON-NLS-1$ } } catch (IllegalStateException e) { - result.add(new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, e.getMessage(), e)); + result.add(Status.error(e.getMessage(), e)); } if (Tracing.DEBUG && result.getSeverity() != IStatus.OK) LogHelper.log(result); @@ -211,7 +211,7 @@ private void expandRequirement(IInstallableUnit iu, IRequirement req) { if (DEBUG) System.out.println("No IU found to satisfy optional dependency of " + iu + " on req " + req); //$NON-NLS-1$//$NON-NLS-2$ } else { - result.add(new Status(IStatus.WARNING, DirectorActivator.PI_DIRECTOR, NLS.bind(Messages.Planner_Unsatisfied_dependency, iu, req))); + result.add(Status.warning(NLS.bind(Messages.Planner_Unsatisfied_dependency, iu, req))); } } } diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanExecutionHelper.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanExecutionHelper.java index 83ac500b7c..af559d80d3 100644 --- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanExecutionHelper.java +++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/provisional/p2/director/PlanExecutionHelper.java @@ -42,7 +42,7 @@ public static IStatus executePlan(IProvisioningPlan result, IEngine engine, IPha try { configChanger.applyConfiguration(); } catch (IOException e) { - return new Status(IStatus.ERROR, DirectorActivator.PI_DIRECTOR, Messages.Director_error_applying_configuration, e); + return Status.error(Messages.Director_error_applying_configuration, e); } } return engine.perform(result, phaseSet, progress);