package org.pentaho.ui.xul.util;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

import org.pentaho.ui.xul.XulEventSource;

public class ViewModel implements XulEventSource{

  protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
  
  public void addPropertyChangeListener(PropertyChangeListener listener) {
    changeSupport.addPropertyChangeListener(listener);
  }

  public void removePropertyChangeListener(PropertyChangeListener listener) {
    changeSupport.removePropertyChangeListener(listener);
  }
  
  protected void firePropertyChange(String attr, Object previousVal, Object newVal){
    if(previousVal == null && newVal == null){
      return;
    }
    changeSupport.firePropertyChange(attr, previousVal, newVal);
  }
}

  
@@ -438,16 +438,192 @@
 );%0D%0A  %7D%0D
+%0A  %0D%0A  public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) %7B%0D%0A    changeSupport.addPropertyChangeListener(propertyName, listener);%0D%0A  %7D%0D
 %0A%0D%0A  pub

add a property change accessor