View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2010 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.model.support;
14  
15  import java.beans.PropertyChangeListener;
16  import java.beans.PropertyChangeSupport;
17  import java.util.Collections;
18  import java.util.List;
19  
20  import com.eviware.soapui.SoapUI;
21  import com.eviware.soapui.model.ModelItem;
22  
23  /***
24   * Base-class for ModelItem implementations
25   * 
26   * @author Ole.Matzura
27   */
28  
29  public abstract class AbstractModelItem implements ModelItem
30  {
31  	private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport( this );
32  
33  	public void addPropertyChangeListener( String propertyName, PropertyChangeListener listener )
34  	{
35  		try
36  		{
37  			propertyChangeSupport.addPropertyChangeListener( propertyName, listener );
38  		}
39  		catch( Throwable t )
40  		{
41  			SoapUI.logError( t );
42  		}
43  	}
44  
45  	public void addPropertyChangeListener( PropertyChangeListener listener )
46  	{
47  		try
48  		{
49  			propertyChangeSupport.addPropertyChangeListener( listener );
50  		}
51  		catch( Throwable t )
52  		{
53  			SoapUI.logError( t );
54  		}
55  	}
56  
57  	public void removePropertyChangeListener( PropertyChangeListener listener )
58  	{
59  		try
60  		{
61  			propertyChangeSupport.removePropertyChangeListener( listener );
62  		}
63  		catch( Throwable t )
64  		{
65  			SoapUI.logError( t );
66  		}
67  	}
68  
69  	public void removePropertyChangeListener( String propertyName, PropertyChangeListener listener )
70  	{
71  		try
72  		{
73  			propertyChangeSupport.removePropertyChangeListener( propertyName, listener );
74  		}
75  		catch( Throwable t )
76  		{
77  			SoapUI.logError( t );
78  		}
79  	}
80  
81  	public void notifyPropertyChanged( String name, Object oldValue, Object newValue )
82  	{
83  		try
84  		{
85  			propertyChangeSupport.firePropertyChange( name, oldValue, newValue );
86  		}
87  		catch( Throwable t )
88  		{
89  			SoapUI.logError( t );
90  		}
91  	}
92  
93  	public void notifyPropertyChanged( String name, String oldValue, String newValue )
94  	{
95  		try
96  		{
97  			propertyChangeSupport.firePropertyChange( name, oldValue, newValue );
98  		}
99  		catch( Throwable t )
100 		{
101 			SoapUI.logError( t );
102 		}
103 	}
104 
105 	public void notifyPropertyChanged( String name, int oldValue, int newValue )
106 	{
107 		try
108 		{
109 			propertyChangeSupport.firePropertyChange( name, oldValue, newValue );
110 		}
111 		catch( Throwable t )
112 		{
113 			SoapUI.logError( t );
114 		}
115 	}
116 
117 	public void notifyPropertyChanged( String name, boolean oldValue, boolean newValue )
118 	{
119 		try
120 		{
121 			propertyChangeSupport.firePropertyChange( name, oldValue, newValue );
122 		}
123 		catch( Throwable t )
124 		{
125 			SoapUI.logError( t );
126 		}
127 	}
128 
129 	public void fireIndexedPropertyChange( String propertyName, int index, boolean oldValue, boolean newValue )
130 	{
131 		try
132 		{
133 			propertyChangeSupport.fireIndexedPropertyChange( propertyName, index, oldValue, newValue );
134 		}
135 		catch( Throwable t )
136 		{
137 			SoapUI.logError( t );
138 		}
139 	}
140 
141 	public void fireIndexedPropertyChange( String propertyName, int index, int oldValue, int newValue )
142 	{
143 		try
144 		{
145 			propertyChangeSupport.fireIndexedPropertyChange( propertyName, index, oldValue, newValue );
146 		}
147 		catch( Throwable t )
148 		{
149 			SoapUI.logError( t );
150 		}
151 	}
152 
153 	public void fireIndexedPropertyChange( String propertyName, int index, Object oldValue, Object newValue )
154 	{
155 		try
156 		{
157 			propertyChangeSupport.fireIndexedPropertyChange( propertyName, index, oldValue, newValue );
158 		}
159 		catch( Throwable t )
160 		{
161 			SoapUI.logError( t );
162 		}
163 	}
164 
165 	@SuppressWarnings( "unchecked" )
166 	public List<? extends ModelItem> getChildren()
167 	{
168 		return Collections.EMPTY_LIST;
169 	}
170 
171 }