View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of version 2.1 of the GNU Lesser General Public License as published by 
6    *  the Free Software Foundation.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  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  {
25      private XProgressMonitor monitor;
26      private Worker delegate;
27  	 private 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 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 void finished() {
53         delegate.finished();
54         if( dialog != null )
55        	 dialog.setVisible( false );
56         delegate = null;
57         monitor = null;
58         dialog = null;
59      }
60  }