package net.sf.jasperreports.engine.design;

import net.sf.jasperreports.engine.base.JRBaseSubreportReturnValue;
import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;

public class JRDesignSubreportReturnValue extends JRBaseSubreportReturnValue implements JRChangeEventsSupport {
  private static final long serialVersionUID = 10200L;
  
  public static final String PROPERTY_CALCULATION = "calculation";
  
  public static final String PROPERTY_INCREMENTER_FACTORY_CLASS_NAME = "incrementerFactoryClassName";
  
  public static final String PROPERTY_SUBREPORT_VARIABLE = "subreportVariable";
  
  public static final String PROPERTY_TO_VARIABLE = "toVariable";
  
  private transient JRPropertyChangeSupport eventSupport;
  
  public void setSubreportVariable(String name) {
    Object old = this.subreportVariable;
    this.subreportVariable = name;
    getEventSupport().firePropertyChange("subreportVariable", old, this.subreportVariable);
  }
  
  public void setToVariable(String name) {
    Object old = this.toVariable;
    this.toVariable = name;
    getEventSupport().firePropertyChange("toVariable", old, this.toVariable);
  }
  
  public void setCalculation(byte calculation) {
    byte old = this.calculation;
    this.calculation = calculation;
    getEventSupport().firePropertyChange("calculation", old, this.calculation);
  }
  
  public void setIncrementerFactoryClassName(String incrementerFactoryClassName) {
    Object old = this.incrementerFactoryClassName;
    this.incrementerFactoryClassName = incrementerFactoryClassName;
    getEventSupport().firePropertyChange("incrementerFactoryClassName", old, this.incrementerFactoryClassName);
  }
  
  public JRPropertyChangeSupport getEventSupport() {
    synchronized (this) {
      if (this.eventSupport == null)
        this.eventSupport = new JRPropertyChangeSupport(this); 
    } 
    return this.eventSupport;
  }
}
