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.support.action.support.AbstractSoapUIAction;
    17  import com.eviware.x.form.XFormDialog;
    18  import com.eviware.x.form.support.ADialogBuilder;
    19  import com.eviware.x.form.support.AField;
    20  import com.eviware.x.form.support.AForm;
    21  import com.eviware.x.form.support.AField.AFieldType;
    22
    23  /***
    24   * Displays the options for the specified WsdlMockService
    25   *
    26   * @author ole.matzura
    27   */
    28
    29  public class MockServiceOptionsAction extends AbstractSoapUIAction<WsdlMockService>
    30  {
    31  	private XFormDialog dialog;
    32
    33  	public MockServiceOptionsAction()
    34  	{
    35  		super( "Options", "Sets options for this MockService" );
    36  	}
    37
    38  	public void perform( WsdlMockService mockService, Object param )
    39  	{
    40  		if( dialog == null )
    41  			dialog = ADialogBuilder.buildDialog( OptionsForm.class );
    42
    43  		dialog.setValue( OptionsForm.PATH, mockService.getPath() );
    44  		dialog.setIntValue( OptionsForm.PORT, mockService.getPort() );
    45
    46  		boolean enabled = mockService.getMockRunner() == null;
    47
    48  		dialog.getFormField( OptionsForm.PATH ).setEnabled( enabled );
    49  		dialog.getFormField( OptionsForm.PORT ).setEnabled( enabled );
    50
    51  		if( dialog.show() )
    52  		{
    53  			mockService.setPath( dialog.getValue( OptionsForm.PATH ) );
    54  			mockService.setPort( dialog.getIntValue( OptionsForm.PORT, mockService.getPort() ) );
    55  		}
    56  	}
    57
    58  	@AForm( name="MockService Options", description="Set options for this MockService" )
    59  	private class OptionsForm
    60  	{
    61  		@AField( name="Path", description="The path this MockService will mount on")
    62  		public final static String PATH = "Path";
    63
    64  		@AField( name="Port", description="The port this MockService will mount on", type=AFieldType.INT )
    65  		public final static String PORT = "Port";
    66  	}
    67  }