Program: 118894
Project: 118894
Buggy source:
/** 
 * DOC ycbai Comment method "loadParametersFromForm". <p> Get element parameters of <code>element</code> from <code>form</code>.
 * @param element
 * @param category
 * @param form
 * @return parameters list
 */
public static List<ElementParameter> getParametersFromForm(IElement element,EComponentCategory category,Form form,ElementParameter parentParam,AtomicInteger lastRowNum){
  List<ElementParameter> elementParameters=new ArrayList<>();
  if (category == null) {
    category=EComponentCategory.BASIC;
  }
  if (lastRowNum == null) {
    lastRowNum=new AtomicInteger();
  }
  ComponentProperties compProperties=form.getProperties();
  compProperties.getProperties();
  List<Widget> formWidgets=form.getWidgets();
  for (  Widget widget : formWidgets) {
    ElementParameter param=new GenericElementParameter(element,compProperties,widget,getComponentService());
    if (parentParam != null) {
      param.setParentParameter(parentParam);
    }
    param.setCategory(category);
    NamedThing[] widgetProperties=widget.getProperties();
    NamedThing widgetProperty=widgetProperties[0];
    param.setName(widgetProperty.getName());
    param.setDisplayName(widgetProperty.getDisplayName());
    if (parentParam != null) {
    }
    param.setShow(parentParam == null ? widget.isVisible() : parentParam.isShow(null) && widget.isVisible());
    int rowNum=widget.getRow();
    if (parentParam != null) {
      rowNum+=parentParam.getNumRow();
    }
    rowNum=rowNum + lastRowNum.get();
    param.setNumRow(rowNum);
    lastRowNum.set(rowNum);
    if (widgetProperty instanceof Form) {
      elementParameters.addAll(getParametersFromForm(element,category,(Form)widgetProperty,param,lastRowNum));
      continue;
    }
    SchemaElement se=null;
    if (widgetProperty instanceof SchemaElement) {
      se=(SchemaElement)widgetProperties[0];
    }
    EParameterFieldType fieldType=null;
switch (widget.getWidgetType()) {
case DEFAULT:
      if (se == null) {
        fieldType=EParameterFieldType.LABEL;
        param.setValue(widgetProperty.getDisplayName());
        break;
      }
switch (se.getType()) {
case BOOLEAN:
      fieldType=EParameterFieldType.CHECK;
    break;
case BYTE_ARRAY:
  fieldType=EParameterFieldType.TEXT;
break;
case DATE:
fieldType=EParameterFieldType.DATE;
break;
case DATETIME:
fieldType=EParameterFieldType.DATE;
break;
case DECIMAL:
fieldType=EParameterFieldType.TEXT;
break;
case DOUBLE:
fieldType=EParameterFieldType.TEXT;
break;
case DYNAMIC:
fieldType=EParameterFieldType.TEXT;
break;
case ENUM:
fieldType=EParameterFieldType.CLOSED_LIST;
break;
case FLOAT:
fieldType=EParameterFieldType.TEXT;
break;
case INT:
fieldType=EParameterFieldType.TEXT;
break;
case SCHEMA:
fieldType=EParameterFieldType.SCHEMA_TYPE;
break;
case STRING:
fieldType=EParameterFieldType.TEXT;
break;
default :
fieldType=EParameterFieldType.TEXT;
break;
}
break;
case BUTTON:
fieldType=EParameterFieldType.TEXT;
break;
case COMPONENT_REFERENCE:
break;
case NAME_SELECTION_AREA:
break;
case NAME_SELECTION_REFERENCE:
break;
case SCHEMA_EDITOR:
break;
case SCHEMA_REFERENCE:
fieldType=EParameterFieldType.SCHEMA_TYPE;
break;
default :
break;
}
param.setFieldType(fieldType);
if (se != null) {
param.setRequired(se.isRequired());
param.setValue(compProperties.getValue(se));
Collection values=se.getPossibleValues();
if (values != null) {
List<String> possVals=new ArrayList<>();
for (Object obj : values) {
possVals.add(String.valueOf(obj));
}
String[] valArray=possVals.toArray(new String[0]);
param.setListItemsDisplayName(valArray);
param.setListItemsDisplayCodeName(valArray);
param.setListItemsValue(valArray);
}
}
param.setReadOnly(false);
elementParameters.add(param);
}
return elementParameters;
}

Fixed version (ground truth):
/** 
 * DOC ycbai Comment method "loadParametersFromForm". <p> Get element parameters of <code>element</code> from <code>form</code>.
 * @param element
 * @param category
 * @param form
 * @return parameters list
 */
public static List<ElementParameter> getParametersFromForm(IElement element,EComponentCategory category,Form form,ElementParameter parentParam,AtomicInteger lastRowNum){
  List<ElementParameter> elementParameters=new ArrayList<>();
  if (category == null) {
    category=EComponentCategory.BASIC;
  }
  if (lastRowNum == null) {
    lastRowNum=new AtomicInteger();
  }
  ComponentProperties compProperties=form.getProperties();
  compProperties.getProperties();
  List<Widget> formWidgets=form.getWidgets();
  for (  Widget widget : formWidgets) {
    ElementParameter param=new GenericElementParameter(element,compProperties,widget,getComponentService());
    if (parentParam != null) {
      param.setParentParameter(parentParam);
    }
    param.setCategory(category);
    NamedThing[] widgetProperties=widget.getProperties();
    NamedThing widgetProperty=widgetProperties[0];
    param.setName(widgetProperty.getName());
    param.setDisplayName(widgetProperty.getDisplayName());
    if (parentParam != null) {
    }
    param.setShow(parentParam == null ? widget.isVisible() : parentParam.isShow(null) && widget.isVisible());
    int rowNum=0;
    if (widget.getOrder() != 1) {
      rowNum=lastRowNum.get();
    }
 else {
      rowNum=widget.getRow();
      if (parentParam != null) {
        rowNum+=parentParam.getNumRow();
      }
      rowNum=rowNum + lastRowNum.get();
    }
    param.setNumRow(rowNum);
    lastRowNum.set(rowNum);
    if (widgetProperty instanceof Form) {
      elementParameters.addAll(getParametersFromForm(element,category,(Form)widgetProperty,param,lastRowNum));
      continue;
    }
    SchemaElement se=null;
    if (widgetProperty instanceof SchemaElement) {
      se=(SchemaElement)widgetProperties[0];
    }
    EParameterFieldType fieldType=null;
switch (widget.getWidgetType()) {
case DEFAULT:
      if (se == null) {
        fieldType=EParameterFieldType.LABEL;
        param.setValue(widgetProperty.getDisplayName());
        break;
      }
switch (se.getType()) {
case BOOLEAN:
      fieldType=EParameterFieldType.CHECK;
    break;
case BYTE_ARRAY:
  fieldType=EParameterFieldType.TEXT;
break;
case DATE:
fieldType=EParameterFieldType.DATE;
break;
case DATETIME:
fieldType=EParameterFieldType.DATE;
break;
case DECIMAL:
fieldType=EParameterFieldType.TEXT;
break;
case DOUBLE:
fieldType=EParameterFieldType.TEXT;
break;
case DYNAMIC:
fieldType=EParameterFieldType.TEXT;
break;
case ENUM:
fieldType=EParameterFieldType.CLOSED_LIST;
break;
case FLOAT:
fieldType=EParameterFieldType.TEXT;
break;
case INT:
fieldType=EParameterFieldType.TEXT;
break;
case SCHEMA:
fieldType=EParameterFieldType.SCHEMA_TYPE;
break;
case STRING:
fieldType=EParameterFieldType.TEXT;
break;
default :
fieldType=EParameterFieldType.TEXT;
break;
}
break;
case BUTTON:
fieldType=EParameterFieldType.BUTTON;
break;
case COMPONENT_REFERENCE:
break;
case NAME_SELECTION_AREA:
break;
case NAME_SELECTION_REFERENCE:
break;
case SCHEMA_EDITOR:
break;
case SCHEMA_REFERENCE:
fieldType=EParameterFieldType.SCHEMA_TYPE;
break;
default :
break;
}
param.setFieldType(fieldType);
if (se != null) {
param.setRequired(se.isRequired());
param.setValue(compProperties.getValue(se));
Collection values=se.getPossibleValues();
if (values != null) {
List<String> possVals=new ArrayList<>();
for (Object obj : values) {
possVals.add(String.valueOf(obj));
}
String[] valArray=possVals.toArray(new String[0]);
param.setListItemsDisplayName(valArray);
param.setListItemsDisplayCodeName(valArray);
param.setListItemsValue(valArray);
}
}
param.setReadOnly(false);
elementParameters.add(param);
}
return elementParameters;
}