public int updateGridToMessage ( BaseMessage message , boolean bReReadMessage , boolean bAddIfNotFound ) { Record record = this . getRecord ( ) ; // Record changed int iHandleType = DBConstants . BOOKMARK_HANDLE ; // OBJECT_ID_HANDLE; if ( this . getNextTable ( ) instanceof org . jbundle . base . db . shared . MultiTable ) iHandleType = DBConstants . FULL_OBJECT_HANDLE ; Object bookmark = ( ( RecordMessageHeader ) message . getMessageHeader ( ) ) . getBookmark ( iHandleType ) ; int iRecordMessageType = ( ( RecordMessageHeader ) message . getMessageHeader ( ) ) . getRecordMessageType ( ) ; // See if this record is currently displayed or buffered, if so, refresh and display. GridTable table = ( GridTable ) record . getTable ( ) ; int iIndex = - 1 ; if ( iRecordMessageType == - 1 ) { iIndex = table . bookmarkToIndex ( bookmark , iHandleType ) ; // Find this bookmark in the table } else if ( iRecordMessageType == DBConstants . CACHE_UPDATE_TYPE ) { // No need to update anything as this is just a notification that the cache has been updaed already. iIndex = table . bookmarkToIndex ( bookmark , iHandleType ) ; // Find this bookmark in the table } else if ( iRecordMessageType == DBConstants . SELECT_TYPE ) { // A secondary record was selected, update the secondary field to the new value. // Don't need to update the table for a select } else if ( iRecordMessageType == DBConstants . AFTER_ADD_TYPE ) { iIndex = table . refreshBookmark ( bookmark , iHandleType , false ) ; // Double-check to see if it has already been added if ( iIndex == - 1 ) { if ( bAddIfNotFound ) { // Note: It might be nice to check this filter in the message on the server, then I don't change to read and check it. try { record = record . setHandle ( bookmark , iHandleType ) ; // Fake the handleCriteria to think this is a slave. NOTE: This is not cool in a multitasked environment. int iDBMasterSlave = record . getTable ( ) . getCurrentTable ( ) . getDatabase ( ) . getMasterSlave ( ) ; record . getTable ( ) . getCurrentTable ( ) . getDatabase ( ) . setMasterSlave ( RecordOwner . MASTER | RecordOwner . SLAVE ) ; boolean bMatch = record . handleRemoteCriteria ( null , false , null ) ; record . getTable ( ) . getCurrentTable ( ) . getDatabase ( ) . setMasterSlave ( iDBMasterSlave ) ; if ( bMatch ) { iHandleType = DBConstants . DATA_SOURCE_HANDLE ; bookmark = this . getDataRecord ( m_bCacheRecordData , BaseBuffer . SELECTED_FIELDS ) ; } else bookmark = null ; } catch ( DBException e ) { e . printStackTrace ( ) ; } if ( bookmark != null ) iIndex = table . addNewBookmark ( bookmark , iHandleType ) ; // Add this new record to the table } } } else { iIndex = table . refreshBookmark ( bookmark , iHandleType , bReReadMessage ) ; // Refresh the data for this bookmark } return iIndex ; }
Use this record update notification to update this gridtable .