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