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.setIntValue( OptionsForm.PORT, mockService.getPort() );
47  		
48  		boolean enabled = mockService.getMockRunner() == null;
49  		
50  		dialog.getFormField( OptionsForm.PATH ).setEnabled( enabled );
51  		dialog.getFormField( OptionsForm.PORT ).setEnabled( enabled );
52  		
53  		if( dialog.show() )
54  		{
55  			mockService.setPath( dialog.getValue( OptionsForm.PATH ) );
56  			mockService.setPort( dialog.getIntValue( OptionsForm.PORT, mockService.getPort() ) );
57  		}
58  	}
59  
60  	@AForm( name="MockService Options", description="Set options for this MockService",
61  				helpUrl=HelpUrls.MOCKSERVICEOPTIONS_HELP_URL, icon=UISupport.OPTIONS_ICON_PATH )
62  	private class OptionsForm
63  	{
64  		@AField( name="Path", description="The path this MockService will mount on")
65  		public final static String PATH = "Path";
66  
67  		@AField( name="Port", description="The port this MockService will mount on", type=AFieldType.INT )
68  		public final static String PORT = "Port";
69  	}
70  }