1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.support.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.support.editor.Editor;
21 import com.eviware.soapui.support.editor.EditorLocation;
22 import com.eviware.soapui.support.editor.EditorView;
23 import com.eviware.soapui.support.editor.xml.XmlDocument;
24 import com.eviware.soapui.support.editor.xml.XmlEditor;
25 import com.eviware.soapui.support.editor.xml.XmlInspector;
26
27 /***
28 * Abstract base-class to be extended by XmlInspectors
29 *
30 * @author ole.matzura
31 */
32
33 public abstract class AbstractXmlInspector implements XmlInspector
34 {
35 private final PropertyChangeSupport propertySupport;
36 private String title;
37 private String description;
38 private boolean enabled;
39 private XmlEditor editor;
40 private final String inspectorId;
41 private boolean active;
42
43 protected AbstractXmlInspector( String title, String description, boolean enabled, String inspectorId )
44 {
45 this.title = title;
46 this.description = description;
47 this.enabled = enabled;
48 this.inspectorId = inspectorId;
49
50 propertySupport = new PropertyChangeSupport( this );
51 }
52
53 public final String getInspectorId()
54 {
55 return inspectorId;
56 }
57
58 public void deactivate()
59 {
60 active = false;
61 }
62
63 public ImageIcon getIcon()
64 {
65 return null;
66 }
67
68 public void addPropertyChangeListener( PropertyChangeListener listener )
69 {
70 propertySupport.addPropertyChangeListener( listener );
71 }
72
73 public void removePropertyChangeListener( PropertyChangeListener listener )
74 {
75 propertySupport.removePropertyChangeListener( listener );
76 }
77
78 public String getDescription()
79 {
80 return description;
81 }
82
83 public String getTitle()
84 {
85 return title;
86 }
87
88 public void setDescription( String description )
89 {
90 String oldDescription = this.description;
91 this.description = description;
92 propertySupport.firePropertyChange( DESCRIPTION_PROPERTY, oldDescription, description );
93 }
94
95 public void setTitle( String title )
96 {
97 String oldTitle = this.title;
98 this.title = title;
99 propertySupport.firePropertyChange( TITLE_PROPERTY, oldTitle, title );
100 }
101
102 public boolean isEnabled()
103 {
104 return enabled;
105 }
106
107 public void setEnabled( boolean enabled )
108 {
109 boolean oldEnabled = this.enabled;
110 this.enabled = enabled;
111 propertySupport.firePropertyChange( ENABLED_PROPERTY, oldEnabled, enabled );
112 }
113
114 public void init( Editor<XmlDocument> editor )
115 {
116 this.editor = (XmlEditor) editor;
117 }
118
119 public Editor<XmlDocument> getEditor()
120 {
121 return (Editor<XmlDocument>)editor;
122 }
123
124 public void release()
125 {
126 }
127
128 public void activate()
129 {
130 active = true;
131 getComponent().requestFocusInWindow();
132 }
133
134 public boolean isActive()
135 {
136 return active;
137 }
138
139 public boolean isContentHandler()
140 {
141 return false;
142 }
143
144 public void locationChanged( EditorLocation<XmlDocument> location )
145 {
146 }
147
148 public boolean isEnabledFor( EditorView<XmlDocument> view )
149 {
150 return false;
151 }
152 }