Module Dfcentry.pkg

     1//  2/26/02 JJT - For 8.2 replaced field_main_index with File_field_Index
     2//  8/2/97  JJT - combo_edit_Changed and combo_item_Changed now forward to
     3//                super class (which will call onChange and set item_
     4//                changed_state
     5// 07/30/97 JJT - add Allow_Defined_State (which is only used by DD combos). This
     6//                places an "undefined" in a drop-down (entry-state=F) list.
     7// 07/23/96 JJT - New Class names
     8// 04/16/96 JJT - Added DD support (if USE$DATA_DICTIONARY is defined)
     9// 2/26/2002  JJT - 8.2 clean up (indirect_file, local, self, etc.)
    10Use DFdtCent.pkg  // DfCombo_Data_entry_form
    11Use cRowIdArray.pkg  // cRowIdArray (has Set capabilities)
    12
    13Register_function File_field_index integer iFile integer iField returns integer
    14
    15{ ClassType=Abstract }
    16{ HelpTopic=dbComboFormDS }
    17Class dbComboFormDS is a dbDataComboForm
    18
    19   Procedure Construct_Object
    20      Forward Send Construct_Object
    21
    22      { Category=Data }
    23      Property Integer Code_File          0   // Must be SET.
    24      { Category=Data }
    25      Property Integer Code_Index         1   // Indx1 is a good guess.
    26      { Category=Data }
    27      Property String  Type_Value         ''  // default these two to
    28      { Category=Data }
    29      Property Integer Type_Field         0   // Undefined (none).
    30      { Category=Data }
    31      Property Integer Code_Field         1   // Fld 1=code, 2=descr
    32      { Category=Data }
    33      Property Integer Description_Field  0   // are good guesses.
    34
    35      { Visibility=Private }
    36      Property Integer Code_Load_Object   0   //(Code_Loader(self))
    37
    38      Set Undefined_Display_Mode to CB_ERR_UPDATE_WINDOW_VALUE
    39      Set Undefined_Save_Mode    to CB_ERR_UPDATE_BLANK_VALUE
    40
    41      { Category=Data }
    42      Property Integer Combo_Data_File  0
    43      { Category=Data }
    44      Property Integer Combo_Index      1
    45
    46      { Visibility=Private }
    47      Property Integer Relational_State False // system maintained
    48
    49      { Category=Behavior }
    50      { PropertyType=Boolean }
    51      Property Integer Allow_Undefined_State False // Only used by DDs
    52
    53      // use this instead of aux_value used for records.
    54      Object oRowIds Is A cRowIdArray
    55      End_Object
    56
    57   End_Procedure // Construct_Object
    58
    59// not supported with rowid
    60//   //Doc/ MethodType=Property Visibility=Private
    61//   Procedure Set Record_Number Integer Itm Integer Rec
    62//     integer dataobj
    63//     Get Combo_data_object to dataobj
    64//     If dataobj ;
    65//        Set Aux_Value of dataobj item itm to Rec
    66//   End_Procedure
    67
    68//   //Doc/ MethodType=Property Visibility=Private
    69//   Function Record_Number Integer Itm Returns Integer
    70//     integer dataobj
    71//     Get Combo_data_object to dataobj
    72//     If dataobj ;
    73//        Function_Return (Aux_Value(DataObj,Itm))
    74//   End_Function
    75
    76   { MethodType=Property Visibility=Private }
    77   Procedure Set RowIdNumber Integer iItm rowId riId
    78        Set RowId_Value of oRowIds iItm to riId
    79   End_Procedure
    80
    81   { MethodType=Property Visibility=Private }
    82   Function RowIdNumber Integer iItm Returns RowId
    83     RowId riId
    84     Get RowId_Value of oRowIds iItm to riId
    85     Function_Return riId
    86   End_Function
    87
    88
    89   // Message to add a record to the list. We store the data value in
    90   // an array, the description in the proxy list, and the record number
    91   // in the proxy list
    92   //
    93   // Send Add_Combo_Item Item_Value {Data_Value}
    94   //
    95   { Visibility=Private }
    96   Procedure Combo_Add_Record Integer dFile Integer dField integer DescField
    97    integer Itm
    98    RowId riId
    99    String DataVal DescVal
   100    If (DescField=0);
   101        Move dField to descField
   102    //Get_field_value dFile 0         to Rec#
   103    Move (getRowId(dFile)) to riId
   104    Get_field_value dFile dField    to DataVal
   105    Get_field_value dFile DescField to DescVal
   106    Get Combo_item_count to itm         // get this before we add the item.
   107    Send Combo_Add_Item DescVal DataVal // first may get altered
   108    Set RowIdNumber itm to riID
   109   End_Procedure
   110
   111   { MethodType=Event }
   112   Procedure Combo_Fill_List
   113      Send Combo_Fill_list_Local
   114   End_Procedure // Combo_Fill_list
   115
   116   { Visibility=Private }
   117   Function Next_Code_Record returns integer
   118   end_function
   119
   120   //
   121   //  Fill the radio list from a file.
   122   //
   123   { Visibility=Private }
   124   Procedure Combo_Fill_List_Local
   125      Integer Obj# Code#
   126      String Code Desc Type
   127      Set Relational_state to False
   128      Get Code_Load_Object to Obj# // object to do the finding for us
   129      If Obj# Begin                // only if obj exists
   130        Get Code_Field to Code#
   131        Send Initialize_File to Obj# ;
   132             (Code_File(self)) (Code_Index(self)) ;
   133             Code# (Description_Field(self)) ;
   134             (Type_Field(self)) (Type_Value(self))
   135        //
   136        While (Next_Code_Record(Obj#))  // rets TRUE if rec exists
   137          Get Current_Description of Obj# to Desc
   138          If Code# gt 0 Get Current_Code of Obj# to Code
   139          Else Move Desc to Code
   140          Send Combo_Add_Item Desc Code
   141        Loop
   142      End
   143      Else Send Combo_Fill_List_From_File
   144   End_Procedure // Fill_list
   145
   146  // Fills the list by loading the entire defined data-file
   147  //
   148  { Visibility=Private }
   149  Procedure Combo_Fill_List_From_File
   150    integer dFile dField Srvr Ndx dFile2 DescField
   151    Get Server to Srvr
   152    If Srvr Begin
   153       get Combo_Data_File  to dFile
   154       Get Data_File        to dFile2
   155       If dFile eq CURRENT ;
   156          Move dFile2 to dFile
   157       if dFIle gt 0 begin
   158          Set Relational_State to (dFile2 eq dFile)
   159          get Code_Field to dField
   160          Get Description_Field to DescField
   161          If dField eq CURRENT ;
   162             Get Data_Field to dField
   163          Get Combo_Index to ndx
   164          if ndx eq CURRENT ;
   165             Get File_Field_Index of Srvr dFile dfield to ndx
   166          Send Request_Read to Srvr FIRST_RECORD dFile Ndx
   167          While [Found]
   168              Send Combo_Add_record dFile dField descField
   169              Send Request_Read to Srvr NEXT_RECORD DFile Ndx
   170          End
   171       End
   172    End
   173  End_procedure
   174
   175  // Removed
   176//  //Doc/ MethodType=Property Visibility=Private
   177//  Function Combo_Current_record Returns Integer
   178//    integer rec# Itm
   179//    String Val
   180//    Get Value Item 0 to Val
   181//    Get Combo_item_matching Val to Itm
   182//    If Itm ge 0 ; // if value is found
   183//       Get Record_Number item itm to Rec#
   184//    Function_Return rec#
   185//  End_Function
   186
   187  { MethodType=Property Visibility=Private }
   188  Function ComboCurrentRowId Returns RowId
   189    integer iItm
   190    String sVal
   191    RowId riId
   192    Get Value 0 to sVal
   193    Get Combo_item_matching sVal to iItm
   194    If (iItm=>0) Begin // if value is found
   195       Get RowIdNumber iItm to riId
   196    end
   197    Function_Return riId
   198  End_Function
   199
   200  { Visibility=Private }
   201  Procedure Combo_find_Current_record
   202    integer iSrvr iFile
   203    RowId riId
   204    get server to iSrvr
   205    Get Data_File to iFile
   206    if (iSrvr AND iFile AND Relational_State(self)) Begin
   207       //Get Combo_Current_Record to iRec
   208       //If iRec Send Find_by_recnum to iSrvr iFile iRec
   209       Get ComboCurrentRowid to riId
   210       Send FindByRowId of iSrvr iFile riId
   211    end
   212  End_Procedure
   213
   214  { MethodType=Event  NoDoc=True }
   215  Procedure Combo_Item_Changed
   216    // Set item_Changed_State item 0 to true // Forward does this
   217    Forward send Combo_item_Changed
   218    Send Combo_find_Current_record
   219  end_Procedure
   220
   221  { MethodType=Event  NoDoc=True }
   222  Procedure Combo_Edit_Changed
   223    // Set item_Changed_State item 0 to true // forward does this
   224    Forward send Combo_edit_changed
   225    Send Combo_find_Current_record
   226  end_Procedure
   227
   228  // These are created to keep the compiler happy. These are defined in the
   229  // code lists. When not used, these messages must be understood even if
   230  // they are never accessed
   231  //
   232  { Visibility=Private }
   233  Procedure Initialize_File
   234  End_Procedure // Initialize_file
   235
   236  { MethodType=Property Visibility=Private }
   237  Function Current_Description returns String
   238  End_Function // Current_Description
   239
   240  { MethodType=Property Visibility=Private }
   241  Function Current_Code Returns String
   242  End_Function // Current_Code
   243End_Class
   244
   245Use DD_Deomx.pkg // mixin support for dd classes
   246Use DD_Cmbmx.pkg // mixin support for combo classes and DD
   247
   248{ ClassType=Abstract }
   249{ HelpTopic=dbComboFormDD_ }
   250Class dbComboFormDD_ is a dbComboFormDS
   251    Import_Class_Protocol Extended_DEO_Mixin
   252    Import_Class_Protocol Extended_DEO_Status_Help_Mixin
   253    //Import_Class_Protocol Extended_DEO_Single_Item_Mixin
   254    Import_Class_Protocol Extended_DEO_Status_Help_Tooltip_Mixin
   255End_Class
   256
   257// we must mix at two levels because this mixin augments some DD
   258// procedures from the above
   259{ HelpTopic=dbComboForm }
   260Class dbComboForm is a dbComboFormDD_
   261    Import_Class_Protocol Extended_Deo_dfCombo_mixin
   262End_Class
   263
   264