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.model.support;
    14
    15  import java.awt.event.ActionEvent;
    16  import java.beans.PropertyChangeListener;
    17  import java.beans.PropertyChangeSupport;
    18
    19  import javax.swing.AbstractAction;
    20
    21  import com.eviware.soapui.model.ModelItem;
    22  import com.eviware.soapui.support.UISupport;
    23
    24  /***
    25   * Base-class for ModelItem implementations
    26   *
    27   * @author Ole.Matzura
    28   */
    29
    30  public abstract class AbstractModelItem implements ModelItem
    31  {
    32     private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport( this );
    33
    34     public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
    35     {
    36        propertyChangeSupport.addPropertyChangeListener( propertyName, listener );
    37     }
    38
    39     public void addPropertyChangeListener(PropertyChangeListener listener)
    40     {
    41        propertyChangeSupport.addPropertyChangeListener( listener );
    42     }
    43
    44     public void removePropertyChangeListener(PropertyChangeListener listener)
    45     {
    46        propertyChangeSupport.removePropertyChangeListener( listener );
    47     }
    48
    49     public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
    50  	{
    51     	propertyChangeSupport.removePropertyChangeListener( propertyName, listener );
    52  	}
    53
    54  	public void notifyPropertyChanged( String name, Object oldValue, Object newValue )
    55     {
    56        propertyChangeSupport.firePropertyChange( name, oldValue, newValue );
    57     }
    58
    59     public void notifyPropertyChanged( String name, int oldValue, int newValue )
    60     {
    61        propertyChangeSupport.firePropertyChange( name, oldValue, newValue );
    62     }
    63
    64     public void notifyPropertyChanged( String name, boolean oldValue, boolean newValue )
    65     {
    66        propertyChangeSupport.firePropertyChange( name, oldValue, newValue );
    67     }
    68
    69  	public class ShowModelItemAction extends AbstractAction
    70  	{
    71  		public ShowModelItemAction()
    72  		{
    73  			super("Show Editor");
    74  		}
    75
    76  		public void actionPerformed(ActionEvent e)
    77  		{
    78  			UISupport.selectAndShow( AbstractModelItem.this );
    79  		}
    80  	}
    81  }