package net.sf.jasperreports.engine.design.events;

import java.beans.PropertyChangeSupport;

public class JRPropertyChangeSupport extends PropertyChangeSupport {
  private static final long serialVersionUID = 10200L;
  
  private Object sourceBean;
  
  public JRPropertyChangeSupport(Object sourceBean) {
    super(sourceBean);
    this.sourceBean = sourceBean;
  }
  
  public void fireCollectionElementAddedEvent(String propertyName, Object addedValue, int addedIndex) {
    firePropertyChange(new CollectionElementAddedEvent(this.sourceBean, propertyName, addedValue, addedIndex));
  }
  
  public void fireCollectionElementRemovedEvent(String propertyName, Object removedValue, int removedIndex) {
    firePropertyChange(new CollectionElementRemovedEvent(this.sourceBean, propertyName, removedValue, removedIndex));
  }
  
  public void firePropertyChange(String propertyName, float oldValue, float newValue) {
    if (oldValue == newValue)
      return; 
    firePropertyChange(propertyName, new Float(oldValue), new Float(newValue));
  }
  
  public void firePropertyChange(String propertyName, double oldValue, double newValue) {
    if (oldValue == newValue)
      return; 
    firePropertyChange(propertyName, new Double(oldValue), new Double(newValue));
  }
}
