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;
14  
15  import java.beans.PropertyChangeListener;
16  import java.beans.PropertyChangeSupport;
17  
18  public abstract class AbstractSoapUIAction<T> implements SoapUIAction<T>
19  {
20  	private PropertyChangeSupport propertySupport;
21  	private String name;
22  	private String description;
23  	private boolean enabled = true;
24  
25  	public AbstractSoapUIAction( String name, String description )
26  	{
27  		this.name = name;
28  		this.description = description;
29  		
30  		propertySupport = new PropertyChangeSupport( this );
31  	}
32  	
33  	public String getDescription()
34  	{
35  		return description;
36  	}
37  
38  	public void setEnabled(boolean enabled)
39  	{
40  		if( enabled == this.enabled )
41  			return;
42  		
43  		boolean oldEnabled = this.enabled;
44  		this.enabled = enabled;
45  		
46  		propertySupport.firePropertyChange( ENABLED_PROPERTY, oldEnabled, enabled );
47  	}
48  
49  	public String getName()
50  	{
51  		return name;
52  	}
53  
54  	public boolean isEnabled()
55  	{
56  		return enabled;
57  	}
58  
59  	public abstract void perform(T target);
60  
61  	public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
62  	{
63  		propertySupport.addPropertyChangeListener( propertyName, listener );
64  	}
65  
66  	public void addPropertyChangeListener(PropertyChangeListener listener)
67  	{
68  		propertySupport.addPropertyChangeListener( listener );
69  	}
70  
71  	public void removePropertyChangeListener(PropertyChangeListener listener)
72  	{
73  		propertySupport.removePropertyChangeListener( listener );
74  	}
75  
76  	public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
77  	{
78  		propertySupport.removePropertyChangeListener( propertyName, listener );
79  	}
80  }