Program: 65809
Project: 65809
Buggy source:
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();
      String argValue=calculationParamsValueMap.get(argName);
      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);
              }
            }
          }
          if (control instanceof Text && argValue != null) {
            ((Text)control).setText(argValue);
          }
        }
      }
    }
  }
}

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());
      if (function == null) {
        return;
      }
      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();
      String argValue=calculationParamsValueMap.get(argName);
      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);
              }
            }
          }
          if (control instanceof Text && argValue != null) {
            ((Text)control).setText(argValue);
          }
        }
      }
    }
  }
}