1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.rest.actions.resource;
14
15 import com.eviware.soapui.impl.rest.RestRequest;
16 import com.eviware.soapui.impl.rest.RestResource;
17 import com.eviware.soapui.impl.support.AbstractHttpRequest.RequestMethod;
18 import com.eviware.soapui.impl.wsdl.support.HelpUrls;
19 import com.eviware.soapui.support.MessageSupport;
20 import com.eviware.soapui.support.UISupport;
21 import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
22 import com.eviware.x.form.XFormDialog;
23 import com.eviware.x.form.support.ADialogBuilder;
24 import com.eviware.x.form.support.AField;
25 import com.eviware.x.form.support.AField.AFieldType;
26 import com.eviware.x.form.support.AForm;
27
28 /***
29 * Actions for importing an existing soapUI project file into the current workspace
30 *
31 * @author Ole.Matzura
32 */
33
34 public class NewRestRequestAction extends AbstractSoapUIAction<RestResource>
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( RestResource resource, 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 = resource.addNewRequest( dialog.getValue(Form.RESOURCENAME));
59 request.setMethod( RequestMethod.valueOf(dialog.getValue( Form.METHOD )));
60
61 UISupport.select(request);
62
63 if( dialog.getBooleanValue(Form.OPENSREQUEST))
64 {
65 UISupport.showDesktopPanel(request);
66 }
67 }
68 }
69
70 @AForm( name="Form.Title", description = "Form.Description", helpUrl=HelpUrls.NEWRESTSERVICE_HELP_URL, icon=UISupport.TOOL_ICON_PATH)
71 public interface Form
72 {
73 @AField( description = "Form.ResourceName.Description", type = AFieldType.STRING )
74 public final static String RESOURCENAME = messages.get("Form.ResourceName.Label");
75
76 @AField( description = "Form.Method.Description", type = AFieldType.ENUMERATION, values={"GET","POST","PUT","DELETE","HEAD"} )
77 public final static String METHOD = messages.get("Form.Method.Label");
78
79 @AField(description = "Form.OpenRequest.Description", type = AFieldType.BOOLEAN )
80 public final static String OPENSREQUEST = messages.get("Form.OpenRequest.Label");
81 }
82 }