public int convertFieldToIndex ( ) { int index = - 1 ; FieldInfo field = this . getField ( ) ; if ( field != null ) { if ( ! field . isNull ( ) ) { boolean bFound = false ; Object bookmark = null ; try { if ( field instanceof ReferenceField ) // Always if ( ( ( ReferenceField ) field ) . getReferenceRecord ( ) == m_record ) bookmark = ( ( ReferenceField ) field ) . getReference ( ) . getHandle ( DBConstants . BOOKMARK_HANDLE ) ; } catch ( DBException ex ) { bookmark = null ; } if ( bookmark == null ) if ( field instanceof IntegerField ) bookmark = field . getData ( ) ; Object bookmarkRecord = null ; try { bookmarkRecord = m_record . getTable ( ) . getHandle ( m_iHandleType ) ; } catch ( DBException ex ) { } if ( ( m_record . getEditMode ( ) == Constants . EDIT_IN_PROGRESS ) || ( m_record . getEditMode ( ) == Constants . EDIT_CURRENT ) ) if ( bookmarkRecord != null ) if ( bookmarkRecord . equals ( bookmark ) ) bFound = true ; // Don't re-read the record... It is current! if ( bFound == false ) if ( bookmark != null ) { // First, try to look up the field (a bookmark) in the grid table. index = m_gridTable . bookmarkToIndex ( bookmark , DBConstants . BOOKMARK_HANDLE ) ; // Find the index of this record in the list if ( index != - 1 ) { if ( m_bIncludeBlankOption ) index ++ ; return index ; } try { bFound = ( m_record . getTable ( ) . setHandle ( bookmark , m_iHandleType ) != null ) ; } catch ( DBException e ) { bFound = false ; } } if ( bFound ) { index = m_gridTable . bookmarkToIndex ( bookmark , DBConstants . BOOKMARK_HANDLE ) ; // Find the index of this record in the list if ( index != - 1 ) { try { m_gridTable . get ( index ) ; // Make sure I'm actually pointing to this record (fast - should be cached) } catch ( DBException e ) { e . printStackTrace ( ) ; // Never } } if ( m_bIncludeBlankOption ) index ++ ; if ( index != - 1 ) return index ; } } } this . moveToIndex ( - 1 ) ; // Move off any valid record if ( m_bIncludeBlankOption ) if ( field != null ) if ( field . isNull ( ) ) return 0 ; // Null = Select the "Blank" line return - 1 ; }
Convert the current field value to an index .