Module cDbCJGridPromptList.pkg

     1Use Windows.pkg
     2Use cDbCJGrid.pkg
     3Use cCJGridSearchDialog.pkg
     4
     5#IFNDEF umPromptRelational
     6
     7Enum_List
     8    Define umPromptRelational
     9    Define umPromptValue
    10    Define umPromptCustom
    11    Define umPromptNonInvoking
    12End_Enum_List
    13
    14#ENDIF
    15
    16{ OverrideProperty=pbPromptListBehavior DesignTime=False}
    17{ OverrideProperty=pbEditOnKeyNavigation DesignTime=False}
    18{ OverrideProperty=pbEditOnClick DesignTime=False}
    19{ OverrideProperty=pbReadOnly DesignTime=False}
    20{ OverrideProperty=Auto_Fill_State DesignTime=False}
    21{ OverrideProperty=pbFocusSubItems DesignTime=False}
    22{ OverrideProperty=pbSelectionEnable DesignTime=False}
    23{ OverrideProperty=pbAllowAppendRow DesignTime=False}
    24{ OverrideProperty=pbAllowDeleteRow DesignTime=False}
    25{ OverrideProperty=pbAllowEdit DesignTime=False}
    26{ OverrideProperty=pbAllowInsertRow DesignTime=False}
    27{ OverrideProperty=pbAutoAppend DesignTime=False}
    28{ OverrideProperty=pbAutoSave DesignTime=False}
    29{ OverrideProperty=pbHeaderPrompts DesignTime=False}
    30{ OverrideProperty=pbSelectTextOnEdit DesignTime=False}
    31{ OverrideProperty=pbValidateOnNext DesignTime=False}
    32{ HelpTopic=cDbCJGridPromptList }
    33Class cDbCJGridPromptList is a cDbCJGrid
    34
    35    Procedure Construct_Object
    36        Forward Send Construct_Object
    37
    38        { Category=Behavior }
    39        Property Boolean pbAutoSeed True     // if we should seed list from invoking data
    40        { Category=Behavior }
    41        Property Boolean pbAutoServer False   // use the invoking DEO's server if possible
    42        { Category=Behavior }
    43        Property Boolean pbAutoColumn True   // attempt to use the best column from invoking object
    44        { Visibility=Private }
    45        Property Boolean Private_pbAutoOrdering True
    46        { Category=Behavior }
    47        Property Boolean pbAutoSearch True  // pops up search window
    48        { Category=Behavior }
    49        Property Boolean pbAutoEnableColumns True  // should non indexed columns be enabled
    50        { Category=Behavior }
    51        { EnumList="umPromptRelational,umPromptValue,umPromptCustom,umPromptNonInvoking" }
    52        Property Integer peUpdateMode umPromptRelational
    53        { Category=Behavior }
    54        Property Integer piUpdateColumn 0
    55        { Category=Behavior }
    56        Property Integer piInitialColumn -1
    57        { Category=Behavior }
    58        Property String  psSeedValue ''
    59        { Category=Behavior }
    60        Property Handle phmPromptUpdateCallback 0
    61        { Category=Behavior }
    62        Property Handle phmPromptSeedBufferCallback 0
    63        
    64        { Visibility=Private }
    65        Property Boolean pbStoredAutoSeed
    66        { Visibility=Private }
    67        Property Boolean pbStoredAutoServer
    68        { Visibility=Private }
    69        Property Boolean pbStoredAutoColumn
    70        { Visibility=Private }
    71        Property Boolean pbStoredAutoOrdering
    72        { Visibility=Private }
    73        Property Boolean pbStoredAutoSearch
    74        { Visibility=Private }
    75        Property Boolean pbStoredAutoEnableColumns
    76        { Visibility=Private }
    77        Property Integer peStoredUpdateMode
    78        { Visibility=Private }
    79        Property Integer piStoredUpdateColumn
    80        { Visibility=Private }
    81        Property Integer piStoredInitialColumn
    82        { Visibility=Private }
    83        Property Handle  phmStoredPromptUpdateCallback
    84        { Visibility=Private }
    85        Property Handle  phmStoredPromptSeedBufferCallback
    86
    87        { Visibility=Private }
    88        Property Handle  phoStoredServer
    89        { Visibility=Private }
    90        Property Integer piStoredOrdering
    91        { Visibility=Private }
    92        Property Boolean pbStoredSelectionEnable
    93        { Visibility=Private }
    94        Property Boolean pbStoredMultipleSelection
    95        { Visibility=Private }
    96        Property Boolean pbStoredStaticData
    97        
    98        // internally set by list
    99
   100        // these must be set upon closing the list and can be used for manual list updates
   101        { DesignTime=False }
   102        Property Boolean pbCanceled
   103        { DesignTime=False }
   104        Property Integer[] pSelectedRows
   105
   106        { Visibility=Private }
   107        Property Boolean pbNeedsNewOrdering
   108        { Visibility=Private }
   109        Property Boolean pbRequestSearch
   110        { DesignTime=False }
   111        Property Integer phoInvokingObject
   112        { Visibility=Private }
   113        Property Boolean pbRelational
   114        { Visibility=Private }
   115        Property Boolean pbAutoServerInUse 
   116        { Visibility=Private }
   117        Property Handle  phoOldServer
   118        { Visibility=Private }
   119        Property Integer piInvokingField
   120        { Visibility=Private }
   121        Property Integer piInvokingFile
   122        { Visibility=Private }
   123        Property Boolean pbDisableEntryUpdate
   124        
   125        
   126
   127        
   128        // these properties makes a prompt list a prompt list
   129        // and should not be changed.
   130        Set pbPromptListBehavior to True
   131        Set pbEditOnKeyNavigation to False
   132        Set pbEditOnClick to False
   133        Set pbReadOnly to True
   134        Set Auto_Fill_State to False
   135        Set pbFocusSubItems to True
   136        
   137        // these could maybe be changed
   138        Set pbShadeSortColumn to True
   139        Set pbHeaderReorders to True
   140        Set pbHeaderTogglesDirection to True
   141        Set pbHeaderSelectsColumn to True
   142        Set peRequestFindMode to rfmFindMainSuper
   143        Set peHorizontalGridStyle to xtpGridNoLines
   144        Set piFocusCellBackColor to clNone
   145        Set piFocusCellForeColor to clNone
   146        Set piFocusCellRectangleColor to clBlack
   147        Set pbUseFocusCellRectangle to False
   148        Set pbSelectionEnable to True
   149        
   150        On_Key kEnter Send Ok
   151        On_Key kCancel Send Cancel
   152        
   153
   154    End_Procedure
   155    
   156    // reorder list automatically on column change
   157    // this also set pbFocusSubItems which is required to make the two states work
   158    { Category=Behavior }
   159    { MethodType=Property InitialValue=True }
   160    Procedure Set pbAutoOrdering Boolean bAutoOrder
   161        Set Private_pbAutoOrdering to bAutoOrder
   162        Set pbFocusSubItems to bAutoOrder
   163    End_Procedure
   164    
   165    { MethodType=Property }
   166    Function pbAutoOrdering Returns Boolean
   167        Boolean bAutoOrder
   168        Get Private_pbAutoOrdering to bAutoOrder
   169        Function_Return bAutoOrder
   170    End_Function
   171
   172    // we don't want a menu for prompt lists
   173    { NoDoc=True }
   174    Function CreateContextMenu Returns Handle
   175        Function_Return 0
   176    End_Function
   177
   178    // if we use auto-ordering, change the order when the column changes
   179    { Visibility=Private }
   180    Procedure ColumnChanged Integer iOld Integer iNew
   181        Boolean bAutoOrder
   182        Forward Send ColumnChanged iOld iNew
   183        Get pbAutoOrdering to bAutoOrder
   184        If bAutoOrder Begin
   185            // will be reordered in idle event
   186            Set pbNeedsNewOrdering to True
   187        End
   188    End_Procedure
   189    
   190    // augmented to handle auto-ordering and invoking the search popup list
   191    { NoDoc=True }
   192    Procedure OnIdle
   193        Boolean bNeedsReorder bSearch bOldToggle
   194        Handle hoCol
   195        Integer iKy1 iKy2 iCol
   196
   197        Get pbNeedsNewOrdering to bNeedsReorder
   198        If bNeedsReorder Begin
   199            Get SelectedColumn to iCol
   200            If (iCol<>-1) Begin
   201                
   202                Get pbHeaderTogglesDirection to bOldToggle
   203                Set pbHeaderTogglesDirection to False
   204                Send HeaderReorder iCol
   205                Set pbHeaderTogglesDirection to bOldToggle
   206                
   207                Set pbNeedsNewOrdering to False
   208            End
   209        End
   210        
   211        Get pbRequestSearch to bSearch
   212        If bSearch Begin
   213            Set pbRequestSearch to False
   214            Get piLastKey to iKy1
   215            Get piLastKey2 to iKy2
   216            Send Request_Search iKy1 iKy2
   217        End
   218        
   219        Forward Send OnIdle
   220    End_Procedure
   221    
   222    { MethodType=Event}
   223    Procedure OnStoreDefaults
   224        Integer iVal
   225        Boolean bVal
   226
   227        Get pbAutoSeed to bVal           
   228        Set pbStoredAutoSeed to bVal           
   229        
   230        Get pbAutoServer to bVal        
   231        Set pbStoredAutoServer to bVal        
   232        
   233        Get pbAutoOrdering to bVal        
   234        Set pbStoredAutoOrdering to bVal      
   235        
   236        Get pbAutoSearch to bVal         
   237        Set pbStoredAutoSearch to bVal         
   238        
   239        Get pbAutoEnableColumns to bVal  
   240        Set pbStoredAutoEnableColumns to bVal  
   241        
   242        Get peUpdateMode to iVal
   243        Set peStoredUpdateMode to iVal
   244        
   245        Get piUpdateColumn to iVal       
   246        Set piStoredUpdateColumn to iVal       
   247
   248        Get piInitialColumn to iVal       
   249        Set piStoredInitialColumn to iVal       
   250
   251        Get phmPromptUpdateCallback to iVal       
   252        Set phmStoredPromptUpdateCallback to iVal       
   253
   254        Get phmPromptSeedBufferCallback to iVal       
   255        Set phmStoredPromptSeedBufferCallback to iVal       
   256        
   257        Get Server to iVal       
   258        Set phoStoredServer to iVal       
   259
   260        Get Ordering to iVal       
   261        Set piStoredOrdering to iVal       
   262        
   263        Get pbSelectionEnable to bVal
   264        Set pbStoredSelectionEnable to bVal
   265        
   266        Get pbMultipleSelection to bVal
   267        Set pbStoredMultipleSelection to bVal
   268        
   269        Get pbStaticData to bVal
   270        Set pbStoredStaticData to bVal
   271        
   272    End_Procedure
   273
   274    { MethodType=Event}
   275    Procedure OnRestoreDefaults
   276        Integer iVal
   277        Boolean bVal
   278
   279        Get pbStoredAutoSeed to bVal           
   280        Set pbAutoSeed to bVal           
   281        
   282        Get pbStoredAutoServer to bVal        
   283        Set pbAutoServer to bVal        
   284        
   285        Get pbStoredAutoOrdering to bVal        
   286        Set pbAutoOrdering to bVal      
   287        
   288        Get pbStoredAutoSearch to bVal         
   289        Set pbAutoSearch to bVal         
   290        
   291        Get pbStoredAutoEnableColumns to bVal  
   292        Set pbAutoEnableColumns to bVal  
   293        
   294        Get peStoredUpdateMode to iVal
   295        Set peUpdateMode to iVal
   296        
   297        Get piStoredInitialColumn to iVal       
   298        Set piInitialColumn to iVal       
   299        
   300        Get phmStoredPromptUpdateCallback to iVal       
   301        Set phmPromptUpdateCallback to iVal       
   302
   303        Get phmStoredPromptSeedBufferCallback to iVal       
   304        Set phmPromptSeedBufferCallback to iVal       
   305
   306        Get phoStoredServer to iVal       
   307        Set Server to iVal       
   308
   309        Get piStoredOrdering to iVal       
   310        Set Ordering to iVal       
   311        
   312        Get pbStoredSelectionEnable to bVal
   313        Set pbSelectionEnable to bVal
   314        
   315        Get pbStoredMultipleSelection to bVal
   316        Set pbMultipleSelection to bVal
   317
   318        Get pbStoredStaticData to bVal
   319        Set pbStaticData to bVal
   320
   321    End_Procedure
   322    
   323    {NoDoc=True }
   324    Procedure Add_Focus Handle hoParent Returns Integer
   325        Integer eMode
   326        Integer[] SelRowsIndexes
   327        Set pbCanceled to True // assume cancel unless changed
   328        Set pSelectedRows to SelRowsIndexes // empty
   329        Get peUpdateMode to eMode
   330        If (eMode<>umPromptNonInvoking) Begin
   331            Send OnStoreDefaults
   332        End
   333        Send InitializePromptList
   334        Forward Send Add_Focus hoParent
   335        Send LoadData
   336        Set psSeedValue to ""
   337    End_Procedure
   338    
   339    // with prompts list we don't want any automatic loading of
   340    // data. Loading is handled in LoadData
   341    Procedure DataLoadAdjustOnAddFocus
   342    End_Procedure    
   343
   344    // called before the list is activated. 
   345    { Visibility=Private }
   346    Procedure InitializePromptList
   347        Integer hoServer hoInvokingObject hoInvokingServer
   348        Boolean bAutoServer bAutoColumn bAutoSeed bRelational bAutoEnable bInUse
   349        Integer iFile iField i iOldMode iMainFile eUpdateMode
   350        String sValue
   351        
   352        Get peUpdateMode to eUpdateMode
   353        If (eUpdateMode<>umPromptNonInvoking) Begin
   354            Get Focus of Desktop to hoInvokingObject
   355            If (hoInvokingObject<=Desktop) Begin
   356                Error DFERR_PROGRAM "Prompt list has no invoking object"
   357                Procedure_Return
   358            End
   359
   360            Set phoInvokingObject to hoInvokingObject
   361
   362            Send Prompt_Callback to hoInvokingObject Self
   363            Get peUpdateMode to eUpdateMode
   364        End
   365
   366        Get Server to hoServer
   367        If (hoServer=0) Begin
   368            Error DFERR_PROGRAM "Prompt list has no Server"
   369            Procedure_Return
   370        End
   371
   372        Set pbRequestSearch to False
   373        Set pbNeedsNewOrdering to False
   374
   375        Get pbAutoSeed to bAutoSeed
   376        Get pbAutoEnableColumns to bAutoEnable
   377        
   378        If (eUpdateMode=umPromptRelational) Begin
   379
   380            Get pbAutoServer to bAutoServer // can only be used with relational lists
   381
   382            Get Delegation_Mode of hoInvokingObject to iOldMode
   383            Set Delegation_Mode of hoInvokingObject to NO_DELEGATE_OR_ERROR
   384            Get Data_File  of hoInvokingObject Current to iFile
   385            Get Data_Field of hoInvokingObject Current to iField
   386            Set Delegation_Mode of hoInvokingObject to iOldMode
   387            If (iFile) Begin
   388                Get Server of hoInvokingObject to hoInvokingServer
   389            End
   390            Set piInvokingFile to iFile
   391            Set piInvokingField to iField
   392            
   393            Get Main_File of hoServer to iMainFile
   394            
   395            If (iFile<>0 and iMainFile=iFile and hoInvokingObject<>0) Begin
   396                Set pbRelational to True
   397                Set pbAutoServerInUse to bAutoServer
   398                If bAutoServer Begin    
   399                    Set Deferred_State to True
   400                    Set phoOldServer to hoServer
   401                    // if using an invokinger server, find and attach to the server that owns the file
   402                    Get Which_Data_Set of hoInvokingServer iMainFile to hoInvokingServer
   403                    If hoInvokingServer Begin
   404                        If (hoServer) Begin
   405                           Send Remove_Deo_From_Server  // the deo is removed from server
   406                        End
   407                        Set private.Server to hoInvokingServer
   408                        Move hoInvokingServer to hoServer
   409                        Send scan_servers
   410                        // if we are latching on to a server, let's make sure the fields have this server.
   411                        Send Refind_Records to hoServer
   412                    End
   413                End
   414            End
   415            Else Begin
   416                Set pbRelational to False
   417                Send OnRelationalPromptListError
   418                // get the update mode in case the RelationalPromptListError changes the mode to try 
   419                // another mode
   420                Get peUpdateMode to eUpdateMode
   421            End
   422        End
   423        
   424        If (eUpdateMode=umPromptValue) Begin // else not used here intentionally
   425            Get Value of hoInvokingObject to sValue
   426            Set psSeedValue to sValue
   427        End
   428        
   429        // Rebuild the DD constraints, unless this is auto-server (if auto-server we assume the DD is
   430        // already built). We do this after the prompt_callback so that any changes that would impact
   431        // constraints will be applied in rebuild_constraints. Do this before Activating so that manual
   432        // loading of data will use rebuilt constraints
   433        Get In_Use_State of hoServer to bInUse // if not in use, it will get rebuilt later
   434        If (bInUse and not(bAutoServer) and eUpdateMode<>umPromptNonInvoking) Begin
   435            // if not auto-server and invoking (if non invoking, constraints s/b built)
   436            Send Rebuild_Constraints of hoServer
   437        End
   438        
   439    End_Procedure
   440    
   441    // by default this raises an error. If you want a failed relational list to not raise an
   442    // error but to default to a different mode such as unPromptValue, just remove the error and
   443    // set peUpdateMode.
   444    { MethodType=Event }
   445    Procedure OnRelationalPromptListError
   446        Error DFERR_PROGRAM "Prompt list can not be used as a relational prompt list for this object"
   447    End_Procedure
   448    
   449    // called after list is created and active. Load Data, seed list, select start column, etc.
   450    { Visibility=Private }
   451    Procedure LoadData
   452        Handle hoServer hoInvokingObject hoDataSource hoUpdateColumn hoInitialColumn
   453        Integer iField iFile iUpdateColumn iOrder iRows iInitialColumn iInitialOrder
   454        Integer eUpdateMode iIndex
   455        Boolean bRelational bAutoSeed bAutoColumn bCancel bSubFocus bAutoOrder bAutoEnable bSeeded
   456        
   457        Get phoDataSource to hoDataSource
   458        Get pbRelational to bRelational
   459        Get pbAutoColumn to bAutoColumn
   460        Get peUpdateMode to eUpdateMode
   461        Get pbAutoEnableColumns to bAutoEnable
   462        Get pbAutoOrdering to bAutoOrder
   463        Get phoInvokingObject to hoInvokingObject
   464        Get Server to hoServer
   465        Get piInvokingFile to iFile
   466        Get piInvokingField to iField
   467        Get pbAutoSeed to bAutoSeed
   468        Get piInitialColumn to iInitialColumn
   469        Get RowCount of hoDataSource to iRows
   470        
   471        Set In_Use_State of hoServer to True // just in case
   472        
   473        // if relational, update column is the "best" else you must specify it
   474        If (eUpdateMode=umPromptRelational) Begin
   475            Get SelectBestColumn iFile iField to iUpdateColumn
   476        End
   477        Else Begin
   478            Get piUpdateColumn to iUpdateColumn
   479        End
   480        If (iUpdateColumn>=0) Begin
   481            Get ColumnObject iUpdateColumn to hoUpdateColumn
   482        End
   483        
   484        // We need an initial column. if you specified an initial column that will get used for the start column
   485        // and the initial sort order. If you did not, which is typical, it will use the update column
   486        If (iInitialColumn=-1) Begin
   487            Move iUpdateColumn to iInitialColumn
   488        End
   489        If (iInitialColumn>=0) Begin
   490            Get ColumnObject iInitialColumn to hoInitialColumn
   491            Set pbVisible of hoInitialColumn to True // initial column should be visible
   492        end
   493        
   494        // this assigns an ordering and a sort order
   495        If (bAutoColumn and hoInitialColumn) Begin
   496            Set piSortColumn to iInitialColumn
   497            // we use update column for now so the seed will work. This may get changed below
   498            Get ColumnOrdering of hoUpdateColumn to iOrder                        
   499            Set Ordering to iOrder
   500            Send BindDataSource
   501        End
   502        
   503        // this function seeds the data and a boolean indicating if the buffer was seeded and read
   504        Get SeedData hoUpdateColumn hoInitialColumn to bSeeded
   505
   506        // if initial and update columns are different we must now reset the ordering
   507        // to the initial order.
   508        If (bAutoColumn and hoInitialColumn and (hoInitialColumn<>hoUpdateColumn)) Begin
   509            Get ColumnOrdering of hoInitialColumn to iOrder                        
   510            Set Ordering to iOrder
   511            Send BindDataSource
   512        End
   513            
   514        // if we have rows it means that the developer already did something to load
   515        // records, probably in activating. If so, we will not get in the way
   516        If (iRows=0) Begin
   517            
   518            If (not(bSeeded)) Begin
   519                Send MovetoFirstRow
   520            End
   521            Else Begin
   522                Send RefreshDataFromExternal 4
   523            End
   524        End
   525        Else Begin
   526            Move -1 to iIndex
   527            If (bAutoSeed and bSeeded) Begin
   528                Get FindExternalDataInCache of hoDataSource to iIndex
   529            End
   530            If (iIndex=-1) Begin
   531                Send MovetoFirstRow
   532            End
   533            Else Begin
   534                Send MoveToRow iIndex
   535            End
   536        End
   537        
   538        // we enable after the load because we may not know if it is static until this point
   539        If bAutoEnable Begin
   540            Send AutoEnableColumns
   541        End
   542        
   543        Get pbFocusSubItems to bSubFocus
   544        If bSubFocus Begin
   545            
   546            If hoInitialColumn Begin
   547                Get MoveToColumnObject hoInitialColumn to bCancel
   548            End
   549            Else Begin
   550                Send MoveToFirstEnterableColumn
   551            End
   552        End
   553
   554    End_Procedure
   555    
   556    
   557  
   558
   559    // disable columns that don't have indexes and non-static. If static it's enabled
   560    { Visibility=Private }
   561    Procedure AutoEnableColumns
   562        Integer iCol iCols iIndex
   563        Handle hoCol hoDataSource
   564        Boolean bStatic bFocusable
   565        Get phoDataSource to hoDataSource
   566        Get DataIsStatic of hoDatasource to bStatic
   567        Get ColumnCount to iCols
   568        For iCol from 0 to (iCols-1)
   569            Get ColumnObject iCol to hoCol
   570            If (bStatic) Begin
   571                Move True to bFocusable
   572            End
   573            Else Begin
   574                Get ColumnOrdering of hoCol to iIndex
   575                Move (iIndex<>-1) to bFocusable
   576            End
   577            Set pbFocusable of hoCol to bFocusable
   578        Loop
   579    End_Procedure
   580    
   581    // select best column to start in
   582    Function SelectBestColumn Integer iFile Integer iField Returns Integer
   583        Integer i iCols iTable iColumn 
   584        Handle hoCol
   585        Get ColumnCount to iCols
   586        For i from 0 to (iCols-1)
   587            Get ColumnObject i to hoCol
   588            Get piBindingTable of hoCol to iTable    
   589            Get piBindingColumn of hoCol to iColumn
   590            If (iFile=iTable and iField=iColumn ) Begin
   591                Function_Return i
   592            End
   593        Loop
   594        Function_Return -1
   595    End_Function
   596    
   597    Function SeedData Handle hoUpdateColumn Handle hoInitialColumn Returns Boolean
   598        Handle hoInvokingObject hoInvokingServer hoDataSource hoServer
   599        Handle hmSeedBuffer
   600        Integer iField iFile eUpdateMode iStat iOrdering
   601        Boolean bRelational bAutoSeed bReadRecord bChanged bSeeded
   602        String sValue
   603
   604        Get phoDataSource to hoDataSource
   605        Get pbRelational to bRelational
   606        Get peUpdateMode to eUpdateMode
   607        Get phoInvokingObject to hoInvokingObject
   608        Get piInvokingFile to iFile
   609        Get piInvokingField to iField
   610        Get pbAutoSeed to bAutoSeed
   611        Get phmPromptSeedBufferCallback to hmSeedBuffer
   612        
   613        // if a seed message is created, we assume that this should override anything else and that
   614        // you will use this and only this for seeding
   615        If (eUpdateMode<>umPromptNonInvoking and hmSeedBuffer) Begin
   616            Clear iFile    // First clear the main_file buffer
   617            Send hmSeedBuffer of hoInvokingObject Self
   618            // if we come back with a non-edited, record we assume the seed did a find
   619            // and we will use that record. Otherwise we want to do a find
   620            Get_Attribute DF_FILE_STATUS of iFile to iStat
   621            If (iStat=DF_FILE_ACTIVE) Begin
   622                Move True to bSeeded
   623            End
   624            Else Begin             
   625                Move True to bReadRecord
   626            End
   627        End
   628        // if relational we will seed if autoseed and if it really is relational
   629        Else If (eUpdateMode=umPromptRelational) Begin
   630            If (bAutoSeed and bRelational) Begin
   631                Clear iFile    // First clear the main_file buffer
   632                // Default action is to perform an entry update just like a find
   633                // key would do. If we have a server allow the server to control this.
   634                Get Server of hoInvokingObject to hoInvokingServer
   635                Set pbDisableEntryUpdate to True
   636                Send Request_Entry_Update to hoInvokingServer iFile 1
   637                Set pbDisableEntryUpdate to False
   638                Move True to bReadRecord
   639            End
   640        End
   641        // if value or custom, we seed if auto seed and we have an update column
   642        Else If (bAutoSeed and hoUpdateColumn) Begin
   643            Get psSeedValue to sValue
   644            Get piBindingTable of hoUpdateColumn to iFile
   645            Get piBindingColumn of hoUpdateColumn to iField
   646            Clear iFile    // First clear the main_file buffer
   647//            Get Server of hoDataSource to hoServer
   648//            Get Ordering of hoDataSource to iOrdering
   649//            // this will set up the buffers for any constraints
   650//            Send Establish_Find_Direction of hoServer FIRST_RECORD iFile iOrdering
   651            Set_Field_Value iFile iField to sValue 
   652            Move True to bReadRecord
   653        End
   654        
   655        // only find a record if there is a change. If the buffer is unchanged we leave
   656        // it as is. This uncleared always start at the top of the list and if a custom
   657        // seed was used to find the record, we will use that id
   658        If bReadRecord Begin
   659            Get_Attribute DF_FILE_CHANGED of iFile to bChanged
   660            If bChanged Begin
   661                Get ReadRecordInBuffer of hoDataSource to bSeeded
   662            End
   663        End
   664        
   665        Function_Return bSeeded
   666    End_Function
   667
   668    
   669    { MethodType=Event }
   670    Procedure OnMoveValueOutByRelational
   671        Boolean bRelational
   672        RowID riRec
   673        Integer[] SelRowsIndexes
   674        Handle hoInvokingObject hoInvokingServer hoServer hoDataSource
   675        Integer iFile 
   676        
   677        Get pbRelational to bRelational
   678        If bRelational Begin
   679            Get phoInvokingObject to hoInvokingObject
   680            Get Server to hoServer
   681            Get Main_File of hoServer to iFile
   682            Get pSelectedRows to SelRowsIndexes
   683            If (SizeOfArray(SelRowsIndexes)>0) Begin
   684                Get phoDataSource to hoDataSource
   685                Get RowTag of hoDataSource SelRowsIndexes[0] to riRec
   686                Get Server of hoInvokingObject to hoInvokingServer   // find server of invoking object
   687                Send FindByRowId of hoInvokingServer iFile riRec
   688            End
   689        End
   690    End_Procedure
   691
   692    { MethodType=Event }
   693    Procedure OnMoveValueOutByValue
   694        String sValue
   695        Handle hoInvokingObject hoCol  hoDataSource
   696        Integer iRow iCol
   697        Integer[] SelRowsIndexes
   698
   699        Get phoInvokingObject to hoInvokingObject
   700        Get pSelectedRows to SelRowsIndexes
   701        If (SizeOfArray(SelRowsIndexes)>0) Begin
   702            Get piUpdateColumn to iCol
   703            Get ColumnObject iCol to hoCol
   704            Get RowValue of hoCol SelRowsIndexes[0] to sValue
   705            Set Value of hoInvokingObject to sValue
   706            Set Item_Changed_State of hoInvokingObject to True
   707        End
   708    End_Procedure
   709
   710    { MethodType=Event }
   711    Procedure OnMoveValueOutByCustom
   712    End_Procedure
   713
   714    { Visibility=Private }
   715    // This is only called in a successful close
   716    Procedure ClosePromptList
   717        Handle hoDataSource hoInvokingObject
   718        Handle hmCallBack
   719        Integer iRow eUpdateMode
   720        Integer[] SelRowsIndexes
   721        
   722        Get phoDataSource to hoDataSource
   723        Get phoInvokingObject to hoInvokingObject
   724        
   725        If (pbMultipleSelection(Self)) Begin
   726            Get GetIndexesForSelectedRows to SelRowsIndexes
   727        End
   728        Else Begin
   729            Get SelectedRow of hoDataSource to iRow
   730            If (iRow<>-1) Begin
   731                Move iRow to SelRowsIndexes[0]
   732            End
   733        End
   734        
   735        Set pbCanceled to False
   736        Set pSelectedRows to SelRowsIndexes
   737        
   738        Get peUpdateMode to eUpdateMode
   739        // if non-invoking there is by definition, no move value out
   740        If (eUpdateMode<>umPromptNonInvoking) Begin
   741            
   742            If (eUpdateMode=umPromptRelational) Begin
   743                Send OnMoveValueOutByRelational
   744            End
   745            Else If (eUpdateMode=umPromptValue) Begin
   746                Send OnMoveValueOutByValue
   747            End
   748            Else If (eUpdateMode=umPromptCustom) Begin
   749                Send OnMoveValueOutByCustom
   750            End
   751                Get phmPromptUpdateCallback to hmCallBack
   752                If hmCallBack Begin
   753                    Send hmCallBack of hoInvokingObject Self
   754                End
   755        End
   756
   757        Send Close_Panel
   758    End_Procedure
   759
   760    { NoDoc=True }
   761    // augment to send OnRestoreDefaults. This must happen after the object is deactivated
   762    // so that the change in server will not do anything. This is called after remove_object
   763    // which removes this DEO from the server.
   764    Procedure Release_Focus
   765        Integer eUpdateMode
   766        Boolean bAutoServer
   767        Handle hoServer
   768        Get peUpdateMode to eUpdateMode
   769        Get pbAutoServerInUse to bAutoServer
   770        Forward Send Release_Focus
   771        If (eUpdateMode<>umPromptNonInvoking) Begin
   772        If bAutoServer Begin
   773            Send Remove_Deo_From_Server
   774            Get phoOldServer to hoServer
   775            Set Private.Server to hoServer
   776            Set phoOldServer to 0
   777            Set pbAutoServerInUse to False
   778            Set Deferred_State to False
   779        End
   780            Send OnRestoreDefaults
   781        End
   782    End_Procedure
   783    
   784    // augment to popup a search window when allowed
   785    { NoDoc=True }
   786    Procedure OnComKeyDown Short ByRef llKeyCode Short llShift
   787        Boolean bSubFocus bAutoSearch bChar
   788        Integer iVal
   789        
   790        Get pbFocusSubItems to bSubFocus
   791        Get pbAutoSearch to bAutoSearch
   792        Forward Send OnComKeyDown llKeyCode llShift
   793        If (bAutoSearch and not(bSubFocus)) Begin
   794            If ((llShift iand 6)=0) Begin // skip alt and ctrl
   795                Get GetVKeyToAnsi llKeyCode llShift to iVal
   796                Move (iVal<>0) to bChar
   797            End
   798            If bChar Begin
   799                Set pbRequestSearch to True
   800            End
   801        End
   802    End_Procedure
   803    
   804    { NoDoc=True }
   805    Procedure OnComRequestEdit Variant llRow Variant llColumn Variant llItem Boolean ByRef llCancel
   806        Boolean bAutoSearch
   807        Get pbAutoSearch to bAutoSearch
   808        If bAutoSearch Begin
   809            Set pbRequestSearch to True // will do a popup search in idle
   810        End
   811        Move True to llCancel
   812    End_Procedure  // OnComRequestEdit
   813    
   814    // must be able to disable this when we are seeding the list from the invoking object w/ auto-server
   815    { NoDoc=True }
   816    Procedure Entry_update Integer iFile Integer iDoAll
   817        Boolean bDisable
   818        Get pbDisableEntryUpdate to bDisable
   819        If not bDisable Begin
   820            Forward Send Entry_Update iFile iDoAll
   821        End
   822    End_Procedure
   823
   824    Procedure Ok Returns Integer
   825        Send ClosePromptList
   826    End_Procedure
   827
   828    Procedure Cancel Returns Integer
   829        Send Close_Panel
   830    End_Procedure
   831        
   832    Procedure Search
   833        Send Activate // give focus back to list so focus things are correct
   834        Send Request_Search 0 0
   835    End_Procedure
   836    
   837    { NoDoc=True }
   838    Procedure OnComRowDblClick Variant llRow Variant llItem
   839        Set pbRequestSearch to False // kill any deferred search popup
   840        Forward Send OnComRowDblClick llRow llItem
   841    End_Procedure
   842    
   843    { NoDoc=True }
   844    Procedure OnRowDoubleClick Integer iRow Integer iCol
   845        Send Ok
   846    End_Procedure
   847    
   848    
   849    Function SelectedRowIds Returns RowID[]
   850        RowID[] SelectedRowids
   851        Integer[] SelectedRows
   852        Integer i iRows
   853        Handle hoDataSource
   854        Get phoDataSource to hoDataSource
   855        Get pSelectedRows to SelectedRows
   856        Move (SizeOfArray(SelectedRows)) to iRows
   857        For i from 0 to (iRows-1)
   858            Get RowTag of hoDataSource SelectedRows[i] to SelectedRowIds[i]
   859        Loop
   860        Function_Return SelectedRowids
   861    End_Function
   862
   863    Function SelectedColumnValues Integer iCol Returns String[]
   864        String[] SelectedValues
   865        Integer[] SelectedRows
   866        Integer i iRows
   867        Handle hoCol
   868        Get ColumnObject iCol to hoCol
   869        Get pSelectedRows to SelectedRows
   870        Move (SizeOfArray(SelectedRows)) to iRows
   871        For i from 0 to (iRows-1)
   872            Get RowValue of hoCol SelectedRows[i] to SelectedValues[i]
   873        Loop
   874        Function_Return SelectedValues
   875    End_Function
   876
   877End_Class