package net.sf.jasperreports.crosstabs.design;

import net.sf.jasperreports.crosstabs.base.JRBaseCrosstabBucket;
import net.sf.jasperreports.engine.JRExpression;
import net.sf.jasperreports.engine.design.JRDesignExpression;
import net.sf.jasperreports.engine.design.events.JRChangeEventsSupport;
import net.sf.jasperreports.engine.design.events.JRPropertyChangeSupport;

public class JRDesignCrosstabBucket extends JRBaseCrosstabBucket implements JRChangeEventsSupport {
  private static final long serialVersionUID = 10200L;
  
  public static final String PROPERTY_COMPARATOR_EXPRESSION = "comparatorExpression";
  
  public static final String PROPERTY_EXPRESSION = "expression";
  
  public static final String PROPERTY_ORDER = "order";
  
  private transient JRPropertyChangeSupport eventSupport;
  
  public void setComparatorExpression(JRExpression comparatorExpression) {
    Object old = this.comparatorExpression;
    this.comparatorExpression = comparatorExpression;
    getEventSupport().firePropertyChange("comparatorExpression", old, this.comparatorExpression);
  }
  
  public void setExpression(JRDesignExpression expression) {
    Object old = this.expression;
    this.expression = (JRExpression)expression;
    getEventSupport().firePropertyChange("expression", old, this.expression);
  }
  
  public void setOrder(byte order) {
    byte old = this.order;
    this.order = order;
    getEventSupport().firePropertyChange("order", old, this.order);
  }
  
  public JRPropertyChangeSupport getEventSupport() {
    synchronized (this) {
      if (this.eventSupport == null)
        this.eventSupport = new JRPropertyChangeSupport(this); 
    } 
    return this.eventSupport;
  }
}
