Author: xcoulon
Date: 2012-02-17 10:02:46 -0500 (Fri, 17 Feb 2012)
New Revision: 38878
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/JobResultFuture.java
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/WizardUtils.java
Log:
Fixed - RefreshTutorialsJob refreshTutorialsJob = RefreshTutorialsJob.INSTANCE;
https://issues.jboss.org/browse/JBIDE-10488
(extra fixes)
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/JobResultFuture.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/JobResultFuture.java 2012-02-17
15:00:57 UTC (rev 38877)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/JobResultFuture.java 2012-02-17
15:02:46 UTC (rev 38878)
@@ -29,6 +29,7 @@
*/
public class JobResultFuture implements Future<IStatus> {
+ private AtomicBoolean done = new AtomicBoolean();
private AtomicBoolean cancelled = new AtomicBoolean();
private ArrayBlockingQueue<IStatus> queue = new
ArrayBlockingQueue<IStatus>(1);
@@ -49,7 +50,7 @@
@Override
public boolean isDone() {
- return queue.size() == 1;
+ return done.get();
}
@Override
@@ -68,7 +69,8 @@
@Override
public void done(IJobChangeEvent event) {
- queue.offer(job.getResult());
+ queue.offer(event.getResult());
+ done.set(true);
}
});
}
Modified:
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/WizardUtils.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/WizardUtils.java 2012-02-17
15:00:57 UTC (rev 38877)
+++
trunk/common/plugins/org.jboss.tools.common.ui/src/org/jboss/tools/common/ui/WizardUtils.java 2012-02-17
15:02:46 UTC (rev 38878)
@@ -100,11 +100,11 @@
*/
public static IStatus runInWizard(final Job job, final DelegatingProgressMonitor
delegatingMonitor,
IWizardContainer container, final long timeout) throws InvocationTargetException,
InterruptedException {
+ final JobResultFuture future = new JobResultFuture(job);
container.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
InterruptedException {
IProgressMonitor monitorToUse = setupDelegatingMonitorIfPresent(delegatingMonitor,
monitor);
- final JobResultFuture future = new JobResultFuture(job);
monitorToUse.beginTask(job.getName(), IProgressMonitor.UNKNOWN);
job.schedule();
try {
@@ -115,10 +115,10 @@
monitorToUse.done();
}
});
- final IStatus result = job.getResult();
- if(result != null) {
- return result;
+ if(future.isDone()) {
+ return job.getResult();
}
+ CommonUIPlugin.getDefault().logError("Operation did not complete in a reasonnable
amount of time");
return new Status(IStatus.ERROR, CommonUIPlugin.PLUGIN_ID,
"Operation did not complete in a reasonnable amount of time");
}