public boolean checkAndHandleFieldChanges ( BaseBuffer buffer , boolean [ ] rgbModified , boolean bRestoreVirtualFields ) { boolean bAnyChanged = false ; // Fifth step: If what is currently on the screen is different from the new merged data, re-call the handleFieldChanged (SCREEN_MOVE) buffer . resetPosition ( ) ; for ( int iFieldSeq = 0 ; iFieldSeq < this . getFieldCount ( ) ; iFieldSeq ++ ) { BaseField field = this . getField ( iFieldSeq ) ; Object dataScreen = buffer . getNextData ( ) ; Object dataUpdated = field . getData ( ) ; if ( ( ( dataUpdated != null ) && ( ! dataUpdated . equals ( dataScreen ) ) ) || ( ( dataUpdated == null ) && ( dataScreen != dataUpdated ) ) || ( field . isModified ( ) ) ) { // I compare rather than check isModified due to the virtual fields if ( ( this . getField ( iFieldSeq ) . isVirtual ( ) ) && ( ! this . getField ( iFieldSeq ) . isModified ( ) ) && ( this . getField ( iFieldSeq ) . getData ( ) == this . getField ( iFieldSeq ) . getDefault ( ) ) ) { // Virtual fields that were not changed, need to be returned to their former value if ( bRestoreVirtualFields ) { boolean [ ] rgbEnabled = this . getField ( iFieldSeq ) . setEnableListeners ( false ) ; this . getField ( iFieldSeq ) . setData ( dataScreen ) ; this . getField ( iFieldSeq ) . setModified ( false ) ; this . getField ( iFieldSeq ) . setEnableListeners ( rgbEnabled ) ; } } else { int iMoveMode = field . isModified ( ) ? DBConstants . SCREEN_MOVE : DBConstants . READ_MOVE ; // If I changed it, SCREEN_MOVE, if data changed, READ_MOVE if ( rgbModified != null ) if ( rgbModified [ iFieldSeq ] ) { iMoveMode = DBConstants . SCREEN_MOVE ; // Special case if I changed it, and the someone else changed it to the same thing, hit screen_move one more time. if ( field . isVirtual ( ) ) if ( ( ( dataUpdated != null ) && ( dataUpdated . equals ( dataScreen ) ) ) || ( ( dataUpdated == null ) && ( dataScreen == dataUpdated ) ) ) if ( ! field . isJustModified ( ) ) // Extra special case - Since a changed virtual field will always be modified, see if it actually changed; iMoveMode = DBConstants . READ_MOVE ; // Extra special case - If not, see if someone else modified it } this . getField ( iFieldSeq ) . handleFieldChanged ( DBConstants . DISPLAY , iMoveMode ) ; bAnyChanged = true ; } } } return bAnyChanged ; }
Compare the current state with the way the record was before and call any fieldchange listeners .