public boolean dataNew(int currentRow,boolean copyCurrent){
  log.info("Current=" + currentRow + ", Copy="+ copyCurrent);
  if (m_readOnly) {
    fireDataStatusEEvent("AccessCannotInsert","",true);
    return false;
  }
  dataSave(-2,false);
  m_inserting=true;
  int size=m_fields.size();
  m_rowData=new Object[size];
  Object[] rowData=new Object[size];
  m_changed=true;
  m_compareDB=true;
  m_newRow=currentRow + 1;
  if (m_sort.size() < m_newRow)   m_newRow=m_sort.size();
  MSort newSort=m_virtual ? new MSort(NEW_ROW_ID,null) : new MSort(m_sort.size(),null);
  if (m_virtual) {
    m_virtualBuffer.put(NEW_ROW_ID,rowData);
  }
 else {
    m_buffer.add(rowData);
  }
  m_sort.add(m_newRow,newSort);
  m_rowCount++;
  if (copyCurrent) {
    boolean hasDocTypeTargetField=(getField("C_DocTypeTarget_ID") != null);
    Object[] origData=getDataAtRow(currentRow);
    for (int i=0; i < size; i++) {
      GridField field=(GridField)m_fields.get(i);
      String columnName=field.getColumnName();
      if (field.isVirtualColumn())       ;
 else       if (field.isKey() || columnName.equals("AD_Client_ID") || columnName.startsWith("Created")|| columnName.startsWith("Updated")|| columnName.equals("EntityType")|| columnName.equals("DocumentNo")|| columnName.equals("Processed")|| columnName.equals("IsSelfService")|| columnName.equals("DocAction")|| columnName.equals("DocStatus")|| columnName.equals("Posted")|| columnName.equals("IsReconciled")|| columnName.equals("IsApproved")|| columnName.equals("IsGenerated")|| columnName.startsWith("Ref_")|| columnName.equals("GrandTotal")|| columnName.equals("TotalLines")|| columnName.equals("C_CashLine_ID")|| columnName.equals("C_Payment_ID")|| columnName.equals("IsPaid")|| columnName.equals("IsAllocated")|| (columnName.equals("C_DocType_ID") && hasDocTypeTargetField)|| (columnName.equals("Line") || !field.IsAllowCopy())) {
        rowData[i]=field.getDefault();
        field.setValue(rowData[i],m_inserting);
      }
 else       rowData[i]=origData[i];
    }
  }
 else {
    for (int i=0; i < size; i++) {
      GridField field=(GridField)m_fields.get(i);
      rowData[i]=field.getDefault();
      field.setValue(rowData[i],m_inserting);
    }
  }
  m_rowChanged=-1;
  log.fine("Current=" + currentRow + ", New="+ m_newRow);
  fireTableRowsInserted(m_newRow,m_newRow);
  fireDataStatusIEvent(copyCurrent ? "UpdateCopied" : "Inserted","");
  log.fine("Current=" + currentRow + ", New="+ m_newRow+ " - complete");
  return true;
}

public boolean dataNew ( int currentRow , boolean copyCurrent ) { log . info ( "Current=" + currentRow + ", Copy=" + copyCurrent ) ; if ( m_readOnly ) { fireDataStatusEEvent ( "AccessCannotInsert" , "" , true ) ; return false ; } dataSave ( - 2 , false ) ; m_inserting = true ; int size = m_fields . size ( ) ; m_rowData = new Object [ size ] ; Object [ ] rowData = new Object [ size ] ; m_changed = true ; m_compareDB = true ; m_newRow = currentRow + 1 ; if ( m_sort . size ( ) < m_newRow ) m_newRow = m_sort . size ( ) ; MSort newSort = m_virtual ? new MSort ( NEW_ROW_ID , null ) : new MSort ( m_sort . size ( ) , null ) ; if ( m_virtual ) { m_virtualBuffer . put ( NEW_ROW_ID , rowData ) ; } else { m_buffer . add ( rowData ) ; } m_sort . add ( m_newRow , newSort ) ; m_rowCount ++ ; if ( copyCurrent ) { boolean hasDocTypeTargetField = ( getField ( "C_DocTypeTarget_ID" ) != null ) ; Object [ ] origData = getDataAtRow ( currentRow ) ; for ( int i = 0 ; i < size ; i ++ ) { GridField field = ( GridField ) m_fields . get ( i ) ; String columnName = field . getColumnName ( ) ; if ( field . isVirtualColumn ( ) ) ; else if ( field . isKey ( ) || columnName . equals ( "AD_Client_ID" ) || columnName . startsWith ( "Created" ) || columnName . startsWith ( "Updated" ) || columnName . equals ( "EntityType" ) || columnName . equals ( "DocumentNo" ) || columnName . equals ( "Processed" ) || columnName . equals ( "IsSelfService" ) || columnName . equals ( "DocAction" ) || columnName . equals ( "DocStatus" ) || columnName . equals ( "Posted" ) || columnName . equals ( "IsReconciled" ) || columnName . equals ( "IsApproved" ) || columnName . equals ( "IsGenerated" ) || columnName . startsWith ( "Ref_" ) || columnName . equals ( "GrandTotal" ) || columnName . equals ( "TotalLines" ) || columnName . equals ( "C_CashLine_ID" ) || columnName . equals ( "C_Payment_ID" ) || columnName . equals ( "IsPaid" ) || columnName . equals ( "IsAllocated" ) || ( columnName . equals ( "C_DocType_ID" ) && hasDocTypeTargetField ) || ( columnName . equals ( "Line" ) || ! field . IsAllowCopy ( ) ) ) { rowData [ i ] = field . getDefault ( ) ; field . setValue ( rowData [ i ] , m_inserting ) ; } else rowData [ i ] = origData [ i ] ; } } else { for ( int i = 0 ; i < size ; i ++ ) { GridField field = ( GridField ) m_fields . get ( i ) ; rowData [ i ] = field . getDefault ( ) ; field . setValue ( rowData [ i ] , m_inserting ) ; } } m_rowChanged = - 1 ; log . fine ( "Current=" + currentRow + ", New=" + m_newRow ) ; fireTableRowsInserted ( m_newRow , m_newRow ) ; fireDataStatusIEvent ( copyCurrent ? "UpdateCopied" : "Inserted" , "" ) ; log . fine ( "Current=" + currentRow + ", New=" + m_newRow + " - complete" ) ; return true ; }
new record after current row
