public Record makeDefaultAnalysisRecord ( Record recBasis ) { // Set one up from scratch using the output params Record recSummary = new AnalysisRecord ( this ) ; KeyArea keyArea = recSummary . makeIndex ( DBConstants . UNIQUE , "SummaryKey" ) ; boolean bAddKeyField = true ; for ( int i = 0 ; i < this . getSourceFieldCount ( ) ; i ++ ) { BaseField field = this . getSourceField ( i ) ; if ( field == null ) continue ; try { BaseField fldSummary = BaseField . cloneField ( field ) ; if ( field . getRecord ( ) != recBasis ) { String strRecord = field . getRecord ( ) . getRecordName ( ) ; if ( field . getRecord ( ) == this . getScreenRecord ( ) ) strRecord = "ScreenRecord" ; fldSummary . setFieldName ( strRecord + ' ' + field . getFieldName ( ) ) ; } if ( field == field . getRecord ( ) . getCounterField ( ) ) { fldSummary . setFieldName ( "Count" ) ; fldSummary . setFieldDesc ( "Count" ) ; } recSummary . addField ( fldSummary ) ; if ( ! this . isKeyField ( fldSummary , i ) ) if ( i != 0 ) bAddKeyField = false ; if ( bAddKeyField ) keyArea . addKeyField ( fldSummary , DBConstants . ASCENDING ) ; } catch ( CloneNotSupportedException ex ) { ex . printStackTrace ( ) ; // Never } } recSummary . setKeyArea ( AnalysisRecord . kIDKey + 1 ) ; // Get rid of the current screen controls. for ( int i = this . getSFieldCount ( ) - 1 ; i >= 0 ; i -- ) { ScreenField sField = this . getSField ( i ) ; if ( ! ( sField instanceof BasePanel ) ) sField . free ( ) ; } int iToolbars = this . getSFieldCount ( ) ; // Add the new screen controls. for ( int i = AnalysisRecord . kID + 1 ; i < recSummary . getFieldCount ( ) ; i ++ ) { recSummary . getField ( i ) . setupDefaultView ( this . getNextLocation ( ScreenConstants . NEXT_LOGICAL , ScreenConstants . ANCHOR_DEFAULT ) , this , ScreenConstants . DEFAULT_DISPLAY ) ; } while ( iToolbars > 0 ) { // Move the toolbars up ScreenField sField = this . getSField ( 0 ) ; this . removeSField ( sField ) ; this . addSField ( sField ) ; iToolbars -- ; } // New main record! this . addRecord ( recSummary , true ) ; return recSummary ; }
Create a record to do the data analysis with .