Program: 145565
Project: 145565
Buggy source:
/** 
 * @param aParent Columns group, with will be parentfor new groups.
 * @param aContents A list of used as a source for columns groups.
 * @param linkSource Wether to link new column groups with sourceDbGridColumn-s. This also means, that LinkedGridColumnsGroup will be created.
 * @return
 * @throws Exception
 */
private Map<TableColumn,GridColumnsGroup> fillColumnsGroup(GridColumnsGroup aParent,List<DbGridColumn> aContents,boolean linkSource) throws Exception {
  Map<TableColumn,GridColumnsGroup> groups=new HashMap<>();
  for (  DbGridColumn dCol : aContents) {
    GridColumnsGroup group;
    if (linkSource) {
      group=new LinkedGridColumnsGroup(dCol);
    }
 else {
      group=new GridColumnsGroup();
    }
    dCol.initializeGridColumnsGroup(group);
    if (aParent != null) {
      group.setParent(aParent);
      aParent.addChild(group);
    }
    if (dCol.hasChildren()) {
      Map<TableColumn,GridColumnsGroup> childGroups=fillColumnsGroup(group,dCol.getChildren(),linkSource);
      groups.putAll(childGroups);
    }
 else {
      if (dCol instanceof FixedDbGridColumn) {
        TableColumn tCol=new RowHeaderTableColumn(dCol.getWidth());
        tCol.setCellRenderer(new RowHeaderCellRenderer(((FixedDbGridColumn)dCol).getHeaderType()));
        tCol.setCellEditor(new RowHeaderCellEditor(((FixedDbGridColumn)dCol).getHeaderType()));
        tCol.setMinWidth(dCol.getWidth());
        tCol.setPreferredWidth(dCol.getWidth());
        tCol.setMaxWidth(dCol.getWidth());
        tCol.setHeaderValue("String_Node_Str");
        group.setTableColumn(tCol);
        group.setMoveable(false);
        group.setResizeable(false);
        group.setSortable(false);
        groups.put(tCol,group);
        columnModel.addColumn(tCol);
      }
 else {
        if (dCol.isPlain()) {
          Rowset rs=DbControlsUtils.resolveRowset(model,dCol.getDatamodelElement());
          int fidx=DbControlsUtils.resolveFieldIndex(model,dCol.getDatamodelElement());
          if (fidx < 1) {
            if (dCol.getDatamodelElement() != null) {
              Logger.getLogger(DbGrid.class.getName()).log(Level.SEVERE,"String_Node_Str" + dCol.getName() + "String_Node_Str");
            }
          }
          FieldModelColumn mCol=new FieldModelColumn(rs,fidx,getHandler(dCol.getCellFunction()),getHandler(dCol.getSelectFunction()),group.isReadonly(),new HasStyle(){
            @Override public CascadedStyle getStyle(){
              return style;
            }
          }
,null,null);
          rowsModel.addColumn(mCol);
          TableColumn tCol=new TableColumn(rowsModel.getColumnCount() - 1);
          tCol.setMinWidth(group.getMinWidth());
          tCol.setMaxWidth(group.getMaxWidth());
          tCol.setPreferredWidth(dCol.getWidth());
          tCol.setWidth(dCol.getWidth());
          tCol.setResizable(!dCol.isFixed());
          if (dCol.getControlInfo() != null) {
            TableCellRenderer cellRenderer=dCol.createCellRenderer();
            tCol.setCellRenderer(cellRenderer);
            if (cellRenderer instanceof ScalarDbControl) {
              ((ScalarDbControl)cellRenderer).setModel(model);
              mCol.setView((ScalarDbControl)cellRenderer);
            }
            TableCellEditor cellEditor=dCol.createCellEditor();
            tCol.setCellEditor(cellEditor);
            if (cellEditor instanceof ScalarDbControl) {
              Field field=DbControlsUtils.resolveField(model,dCol.getDatamodelElement());
              ((ScalarDbControl)cellEditor).setModel(model);
              ((ScalarDbControl)cellEditor).extraCellControls(getHandler(dCol != null ? dCol.getSelectFunction() : null),field != null ? field.isNullable() : false);
              mCol.setEditor((ScalarDbControl)cellEditor);
            }
          }
          String title=group.getTitle();
          if (title == null || title.isEmpty()) {
            title=group.getName();
          }
          tCol.setHeaderValue(title);
          tCol.setIdentifier(mCol);
          group.setTableColumn(tCol);
          group.setResizeable(tCol.getResizable());
          groups.put(tCol,group);
          columnModel.addColumn(tCol);
          scriptableColumns.add(new ScriptableColumn(dCol,mCol,tCol,columnModel.getColumnCount() - 1,columnModel,rowsModel,groups));
        }
 else {
          Rowset colsRs=DbControlsUtils.resolveRowset(model,dCol.getColumnsDatasource());
          int colTitleColIdx=DbControlsUtils.resolveFieldIndex(model,dCol.getColumnsDisplayField());
          Rowset cellsRs=DbControlsUtils.resolveRowset(model,dCol.getCellsDatasource());
          int cellsRowKeyIdx=DbControlsUtils.resolveFieldIndex(model,dCol.getCellDesignInfo().getRowsKeyField());
          int cellsColumKeyIdx=DbControlsUtils.resolveFieldIndex(model,dCol.getCellDesignInfo().getColumnsKeyField());
          Rowset cellsValuesRs=DbControlsUtils.resolveRowset(model,dCol.getCellDesignInfo().getCellValueField());
          int cellsValuesFieldIdx=DbControlsUtils.resolveFieldIndex(model,dCol.getCellDesignInfo().getCellValueField());
          if (colsRs != null && cellsRs != null && cellsValuesRs != null && colTitleColIdx != 0 && cellsRowKeyIdx != 0 && cellsColumKeyIdx != 0 && cellsValuesFieldIdx != 0) {
            Locator colsLoc=createPksLocator(colsRs);
            Locator cellsLoc=cellsRs.createLocator();
            cellsLoc.beginConstrainting();
            try {
              cellsLoc.addConstraint(cellsRowKeyIdx);
              cellsLoc.addConstraint(cellsColumKeyIdx);
            }
  finally {
              cellsLoc.endConstrainting();
            }
            AnchorTableColumn anchorCol=new AnchorTableColumn(0);
            String title=group.getTitle();
            if (title == null || title.isEmpty()) {
              title=group.getName();
            }
            anchorCol.setHeaderValue(title);
            anchorCol.setMinWidth(0);
            anchorCol.setPreferredWidth(0);
            anchorCol.setMaxWidth(0);
            anchorCol.setWidth(0);
            ColumnsSource cs=new ColumnsSource(group,anchorCol,colsLoc,colTitleColIdx,cellsLoc,cellsValuesRs,cellsValuesFieldIdx,new VeerColumnsHandler(model,dCol),getHandler(dCol.getCellFunction()),getHandler(dCol.getSelectFunction()));
            anchorCol.setColumnsSource(cs);
            columnModel.addColumn(anchorCol);
          }
        }
      }
    }
  }
  return groups;
}

Fixed version (ground truth):
/** 
 * @param aParent Columns group, with will be parentfor new groups.
 * @param aContents A list of used as a source for columns groups.
 * @param linkSource Wether to link new column groups with sourceDbGridColumn-s. This also means, that LinkedGridColumnsGroup will be created.
 * @return
 * @throws Exception
 */
private Map<TableColumn,GridColumnsGroup> fillColumnsGroup(GridColumnsGroup aParent,List<DbGridColumn> aContents,boolean linkSource) throws Exception {
  Map<TableColumn,GridColumnsGroup> groups=new HashMap<>();
  for (  DbGridColumn dCol : aContents) {
    GridColumnsGroup group;
    if (linkSource) {
      group=new LinkedGridColumnsGroup(dCol);
    }
 else {
      group=new GridColumnsGroup();
    }
    dCol.initializeGridColumnsGroup(group);
    if (aParent != null) {
      group.setParent(aParent);
      aParent.addChild(group);
    }
    if (dCol.hasChildren()) {
      Map<TableColumn,GridColumnsGroup> childGroups=fillColumnsGroup(group,dCol.getChildren(),linkSource);
      groups.putAll(childGroups);
    }
 else {
      if (dCol instanceof FixedDbGridColumn) {
        TableColumn tCol=new RowHeaderTableColumn(dCol.getWidth());
        tCol.setCellRenderer(new RowHeaderCellRenderer(((FixedDbGridColumn)dCol).getHeaderType()));
        tCol.setCellEditor(new RowHeaderCellEditor(((FixedDbGridColumn)dCol).getHeaderType()));
        tCol.setMinWidth(dCol.getWidth());
        tCol.setPreferredWidth(dCol.getWidth());
        tCol.setMaxWidth(dCol.getWidth());
        tCol.setHeaderValue("String_Node_Str");
        group.setTableColumn(tCol);
        group.setMoveable(false);
        group.setResizeable(false);
        group.setSortable(false);
        groups.put(tCol,group);
        columnModel.addColumn(tCol);
      }
 else {
        if (dCol.isPlain()) {
          Rowset rs=DbControlsUtils.resolveRowset(model,dCol.getDatamodelElement());
          int fidx=DbControlsUtils.resolveFieldIndex(model,dCol.getDatamodelElement());
          if (fidx < 1) {
            if (dCol.getDatamodelElement() != null) {
              Logger.getLogger(DbGrid.class.getName()).log(Level.SEVERE,"String_Node_Str",dCol.getName());
            }
          }
          FieldModelColumn mCol=new FieldModelColumn(rs,fidx,getHandler(dCol.getCellFunction()),getHandler(dCol.getSelectFunction()),group.isReadonly(),new HasStyle(){
            @Override public CascadedStyle getStyle(){
              return style;
            }
          }
,null,null);
          rowsModel.addColumn(mCol);
          TableColumn tCol=new TableColumn(rowsModel.getColumnCount() - 1);
          tCol.setMinWidth(group.getMinWidth());
          tCol.setMaxWidth(group.getMaxWidth());
          tCol.setPreferredWidth(dCol.getWidth());
          tCol.setWidth(dCol.getWidth());
          tCol.setResizable(!dCol.isFixed());
          if (dCol.getControlInfo() != null) {
            TableCellRenderer cellRenderer=dCol.createCellRenderer();
            tCol.setCellRenderer(cellRenderer);
            if (cellRenderer instanceof ScalarDbControl) {
              ((ScalarDbControl)cellRenderer).setModel(model);
              mCol.setView((ScalarDbControl)cellRenderer);
            }
            TableCellEditor cellEditor=dCol.createCellEditor();
            tCol.setCellEditor(cellEditor);
            if (cellEditor instanceof ScalarDbControl) {
              Field field=DbControlsUtils.resolveField(model,dCol.getDatamodelElement());
              ((ScalarDbControl)cellEditor).setModel(model);
              ((ScalarDbControl)cellEditor).extraCellControls(getHandler(dCol.getSelectFunction()),field != null ? field.isNullable() : false);
              mCol.setEditor((ScalarDbControl)cellEditor);
            }
          }
          String title=group.getTitle();
          if (title == null || title.isEmpty()) {
            title=group.getName();
          }
          tCol.setHeaderValue(title);
          tCol.setIdentifier(mCol);
          group.setTableColumn(tCol);
          group.setResizeable(tCol.getResizable());
          groups.put(tCol,group);
          columnModel.addColumn(tCol);
          scriptableColumns.add(new ScriptableColumn(dCol,mCol,tCol,columnModel.getColumnCount() - 1,columnModel,rowsModel,groups));
        }
 else {
          Rowset colsRs=DbControlsUtils.resolveRowset(model,dCol.getColumnsDatasource());
          int colTitleColIdx=DbControlsUtils.resolveFieldIndex(model,dCol.getColumnsDisplayField());
          Rowset cellsRs=DbControlsUtils.resolveRowset(model,dCol.getCellsDatasource());
          int cellsRowKeyIdx=DbControlsUtils.resolveFieldIndex(model,dCol.getCellDesignInfo().getRowsKeyField());
          int cellsColumKeyIdx=DbControlsUtils.resolveFieldIndex(model,dCol.getCellDesignInfo().getColumnsKeyField());
          Rowset cellsValuesRs=DbControlsUtils.resolveRowset(model,dCol.getCellDesignInfo().getCellValueField());
          int cellsValuesFieldIdx=DbControlsUtils.resolveFieldIndex(model,dCol.getCellDesignInfo().getCellValueField());
          if (colsRs != null && cellsRs != null && cellsValuesRs != null && colTitleColIdx != 0 && cellsRowKeyIdx != 0 && cellsColumKeyIdx != 0 && cellsValuesFieldIdx != 0) {
            Locator colsLoc=createPksLocator(colsRs);
            Locator cellsLoc=cellsRs.createLocator();
            cellsLoc.beginConstrainting();
            try {
              cellsLoc.addConstraint(cellsRowKeyIdx);
              cellsLoc.addConstraint(cellsColumKeyIdx);
            }
  finally {
              cellsLoc.endConstrainting();
            }
            AnchorTableColumn anchorCol=new AnchorTableColumn(0);
            String title=group.getTitle();
            if (title == null || title.isEmpty()) {
              title=group.getName();
            }
            anchorCol.setHeaderValue(title);
            anchorCol.setMinWidth(0);
            anchorCol.setPreferredWidth(0);
            anchorCol.setMaxWidth(0);
            anchorCol.setWidth(0);
            ColumnsSource cs=new ColumnsSource(group,anchorCol,colsLoc,colTitleColIdx,cellsLoc,cellsValuesRs,cellsValuesFieldIdx,new VeerColumnsHandler(model,dCol),getHandler(dCol.getCellFunction()),getHandler(dCol.getSelectFunction()));
            anchorCol.setColumnsSource(cs);
            columnModel.addColumn(anchorCol);
          }
        }
      }
    }
  }
  return groups;
}