View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 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.impl.wsdl.actions.mockservice;
14  
15  import javax.swing.SwingUtilities;
16  
17  import com.eviware.soapui.SoapUI;
18  import com.eviware.soapui.impl.wsdl.mock.WsdlMockService;
19  import com.eviware.soapui.support.UISupport;
20  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
21  import com.eviware.soapui.ui.desktop.DesktopPanel;
22  
23  /***
24   * Clones a WsdlMockService
25   * 
26   * @author Ole.Matzura
27   */
28  
29  public class StartMinimizedMockServiceAction extends AbstractSoapUIAction<WsdlMockService>
30  {
31  	public final static String SOAPUI_ACTION_ID = "StartMinimizedMockServiceAction";
32  
33  	public StartMinimizedMockServiceAction()
34  	{
35  		super( "Start Minimized", "Starts this MockService and minimizes its desktop window" );
36  	}
37  
38  	public void perform( WsdlMockService mockService, Object param )
39  	{
40  		try
41  		{
42  			UISupport.setHourglassCursor();
43  			final DesktopPanel desktopPanel = UISupport.showDesktopPanel( mockService );
44  			if( mockService.getMockRunner() == null )
45  				mockService.start();
46  
47  			SwingUtilities.invokeLater( new Runnable()
48  			{
49  				public void run()
50  				{
51  					SoapUI.getDesktop().minimize( desktopPanel );
52  				}
53  			} );
54  		}
55  		catch( Exception e )
56  		{
57  			UISupport.showErrorMessage( e );
58  		}
59  		finally
60  		{
61  			UISupport.resetCursor();
62  		}
63  	}
64  }