Program: 66305
Project: 66305
Buggy source:
private void initCalculationTypeCombo(String dimensionName){
  DimensionHandle handle=getCrosstabReportItemHandle().getCube().getDimension(dimensionName);
  boolean isStatic=true;
  if (recentButton.getSelection()) {
    isStatic=false;
  }
  times=TimeFunctionManager.getCalculationTypes(handle,getUseLevels(dimensionName),true);
  String[] items=new String[times.size()];
  String[] names=new String[times.size()];
  for (int i=0; i < times.size(); i++) {
    items[i]=times.get(i).getDisplayName();
    names[i]=times.get(i).getName();
  }
  calculationType.setItems(items);
  if (getBinding() == null) {
    calculationType.select(0);
    handleCalculationSelectEvent();
  }
 else {
    ITimeFunction function=getTimeFunctionByDisplaName(getBinding().getCalculationType());
    String name=function.getName();
    int itemIndex=getItemIndex(names,name);
    if (itemIndex >= 0) {
      calculationType.select(itemIndex);
    }
 else {
      calculationType.select(0);
    }
    handleCalculationSelectEvent();
    List<IArgumentInfo> infos=function.getArguments();
    for (int i=0; i < infos.size(); i++) {
      String argName=infos.get(i).getName();
      if (calculationParamsMap.containsKey(argName)) {
        if (getArgumentValue(getBinding(),argName) != null) {
          Control control=calculationParamsMap.get(argName);
          ExpressionHandle obj=(ExpressionHandle)getArgumentValue(getBinding(),argName);
          if (infos.get(i).getPeriodChoices() == null || infos.get(i).getPeriodChoices().isEmpty()) {
            initExpressionButtonControl(control,obj);
          }
 else {
            Combo combo=(Combo)control;
            String str=obj.getStringExpression();
            if (str == null || str.length() == 0) {
              combo.select(0);
            }
 else {
              int comboIndex=getItemIndex(combo.getItems(),str);
              if (comboIndex >= 0) {
                combo.select(comboIndex);
              }
 else {
                combo.select(0);
              }
            }
          }
        }
      }
    }
  }
}

Fixed version (ground truth):
private void initCalculationTypeCombo(String dimensionName){
  DimensionHandle handle=getCrosstabReportItemHandle().getCube().getDimension(dimensionName);
  String cal=calculationType.getText();
  isStatic=true;
  if (recentButton.getSelection()) {
    isStatic=false;
  }
  times=TimeFunctionManager.getCalculationTypes(handle,getUseLevels(dimensionName),isStatic);
  String[] items=new String[times.size()];
  String[] names=new String[times.size()];
  for (int i=0; i < times.size(); i++) {
    items[i]=times.get(i).getDisplayName();
    names[i]=times.get(i).getName();
  }
  calculationType.setItems(items);
  if (getBinding() == null) {
    if (cal != null && getItemIndex(items,cal) >= 0) {
      calculationType.select(getItemIndex(items,cal));
    }
 else {
      calculationType.select(0);
    }
    handleCalculationSelectEvent();
  }
 else {
    if (cal != null && getItemIndex(items,cal) >= 0) {
      calculationType.select(getItemIndex(items,cal));
    }
 else {
      ITimeFunction function=getTimeFunctionByDisplaName(getBinding().getCalculationType());
      String name=function.getName();
      int itemIndex=getItemIndex(names,name);
      if (itemIndex >= 0) {
        calculationType.select(itemIndex);
      }
 else {
        calculationType.select(0);
      }
    }
    handleCalculationSelectEvent();
    ITimeFunction function=getTimeFunctionByIndex(calculationType.getSelectionIndex());
    List<IArgumentInfo> infos=function.getArguments();
    for (int i=0; i < infos.size(); i++) {
      String argName=infos.get(i).getName();
      if (calculationParamsMap.containsKey(argName)) {
        if (getArgumentValue(getBinding(),argName) != null) {
          Control control=calculationParamsMap.get(argName);
          ExpressionHandle obj=(ExpressionHandle)getArgumentValue(getBinding(),argName);
          if (infos.get(i).getPeriodChoices() == null || infos.get(i).getPeriodChoices().isEmpty()) {
            initExpressionButtonControl(control,obj);
          }
 else {
            Combo combo=(Combo)control;
            String str=obj.getStringExpression();
            if (str == null || str.length() == 0) {
              combo.select(0);
            }
 else {
              int comboIndex=getItemIndex(combo.getItems(),str);
              if (comboIndex >= 0) {
                combo.select(comboIndex);
              }
 else {
                combo.select(0);
              }
            }
          }
        }
      }
    }
  }
}