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( String name, String description )
    35  	{
    36  		this.name = name;
    37  		this.description = description;
    38
    39  		propertySupport = new PropertyChangeSupport( this );
    40  	}
    41
    42  	public String getDescription()
    43  	{
    44  		return description;
    45  	}
    46
    47  	public void setEnabled(boolean enabled)
    48  	{
    49  		if( enabled == this.enabled )
    50  			return;
    51
    52  		boolean oldEnabled = this.enabled;
    53  		this.enabled = enabled;
    54
    55  		propertySupport.firePropertyChange( ENABLED_PROPERTY, oldEnabled, enabled );
    56  	}
    57
    58  	public boolean applies( T target )
    59  	{
    60  		return true;
    61  	}
    62
    63  	public boolean isDefault()
    64  	{
    65  		return false;
    66  	}
    67
    68  	public String getName()
    69  	{
    70  		return name;
    71  	}
    72
    73  	public boolean isEnabled()
    74  	{
    75  		return enabled;
    76  	}
    77
    78  	public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
    79  	{
    80  		propertySupport.addPropertyChangeListener( propertyName, listener );
    81  	}
    82
    83  	public void addPropertyChangeListener(PropertyChangeListener listener)
    84  	{
    85  		propertySupport.addPropertyChangeListener( listener );
    86  	}
    87
    88  	public void removePropertyChangeListener(PropertyChangeListener listener)
    89  	{
    90  		propertySupport.removePropertyChangeListener( listener );
    91  	}
    92
    93  	public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
    94  	{
    95  		propertySupport.removePropertyChangeListener( propertyName, listener );
    96  	}
    97  }