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
    38  	protected AbstractXmlInspector( String title, String description, boolean enabled, String inspectorId )
    39  	{
    40  		this.title = title;
    41  		this.description = description;
    42  		this.enabled = enabled;
    43  		this.inspectorId = inspectorId;
    44
    45  		propertySupport = new PropertyChangeSupport( this );
    46  	}
    47
    48  	public final String getInspectorId()
    49  	{
    50  		return inspectorId;
    51  	}
    52
    53  	public void deactivate()
    54  	{
    55  	}
    56
    57  	public ImageIcon getIcon()
    58  	{
    59  		return null;
    60  	}
    61
    62  	public void addPropertyChangeListener( PropertyChangeListener listener )
    63  	{
    64  		propertySupport.addPropertyChangeListener( listener );
    65  	}
    66
    67  	public void removePropertyChangeListener( PropertyChangeListener listener )
    68  	{
    69  		propertySupport.removePropertyChangeListener( listener );
    70  	}
    71
    72  	public String getDescription()
    73  	{
    74  		return description;
    75  	}
    76
    77  	public String getTitle()
    78  	{
    79  		return title;
    80  	}
    81
    82  	public void setDescription( String description )
    83  	{
    84  		String oldDescription = this.description;
    85  		this.description = description;
    86  		propertySupport.firePropertyChange( DESCRIPTION_PROPERTY, oldDescription, description );
    87  	}
    88
    89  	public void setTitle( String title )
    90  	{
    91  		String oldTitle = this.title;
    92  		this.title = title;
    93  		propertySupport.firePropertyChange( TITLE_PROPERTY, oldTitle, title );
    94  	}
    95
    96  	public boolean isEnabled()
    97  	{
    98  		return enabled;
    99  	}
    100
    101 	public void setEnabled( boolean enabled )
    102 	{
    103 		boolean oldEnabled = this.enabled;
    104 		this.enabled = enabled;
    105 		propertySupport.firePropertyChange( ENABLED_PROPERTY, oldEnabled, enabled );
    106 	}
    107
    108 	public void init( XmlEditor editor )
    109 	{
    110 		this.editor = editor;
    111 	}
    112
    113 	public XmlEditor getEditor()
    114 	{
    115 		return editor;
    116 	}
    117
    118 	public void release()
    119 	{
    120 	}
    121
    122 	public void activate()
    123 	{
    124 		getComponent().requestFocusInWindow();
    125 	}
    126 }