1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.actions.mockservice;
14
15 import com.eviware.soapui.impl.wsdl.mock.WsdlMockService;
16 import com.eviware.soapui.impl.wsdl.support.HelpUrls;
17 import com.eviware.soapui.support.UISupport;
18 import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
19 import com.eviware.x.form.XFormDialog;
20 import com.eviware.x.form.support.ADialogBuilder;
21 import com.eviware.x.form.support.AField;
22 import com.eviware.x.form.support.AForm;
23 import com.eviware.x.form.support.AField.AFieldType;
24
25 /***
26 * Displays the options for the specified WsdlMockService
27 *
28 * @author ole.matzura
29 */
30
31 public class MockServiceOptionsAction extends AbstractSoapUIAction<WsdlMockService>
32 {
33 private XFormDialog dialog;
34
35 public MockServiceOptionsAction()
36 {
37 super( "Options", "Sets options for this MockService" );
38 }
39
40 public void perform( WsdlMockService mockService, Object param )
41 {
42 if( mockService.getMockRunner() != null && mockService.getMockRunner().isRunning() )
43 {
44 UISupport.showErrorMessage("Can not set MockService options while running" );
45 return;
46 }
47
48 if( dialog == null )
49 dialog = ADialogBuilder.buildDialog( OptionsForm.class );
50
51 dialog.setValue( OptionsForm.PATH, mockService.getPath() );
52 dialog.setValue( OptionsForm.HOST, mockService.getHost() );
53 dialog.setIntValue( OptionsForm.PORT, mockService.getPort() );
54 dialog.setBooleanValue( OptionsForm.HOSTONLY, mockService.getBindToHostOnly() );
55 dialog.setValue(OptionsForm.DOCROOT, mockService.getDocroot());
56
57 if( dialog.show() )
58 {
59 mockService.setPath( dialog.getValue( OptionsForm.PATH ) );
60 mockService.setPort( dialog.getIntValue( OptionsForm.PORT, mockService.getPort() ) );
61 mockService.setHost( dialog.getValue( OptionsForm.HOST ) );
62 mockService.setBindToHostOnly( dialog.getBooleanValue( OptionsForm.HOSTONLY ) );
63 mockService.setDocroot(dialog.getValue( OptionsForm.DOCROOT ));
64 }
65 }
66
67 @AForm( name="MockService Options", description="Set options for this MockService",
68 helpUrl=HelpUrls.MOCKSERVICEOPTIONS_HELP_URL, icon=UISupport.OPTIONS_ICON_PATH )
69 private class OptionsForm
70 {
71 @AField( name="Path", description="The path this MockService will mount on")
72 public final static String PATH = "Path";
73
74 @AField( name="Port", description="The port this MockService will mount on", type=AFieldType.INT )
75 public final static String PORT = "Port";
76
77 @AField( name="Host", description="The local host to bind to and use in Port endpoints")
78 public final static String HOST = "Host";
79
80 @AField( name="Host Only", description="Only binds to specified host", type=AFieldType.BOOLEAN )
81 public final static String HOSTONLY = "Host Only";
82
83 @AField( name="Docroot", description="The document root to serve (empty = none)", type=AFieldType.FOLDER )
84 public final static String DOCROOT = "Docroot";
85 }
86 }