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.rest.actions.method;
14  
15  import com.eviware.soapui.impl.rest.RestMethod;
16  import com.eviware.soapui.impl.rest.RestRequest;
17  import com.eviware.soapui.impl.wsdl.support.HelpUrls;
18  import com.eviware.soapui.support.MessageSupport;
19  import com.eviware.soapui.support.UISupport;
20  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
21  import com.eviware.x.form.XFormDialog;
22  import com.eviware.x.form.support.ADialogBuilder;
23  import com.eviware.x.form.support.AField;
24  import com.eviware.x.form.support.AForm;
25  import com.eviware.x.form.support.AField.AFieldType;
26  
27  /***
28   * Actions for importing an existing soapUI project file into the current
29   * workspace
30   * 
31   * @author Ole.Matzura
32   */
33  
34  public class NewRestRequestAction extends AbstractSoapUIAction<RestMethod>
35  {
36  	public static final String SOAPUI_ACTION_ID = "NewRestRequestAction";
37  	public static final MessageSupport messages = MessageSupport.getMessages( NewRestRequestAction.class );
38  	private XFormDialog dialog;
39  
40  	public NewRestRequestAction()
41  	{
42  		super( messages.get( "title" ), messages.get( "description" ) );
43  	}
44  
45  	public void perform( RestMethod method, Object param )
46  	{
47  		if( dialog == null )
48  		{
49  			dialog = ADialogBuilder.buildDialog( Form.class );
50  		}
51  		else
52  		{
53  			dialog.setValue( Form.RESOURCENAME, "" );
54  		}
55  
56  		if( dialog.show() )
57  		{
58  			RestRequest request = method.addNewRequest( dialog.getValue( Form.RESOURCENAME ) );
59  
60  			UISupport.select( request );
61  
62  			if( dialog.getBooleanValue( Form.OPENSREQUEST ) )
63  			{
64  				UISupport.showDesktopPanel( request );
65  			}
66  		}
67  	}
68  
69  	@AForm( name = "Form.Title", description = "Form.Description", helpUrl = HelpUrls.NEWRESTSERVICE_HELP_URL, icon = UISupport.TOOL_ICON_PATH )
70  	public interface Form
71  	{
72  		@AField( description = "Form.ResourceName.Description", type = AFieldType.STRING )
73  		public final static String RESOURCENAME = messages.get( "Form.ResourceName.Label" );
74  
75  		@AField( description = "Form.OpenRequest.Description", type = AFieldType.BOOLEAN )
76  		public final static String OPENSREQUEST = messages.get( "Form.OpenRequest.Label" );
77  	}
78  }