View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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.teststep;
14  
15  import com.eviware.soapui.config.TestStepConfig;
16  import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase;
17  import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep;
18  import com.eviware.soapui.impl.wsdl.teststeps.registry.WsdlTestStepFactory;
19  import com.eviware.soapui.support.UISupport;
20  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
21  
22  /***
23   * Inserts a WsdlTestStep specified by the supplied WsdlTestStepFactory at the
24   * position to the specified WsdlTestStep
25   * 
26   * @author ole.matzura
27   */
28  
29  public class InsertWsdlTestStepAction extends AbstractSoapUIAction<WsdlTestStep>
30  {
31  	public static final String SOAPUI_ACTION_ID = "InsertWsdlTestStepAction";
32  
33  	public InsertWsdlTestStepAction()
34  	{
35  		super( "Insert Step", "Inserts a TestStep at the position of this TestStep" );
36  	}
37  
38  	public void perform( WsdlTestStep testStep, Object param )
39  	{
40  		WsdlTestStepFactory factory = ( WsdlTestStepFactory )param;
41  		WsdlTestCase testCase = testStep.getTestCase();
42  
43  		String name = UISupport.prompt( "Specify name for new step", "Insert Step", factory.getTestStepName() );
44  		if( name != null )
45  		{
46  			TestStepConfig newTestStepConfig = factory.createNewTestStep( testCase, name );
47  			if( newTestStepConfig != null )
48  			{
49  				int ix = testCase.getIndexOfTestStep( testStep );
50  				testStep = testCase.insertTestStep( newTestStepConfig, ix );
51  				if( testStep != null )
52  					UISupport.selectAndShow( testStep );
53  			}
54  		}
55  	}
56  }