01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
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 class SwingWorkerDelegator extends SwingWorker {
24: private XProgressMonitor monitor;
25: private Worker delegate;
26: private XProgressDialog dialog;
27:
28: /**
29: * Start a thread that will call <code>delegate.construct</code> and then exit.
30: */
31: public SwingWorkerDelegator(XProgressMonitor monitor,
32: XProgressDialog dialog, Worker delegate) {
33: this .monitor = monitor;
34: this .dialog = dialog;
35: this .delegate = delegate;
36: }
37:
38: /**
39: * Compute the value to be returned by the <code>get</code> method.
40: */
41:
42: public Object construct() {
43: return delegate.construct(monitor);
44: }
45:
46: /**
47: * Called on the event dispatching thread (not on the worker thread)
48: * after the <code>construct</code> method has returned.
49: */
50: public void finished() {
51: delegate.finished();
52: if (dialog != null)
53: dialog.setVisible(false);
54: delegate = null;
55: monitor = null;
56: dialog = null;
57: }
58: }
|