View Javadoc

1   /*
2    *  soapUI, copyright (C) 2004-2009 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.impl.wsdl.panels.teststeps.support;
14  
15  import java.beans.PropertyChangeListener;
16  import java.beans.PropertyChangeSupport;
17  
18  import javax.swing.Action;
19  
20  import com.eviware.soapui.model.settings.Settings;
21  
22  public abstract class AbstractGroovyEditorModel implements GroovyEditorModel
23  {
24  	private final String[] keywords;
25  	private final Settings settings;
26  	private Action runAction;
27  	private final String name;
28  	
29  	private PropertyChangeSupport propertyChangeSupport;
30  
31  	public AbstractGroovyEditorModel( String[] keywords, Settings settings, String name )
32  	{
33  		this.keywords = keywords;
34  		this.settings = settings;
35  		this.name = name;
36  
37  		runAction = createRunAction();
38  		
39  		propertyChangeSupport = new PropertyChangeSupport( this );
40  	}
41  
42  	public String[] getKeywords()
43  	{
44  		return keywords;
45  	}
46  
47  	public Action getRunAction()
48  	{
49  		return runAction;
50  	}
51  
52  	public Action createRunAction()
53  	{
54  		return null;
55  	}
56  
57  	public abstract String getScript();
58  
59  	public Settings getSettings()
60  	{
61  		return settings;
62  	}
63  
64  	public abstract void setScript( String text );
65  
66  	public String getScriptName()
67  	{
68  		return name;
69  	}
70  
71  	public void addPropertyChangeListener( PropertyChangeListener listener )
72  	{
73  		propertyChangeSupport.addPropertyChangeListener( listener );
74  	}
75  
76  	public void removePropertyChangeListener( PropertyChangeListener listener )
77  	{
78  		propertyChangeSupport.removePropertyChangeListener( listener );
79  	}
80  	
81  	public void notifyPropertyChanged( String name, Object oldValue, Object newValue )
82  	{
83  		propertyChangeSupport.firePropertyChange( name, oldValue, newValue );
84  	}
85  }