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.teststep;
    14
    15  import java.util.List;
    16
    17  import com.eviware.soapui.SoapUI;
    18  import com.eviware.soapui.impl.wsdl.actions.support.ShowDesktopPanelAction;
    19  import com.eviware.soapui.impl.wsdl.teststeps.WsdlTestStep;
    20  import com.eviware.soapui.support.action.SoapUIActionGroup;
    21  import com.eviware.soapui.support.action.SoapUIActionMapping;
    22  import com.eviware.soapui.support.action.support.DefaultActionMapping;
    23  import com.eviware.soapui.support.action.support.DefaultSoapUIActionGroup;
    24
    25  /***
    26   * SoapUIActionGroup for WsdlTestSteps
    27   *
    28   * @author ole.matzura
    29   */
    30
    31  public class WsdlTestStepSoapUIActionGroup extends DefaultSoapUIActionGroup<WsdlTestStep>
    32  {
    33  	private boolean initialized;
    34
    35  	public WsdlTestStepSoapUIActionGroup( String id, String name )
    36  	{
    37  		super( id, name );
    38  	}
    39
    40  	public List<SoapUIActionMapping<WsdlTestStep>> getActionMappings( WsdlTestStep modelItem )
    41  	{
    42  		List<SoapUIActionMapping<WsdlTestStep>> actions = super.getActionMappings( modelItem );
    43  		SoapUIActionMapping<WsdlTestStep> toggleDisabledActionMapping = null;
    44
    45  		if( !initialized )
    46  		{
    47  			int insertIndex = 0;
    48
    49  			// add open-editor action
    50  			if( modelItem.hasEditor() )
    51  			{
    52  				DefaultActionMapping<WsdlTestStep> actionMapping = new DefaultActionMapping<WsdlTestStep>( ShowDesktopPanelAction.SOAPUI_ACTION_ID,
    53  										"ENTER", null, true, modelItem );
    54
    55  				actionMapping.setName( "Open Editor" );
    56  				actionMapping.setDescription( "Opens the editor for this TestStep" );
    57
    58  				actions.add( 0, actionMapping);
    59  				insertIndex++;
    60  			}
    61
    62  			toggleDisabledActionMapping = new DefaultActionMapping<WsdlTestStep>( ToggleDisableTestStepAction.SOAPUI_ACTION_ID,
    63  									null, null, false, modelItem );
    64
    65  			actions.add( insertIndex, toggleDisabledActionMapping);
    66  			insertIndex++;
    67
    68  			// add default teststep actions
    69  			SoapUIActionGroup<WsdlTestStep> actionGroup = SoapUI.getActionRegistry().getActionGroup( "WsdlTestStepActions" );
    70  			if( actionGroup != null )
    71  			{
    72  				actions.addAll( insertIndex, actionGroup.getActionMappings( modelItem ));
    73  			}
    74
    75  			initialized = true;
    76  		}
    77  		else
    78  		{
    79  			for( int c = 0; c < actions.size(); c++ )
    80  			{
    81  				if( actions.get( c ).getActionId().equals( ToggleDisableTestStepAction.SOAPUI_ACTION_ID ))
    82  				{
    83  					toggleDisabledActionMapping = actions.get( c );
    84  					break;
    85  				}
    86  			}
    87  		}
    88
    89  		if( toggleDisabledActionMapping != null )
    90  		{
    91  			if( modelItem.isDisabled() )
    92  			{
    93  				toggleDisabledActionMapping.setName( "Enable TestStep" );
    94  				toggleDisabledActionMapping.setDescription( "Enable this TestStep during TestCase execution" );
    95  			}
    96  			else
    97  			{
    98  				toggleDisabledActionMapping.setName( "Disable TestStep" );
    99  				toggleDisabledActionMapping.setDescription( "Disables this TestStep during TestCase execution" );
    100 			}
    101 		}
    102
    103 		return actions;
    104 	}
    105
    106 }