### Eclipse Workspace Patch 1.0 #P org.eclipse.ui.tests Index: Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressContantsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressContantsTest.java,v retrieving revision 1.6 diff -u -r1.6 ProgressContantsTest.java --- Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressContantsTest.java 1 Jun 2010 19:22:26 -0000 1.6 +++ Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressContantsTest.java 29 Jun 2010 14:16:27 -0000 @@ -13,16 +13,20 @@ import org.eclipse.core.commands.Command; import org.eclipse.core.commands.ParameterizedCommand; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.handlers.IHandlerService; +import org.eclipse.ui.internal.progress.FinishedJobs; import org.eclipse.ui.internal.progress.JobInfo; import org.eclipse.ui.internal.progress.ProgressInfoItem; import org.eclipse.ui.progress.IProgressConstants; import org.eclipse.ui.progress.IProgressConstants2; +import org.eclipse.ui.tests.TestPlugin; /** * @since 3.6 @@ -117,4 +121,38 @@ // assertTrue(okJobFound); // assertTrue(warningJobFound); // } + + // see bug 279748 + public void testKeepPropertyWhenStatusNotOk() throws PartInitException, InterruptedException{ + openProgressView(); + + DummyJob warningJob = new DummyJob("Warning Job", new Status(IStatus.WARNING, TestPlugin.PLUGIN_ID, "Warning message")); + warningJob.setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE); + warningJob.schedule(); + + processEvents(); + + warningJob.join(); + + processEvents(); + + //this is called on clicking the ProgressAnimationItem + FinishedJobs.getInstance().removeErrorJobs(); + + processEvents(); + + boolean warningJobFound = false; + ProgressInfoItem[] progressInfoItems = progressView.getViewer().getProgressInfoItems(); + for (int i = 0; i < progressInfoItems.length; i++) { + JobInfo[] jobInfos = progressInfoItems[i].getJobInfos(); + for (int j = 0; j < jobInfos.length; j++) { + Job job = jobInfos[j].getJob(); + if (job.equals(warningJob)) { + warningJobFound = true; + } + } + } + assertTrue("The job with the keep flag must not be removed when ProgressAnimationItem is clicked", warningJobFound); + } + } #P org.eclipse.ui.workbench Index: Eclipse UI/org/eclipse/ui/internal/progress/FinishedJobs.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/FinishedJobs.java,v retrieving revision 1.36 diff -u -r1.36 FinishedJobs.java --- Eclipse UI/org/eclipse/ui/internal/progress/FinishedJobs.java 24 Mar 2008 19:21:58 -0000 1.36 +++ Eclipse UI/org/eclipse/ui/internal/progress/FinishedJobs.java 29 Jun 2010 14:16:28 -0000 @@ -109,22 +109,31 @@ static boolean keep(JobInfo info) { Job job = info.getJob(); if (job != null) { - Object prop = job.getProperty(ProgressManagerUtil.KEEP_PROPERTY); - if (prop instanceof Boolean) { - if (((Boolean) prop).booleanValue()) { - return true; - } + if (hasKeepFlag(job)) + return true; + + IStatus status = job.getResult(); + if (status != null && status.getSeverity() == IStatus.ERROR) { + return true; } + } + return false; + } - prop = job.getProperty(ProgressManagerUtil.KEEPONE_PROPERTY); - if (prop instanceof Boolean) { - if (((Boolean) prop).booleanValue()) { - return true; - } + /** + * Returns true if job has one of keep flags set. + */ + static boolean hasKeepFlag(Job job) { + Object prop = job.getProperty(ProgressManagerUtil.KEEP_PROPERTY); + if (prop instanceof Boolean) { + if (((Boolean) prop).booleanValue()) { + return true; } + } - IStatus status = job.getResult(); - if (status != null && status.getSeverity() == IStatus.ERROR) { + prop = job.getProperty(ProgressManagerUtil.KEEPONE_PROPERTY); + if (prop instanceof Boolean) { + if (((Boolean) prop).booleanValue()) { return true; } } @@ -288,6 +297,22 @@ JobInfo info1 = (JobInfo) infos[i]; Job job = info1.getJob(); if (job != null) { + + // do not remove error jobs that have keep flag set + if (hasKeepFlag(job)){ + // but mark the job as reported to prevent displaying + // the same job error many times + info1.setReported(true); + // notify listeners to force refresh + Object l[] = getListeners(); + for (int j = 0; j < l.length; j++) { + KeptJobsListener jv = (KeptJobsListener) l[j]; + jv.removed(null); + } + //proceed with next entry + continue; + } + IStatus status = job.getResult(); if (status != null && status.getSeverity() == IStatus.ERROR) { JobTreeElement topElement = (JobTreeElement) info1 Index: Eclipse UI/org/eclipse/ui/internal/progress/JobInfo.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/JobInfo.java,v retrieving revision 1.49 diff -u -r1.49 JobInfo.java --- Eclipse UI/org/eclipse/ui/internal/progress/JobInfo.java 1 Jun 2010 19:22:35 -0000 1.49 +++ Eclipse UI/org/eclipse/ui/internal/progress/JobInfo.java 29 Jun 2010 14:16:28 -0000 @@ -30,6 +30,13 @@ private IStatus blockedStatus; private volatile boolean canceled = false; + + /** + * This flag controls when the job result was passed to status handling in + * order to display it. + */ + private volatile boolean reported = false; + private List children = Collections.synchronizedList(new ArrayList()); private Job job; @@ -382,6 +389,14 @@ return getJob().getState() != Job.NONE; } + boolean isReported() { + return reported; + } + + void setReported(boolean errorReported) { + this.reported = errorReported; + } + /** * Return whether or not the receiver is blocked. * Index: Eclipse UI/org/eclipse/ui/internal/progress/ProgressAnimationItem.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressAnimationItem.java,v retrieving revision 1.58 diff -u -r1.58 ProgressAnimationItem.java --- Eclipse UI/org/eclipse/ui/internal/progress/ProgressAnimationItem.java 1 Jun 2010 19:22:35 -0000 1.58 +++ Eclipse UI/org/eclipse/ui/internal/progress/ProgressAnimationItem.java 29 Jun 2010 14:16:28 -0000 @@ -103,6 +103,10 @@ for (int i = jobTreeElements.length - 1; i >= 0; i--) { if (jobTreeElements[i] instanceof JobInfo) { JobInfo ji = (JobInfo) jobTreeElements[i]; + if (ji.isReported()) { + // the error was already reported, so do nothing. + continue; + } Job job = ji.getJob(); if (job != null) { @@ -117,7 +121,11 @@ StatusManager.getManager().handle(statusAdapter, StatusManager.SHOW); - removeTopElement(ji); + if (FinishedJobs.keep(ji)) { + ji.setReported(true); + } else { + removeTopElement(ji); + } } execute(ji, job); @@ -209,7 +217,7 @@ if (jobTreeElements[i] instanceof JobInfo) { JobInfo ji = (JobInfo) jobTreeElements[i]; Job job = ji.getJob(); - if (job != null) { + if ((job != null) && (!ji.isReported())) { IStatus status = job.getResult(); if (status != null && status.getSeverity() == IStatus.ERROR) { // green arrow with error overlay