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.support.action.support;
    14
    15  import com.eviware.soapui.SoapUI;
    16  import com.eviware.soapui.model.ModelItem;
    17  import com.eviware.soapui.support.action.SoapUIAction;
    18  import com.eviware.soapui.support.action.SoapUIActionMapping;
    19
    20  /***
    21   * Default implementation for a SoapUIActionMapping
    22   *
    23   * @author ole.matzura
    24   */
    25
    26  public class DefaultActionMapping<T extends ModelItem> implements SoapUIActionMapping<T>
    27  {
    28  	private String actionId;
    29  	private String keyStroke;
    30  	private String iconPath;
    31  	private boolean isDefault;
    32  	private Object param;
    33  	private String description;
    34  	private String name;
    35  	private boolean enabled = true;
    36
    37  	public DefaultActionMapping( String actionId, String keyStroke, String iconPath, boolean isDefault, Object param )
    38  	{
    39  		super();
    40  		this.actionId = actionId;
    41  		this.keyStroke = keyStroke;
    42  		this.iconPath = iconPath;
    43  		this.isDefault = isDefault;
    44  		this.param = param;
    45  	}
    46
    47  	@SuppressWarnings("unchecked")
    48  	public SoapUIAction<T> getAction()
    49  	{
    50  		return SoapUI.getActionRegistry().getAction( actionId );
    51  	}
    52
    53  	public boolean isDefault()
    54  	{
    55  		return isDefault;
    56  	}
    57
    58  	public String getIconPath()
    59  	{
    60  		return iconPath;
    61  	}
    62
    63  	public String getKeyStroke()
    64  	{
    65  		return keyStroke;
    66  	}
    67
    68  	public String getActionId()
    69  	{
    70  		return actionId;
    71  	}
    72
    73  	public Object getParam()
    74  	{
    75  		return param;
    76  	}
    77
    78  	public String getDescription()
    79  	{
    80  		return description == null ? getAction().getDescription() : description;
    81  	}
    82
    83  	public String getName()
    84  	{
    85  		return name == null ? getAction().getName() : name;
    86  	}
    87
    88  	public void setActionId( String actionId )
    89  	{
    90  		this.actionId = actionId;
    91  	}
    92
    93  	public SoapUIActionMapping<T> setDescription( String description )
    94  	{
    95  		this.description = description;
    96  		return this;
    97  	}
    98
    99  	public void setIconPath( String iconPath )
    100 	{
    101 		this.iconPath = iconPath;
    102 	}
    103
    104 	public void setDefault( boolean isDefault )
    105 	{
    106 		this.isDefault = isDefault;
    107 	}
    108
    109 	public void setKeyStroke( String keyStroke )
    110 	{
    111 		this.keyStroke = keyStroke;
    112 	}
    113
    114 	public SoapUIActionMapping<T> setName( String name )
    115 	{
    116 		this.name = name;
    117 		return this;
    118 	}
    119
    120 	public SoapUIActionMapping<T> setParam( Object param )
    121 	{
    122 		this.param = param;
    123 		return this;
    124 	}
    125
    126 	public boolean isEnabled()
    127 	{
    128 		return enabled ;
    129 	}
    130
    131 	public SoapUIActionMapping<T> setEnabled( boolean enabled )
    132 	{
    133 		this.enabled = enabled;
    134 		return this;
    135 	}
    136 }