1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.support.swing;
14
15 import com.eviware.x.dialogs.Worker;
16 import com.eviware.x.dialogs.XProgressDialog;
17 import com.eviware.x.dialogs.XProgressMonitor;
18
19 /***
20 *
21 * @author Lars Høidahl
22 */
23 public final class SwingWorkerDelegator extends SwingWorker
24 {
25 private XProgressMonitor monitor;
26 private Worker delegate;
27 private final XProgressDialog dialog;
28
29 /***
30 * Start a thread that will call <code>delegate.construct</code> and then exit.
31 */
32 public SwingWorkerDelegator(XProgressMonitor monitor, XProgressDialog dialog, Worker delegate)
33 {
34 this.monitor = monitor;
35 this.dialog = dialog;
36 this.delegate = delegate;
37 }
38
39 /***
40 * Compute the value to be returned by the <code>get</code> method.
41 */
42
43 public final Object construct()
44 {
45 return delegate.construct(monitor);
46 }
47
48 /***
49 * Called on the event dispatching thread (not on the worker thread)
50 * after the <code>construct</code> method has returned.
51 */
52 public final void finished() {
53 delegate.finished();
54 if( dialog != null )
55 dialog.setVisible( false );
56 }
57 }