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.teststeps.actions;
    14
    15  import java.awt.event.ActionEvent;
    16
    17  import javax.swing.AbstractAction;
    18  import javax.swing.Action;
    19
    20  import com.eviware.soapui.impl.wsdl.WsdlOperation;
    21  import com.eviware.soapui.impl.wsdl.WsdlRequest;
    22  import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStep;
    23  import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestRequestStepResult;
    24  import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStepResult;
    25  import com.eviware.soapui.support.UISupport;
    26
    27  /***
    28   * Creates a request from the specified TestStepResult
    29   *
    30   * @author Ole.Matzura
    31   */
    32
    33  public class CreateRequestAction extends AbstractAction
    34  {
    35  	private final WsdlTestRequestStepResult result;
    36
    37  	public CreateRequestAction(WsdlTestStepResult result)
    38  	{
    39  		this.result = (WsdlTestRequestStepResult) result;
    40
    41  		putValue( Action.SMALL_ICON, UISupport.createImageIcon( "/create_request_from_result.gif" ));
    42  		putValue( Action.SHORT_DESCRIPTION, "Creates a new request from this result" );
    43  	}
    44
    45  	public void actionPerformed(ActionEvent e)
    46  	{
    47  		WsdlTestRequestStep step = (WsdlTestRequestStep) result.getTestStep();
    48  		String name = UISupport.prompt( "Specify name of request", "Create Request",  "Result from " + step.getName() );
    49
    50  		if( name != null )
    51  		{
    52  			WsdlOperation operation = (WsdlOperation) step.getTestRequest().getOperation();
    53  			WsdlRequest request = operation.addNewRequest( name );
    54  			request.setRequestContent( result.getRequestContent() );
    55  			request.setDomain( result.getDomain() );
    56  			request.setEncoding( result.getEncoding() );
    57  			request.setEndpoint( result.getEndpoint() );
    58  			request.setPassword( result.getPassword() );
    59  			request.setUsername( result.getUsername() );
    60
    61           UISupport.showDesktopPanel( request );
    62  		}
    63  	}
    64  }