diff options
Diffstat (limited to 'bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/JobInfo.java')
-rw-r--r-- | bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/JobInfo.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/JobInfo.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/JobInfo.java index 61c70a8e69a..4824faf2f01 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/JobInfo.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/JobInfo.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Brock Janiczak <brockj@tpg.com.au> - Fix for Bug 123169 [Progress] NPE from JobInfo + * Martin W. Kirst <martin.kirst@s1998.tu-chemnitz.de> - jUnit test for Bug 361121 [Progress] DetailedProgressViewer's comparator violates its general contract *******************************************************************************/ package org.eclipse.ui.internal.progress; @@ -46,7 +47,7 @@ public class JobInfo extends JobTreeElement { * * @param enclosingJob */ - JobInfo(Job enclosingJob) { + protected JobInfo(Job enclosingJob) { this.job = enclosingJob; } @@ -147,10 +148,12 @@ public class JobInfo extends JobTreeElement { } } + // If equal prio, order by names if (job.getPriority() == job2.getPriority()) { return job.getName().compareTo(job2.getName()); } + // order by priority if (job.getPriority() > job2.getPriority()) { return -1; } @@ -174,15 +177,16 @@ public class JobInfo extends JobTreeElement { return 1; } - if (element.getJob().getState() == getJob().getState()) { - return compareJobs(element); - } + int thisState = getJob().getState(); + int anotherState = element.getJob().getState(); - if (getJob().getState() == Job.RUNNING) { - return -1; + // if equal job state, compare other job attributes + if (thisState == anotherState) { + return compareJobs(element); } - return 1; + // ordering by job states, Job.RUNNING should be ordered first + return (thisState > anotherState ? -1 : (thisState == anotherState ? 0 : 1)); } /** |