View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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.support.action.support;
14  
15  import com.eviware.soapui.model.ModelItem;
16  import com.eviware.soapui.support.action.SoapUIAction;
17  import com.eviware.soapui.support.action.SoapUIActionMapping;
18  
19  /***
20   * A standalone SoapUIAcionMapping
21   * 
22   * @author ole.matzura
23   */
24  
25  public class StandaloneActionMapping<T extends ModelItem> implements SoapUIActionMapping<T>
26  {
27  	private final SoapUIAction<T> action;
28  	private String keyStroke;
29  	private String description;
30  	private String name;
31  	private Object param;
32  	private String iconPath;
33  	private boolean enabled = true;
34  
35  	public StandaloneActionMapping( SoapUIAction<T> action, String keyStroke, String iconPath )
36  	{
37  		if( action == null )
38  			throw new IllegalArgumentException( "action can't be null" );
39  		this.action = action;
40  		this.keyStroke = keyStroke;
41  		this.iconPath = iconPath;
42  	}
43  
44  	public StandaloneActionMapping( SoapUIAction<T> action, String keyStroke )
45  	{
46  		this.action = action;
47  		this.keyStroke = keyStroke;
48  	}
49  
50  	public StandaloneActionMapping( SoapUIAction<T> action )
51  	{
52  		this.action = action;
53  	}
54  
55  	public SoapUIAction<T> getAction()
56  	{
57  		return action;
58  	}
59  
60  	public String getActionId()
61  	{
62  		return action.getClass().getSimpleName();
63  	}
64  
65  	public String getIconPath()
66  	{
67  		return iconPath;
68  	}
69  
70  	public String getKeyStroke()
71  	{
72  		return keyStroke;
73  	}
74  
75  	public Object getParam()
76  	{
77  		return param;
78  	}
79  
80  	public boolean isDefault()
81  	{
82  		return false;
83  	}
84  
85  	public String getDescription()
86  	{
87  		return description == null ? action.getDescription() : description;
88  	}
89  
90  	public String getName()
91  	{
92  		return name == null ? action.getName() : name;
93  	}
94  
95  	public SoapUIActionMapping<T> setDescription( String description )
96  	{
97  		this.description = description;
98  		return this;
99  	}
100 
101 	public SoapUIActionMapping<T> setName( String name )
102 	{
103 		this.name = name;
104 		return this;
105 	}
106 
107 	public SoapUIActionMapping<T> setParam( Object param )
108 	{
109 		this.param = param;
110 		return this;
111 	}
112 
113 	public String getId()
114 	{
115 		return null;
116 	}
117 
118 	public boolean isEnabled()
119 	{
120 		return enabled;
121 	}
122 
123 	public SoapUIActionMapping<T> setEnabled( boolean enabled )
124 	{
125 		this.enabled = enabled;
126 		return this;
127 	}
128 }