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 java.beans.PropertyChangeListener;
    16  import java.beans.PropertyChangeSupport;
    17
    18  import com.eviware.soapui.model.ModelItem;
    19  import com.eviware.soapui.support.action.SoapUIAction;
    20
    21  /***
    22   * Abstract SoapUIAction for extension
    23   *
    24   * @author ole.matzura
    25   */
    26
    27  public abstract class AbstractSoapUIAction<T extends ModelItem> implements SoapUIAction<T>
    28  {
    29  	private PropertyChangeSupport propertySupport;
    30  	private String name;
    31  	private String description;
    32  	private boolean enabled = true;
    33
    34  	public AbstractSoapUIAction()
    35  	{
    36  		propertySupport = new PropertyChangeSupport( this );
    37  	}
    38
    39  	public AbstractSoapUIAction( String name, String description )
    40  	{
    41  		this.name = name;
    42  		this.description = description;
    43
    44  		propertySupport = new PropertyChangeSupport( this );
    45  	}
    46
    47  	public String getDescription()
    48  	{
    49  		return description;
    50  	}
    51
    52  	public void setEnabled(boolean enabled)
    53  	{
    54  		if( enabled == this.enabled )
    55  			return;
    56
    57  		boolean oldEnabled = this.enabled;
    58  		this.enabled = enabled;
    59
    60  		propertySupport.firePropertyChange( ENABLED_PROPERTY, oldEnabled, enabled );
    61  	}
    62
    63  	public boolean applies( T target )
    64  	{
    65  		return true;
    66  	}
    67
    68  	public boolean isDefault()
    69  	{
    70  		return false;
    71  	}
    72
    73  	public String getName()
    74  	{
    75  		return name;
    76  	}
    77
    78  	public boolean isEnabled()
    79  	{
    80  		return enabled;
    81  	}
    82
    83  	public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
    84  	{
    85  		propertySupport.addPropertyChangeListener( propertyName, listener );
    86  	}
    87
    88  	public void addPropertyChangeListener(PropertyChangeListener listener)
    89  	{
    90  		propertySupport.addPropertyChangeListener( listener );
    91  	}
    92
    93  	public void removePropertyChangeListener(PropertyChangeListener listener)
    94  	{
    95  		propertySupport.removePropertyChangeListener( listener );
    96  	}
    97
    98  	public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
    99  	{
    100 		propertySupport.removePropertyChangeListener( propertyName, listener );
    101 	}
    102 }