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.impl.wsdl.panels.request.components.editor.inspectors;
14  
15  import java.beans.PropertyChangeListener;
16  import java.beans.PropertyChangeSupport;
17  
18  import javax.swing.ImageIcon;
19  
20  import com.eviware.soapui.impl.wsdl.panels.request.components.editor.XmlEditor;
21  import com.eviware.soapui.impl.wsdl.panels.request.components.editor.XmlInspector;
22  
23  /***
24   * Abstract base-class to be extended by XmlInspectors
25   * 
26   * @author ole.matzura
27   */
28  
29  public abstract class AbstractXmlInspector implements XmlInspector
30  {
31  	private final PropertyChangeSupport propertySupport;
32  	private String title;
33  	private String description;
34  	private boolean enabled;
35  	private XmlEditor editor;
36  	private final String inspectorId;
37  	private boolean active;
38  	
39  	protected AbstractXmlInspector( String title, String description, boolean enabled, String inspectorId )
40  	{
41  		this.title = title;
42  		this.description = description;
43  		this.enabled = enabled;
44  		this.inspectorId = inspectorId;
45  	
46  		propertySupport = new PropertyChangeSupport( this );
47  	}
48  	
49  	public final String getInspectorId()
50  	{
51  		return inspectorId;
52  	}
53  
54  	public void deactivate()
55  	{
56  		active = false;
57  	}
58  
59  	public ImageIcon getIcon()
60  	{
61  		return null;
62  	}
63  
64  	public void addPropertyChangeListener( PropertyChangeListener listener )
65  	{
66  		propertySupport.addPropertyChangeListener( listener );
67  	}
68  
69  	public void removePropertyChangeListener( PropertyChangeListener listener )
70  	{
71  		propertySupport.removePropertyChangeListener( listener );
72  	}
73  	
74  	public String getDescription()
75  	{
76  		return description;
77  	}
78  
79  	public String getTitle()
80  	{
81  		return title;
82  	}
83  
84  	public void setDescription( String description )
85  	{
86  		String oldDescription = this.description;
87  		this.description = description;
88  		propertySupport.firePropertyChange( DESCRIPTION_PROPERTY, oldDescription, description );
89  	}
90  
91  	public void setTitle( String title )
92  	{
93  		String oldTitle = this.title;
94  		this.title = title;
95  		propertySupport.firePropertyChange( TITLE_PROPERTY, oldTitle, title );
96  	}
97  
98  	public boolean isEnabled()
99  	{
100 		return enabled;
101 	}
102 
103 	public void setEnabled( boolean enabled )
104 	{
105 		boolean oldEnabled = this.enabled;
106 		this.enabled = enabled;
107 		propertySupport.firePropertyChange( ENABLED_PROPERTY, oldEnabled, enabled );
108 	}
109 
110 	public void init( XmlEditor editor )
111 	{
112 		this.editor = editor;
113 	}
114 
115 	public XmlEditor getEditor()
116 	{
117 		return editor;
118 	}
119 
120 	public void release()
121 	{
122 	}
123 
124 	public void activate()
125 	{
126 		active = true;
127 		getComponent().requestFocusInWindow();
128 	}
129 
130 	public boolean isActive()
131 	{
132 		return active;
133 	}
134 
135 	public boolean isContentHandler()
136 	{
137 		return false;
138 	}
139 }