View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2007 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.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( dialog == null )
43  			dialog = ADialogBuilder.buildDialog( OptionsForm.class );
44  
45  		dialog.setValue( OptionsForm.PATH, mockService.getPath() );
46  		dialog.setValue( OptionsForm.HOST, mockService.getHost() );
47  		dialog.setIntValue( OptionsForm.PORT, mockService.getPort() );
48  		dialog.setBooleanValue( OptionsForm.HOSTONLY, mockService.getBindToHostOnly() );
49  		
50  		if( dialog.show() )
51  		{
52  			mockService.setPath( dialog.getValue( OptionsForm.PATH ) );
53  			mockService.setPort( dialog.getIntValue( OptionsForm.PORT, mockService.getPort() ) );
54  			mockService.setHost(  dialog.getValue( OptionsForm.HOST ) );
55  			mockService.setBindToHostOnly( dialog.getBooleanValue( OptionsForm.HOSTONLY ) );
56  		}
57  	}
58  
59  	@AForm( name="MockService Options", description="Set options for this MockService",
60  				helpUrl=HelpUrls.MOCKSERVICEOPTIONS_HELP_URL, icon=UISupport.OPTIONS_ICON_PATH )
61  	private class OptionsForm
62  	{
63  		@AField( name="Path", description="The path this MockService will mount on")
64  		public final static String PATH = "Path";
65  
66  		@AField( name="Port", description="The port this MockService will mount on", type=AFieldType.INT )
67  		public final static String PORT = "Port";
68  
69  		@AField( name="Host", description="The local host to bind to and use in Port endpoints")
70  		public final static String HOST = "Host";
71  
72  		@AField( name="Host Only", description="Only binds to specified host", type=AFieldType.BOOLEAN )
73  		public final static String HOSTONLY = "Host Only";
74  
75  	}
76  }