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.operation;
14  
15  import com.eviware.soapui.impl.wsdl.WsdlOperation;
16  import com.eviware.soapui.impl.wsdl.WsdlRequest;
17  import com.eviware.soapui.settings.WsdlSettings;
18  import com.eviware.soapui.support.UISupport;
19  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
20  
21  /***
22   * Adds a new WsdlRequest to a WsdlOperation
23   * 
24   * @author Ole.Matzura
25   */
26  
27  public class NewRequestAction extends AbstractSoapUIAction<WsdlOperation>
28  {
29  	public final static String SOAPUI_ACTION_ID = "NewRequestAction";
30  
31  	public NewRequestAction()
32  	{
33  		super( "New request", "Creates a new request for this operation" );
34  	}
35  
36  	public void perform( WsdlOperation operation, Object param )
37  	{
38  		String name = UISupport.prompt( "Specify name of request", "New request", "Request "
39  				+ ( operation.getRequestCount() + 1 ) );
40  		if( name == null )
41  			return;
42  
43  		boolean createOptional = operation.getSettings().getBoolean(
44  				WsdlSettings.XML_GENERATION_ALWAYS_INCLUDE_OPTIONAL_ELEMENTS );
45  		if( !createOptional )
46  			createOptional = UISupport.confirm( "Create optional elements in schema?", "Create Request" );
47  
48  		WsdlRequest newRequest = operation.addNewRequest( name );
49  		String requestContent = operation.createRequest( createOptional );
50  		if( requestContent != null )
51  		{
52  			newRequest.setRequestContent( requestContent );
53  		}
54  
55  		UISupport.showDesktopPanel( newRequest );
56  	}
57  }