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.operation;
    14
    15  import com.eviware.soapui.impl.wsdl.WsdlOperation;
    16  import com.eviware.soapui.impl.wsdl.WsdlRequest;
    17  import com.eviware.soapui.settings.WsdlSettings;
    18  import com.eviware.soapui.support.UISupport;
    19  import com.eviware.soapui.support.action.support.AbstractSoapUIAction;
    20
    21  /***
    22   * Adds a new WsdlRequest to a WsdlOperation
    23   *
    24   * @author Ole.Matzura
    25   */
    26
    27  public class NewRequestAction extends AbstractSoapUIAction<WsdlOperation>
    28  {
    29  	public final static String SOAPUI_ACTION_ID = "NewRequestAction";
    30
    31  	public NewRequestAction()
    32     {
    33        super( "New request", "Creates a new request for this operation" );
    34     }
    35
    36     public void perform( WsdlOperation operation, Object param )
    37  	{
    38        String name = UISupport.prompt( "Specify name of request", "New request", "Request " + (operation.getRequestCount()+1) );
    39        if( name == null ) return;
    40
    41        boolean createOptional = operation.getSettings().getBoolean(WsdlSettings.XML_GENERATION_ALWAYS_INCLUDE_OPTIONAL_ELEMENTS);
    42        if (!createOptional)
    43      	  createOptional =  UISupport.confirm(	"Create optional elements in schema?", "Create Request" );
    44
    45        WsdlRequest newRequest = operation.addNewRequest( name );
    46        String requestContent = operation.createRequest( createOptional );
    47        if(requestContent != null)
    48        {
    49           newRequest.setRequestContent( requestContent );
    50        }
    51
    52        UISupport.showDesktopPanel( newRequest );
    53     }
    54  }