home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / WebObjects / WebObjectsDoc_HTML / Reuse / ReusableComponentsEx / ObjectArrayEditor.wo / ObjectArrayEditor.wos < prev   
Encoding:
Text File  |  1996-02-29  |  1.5 KB  |  91 lines

  1. ////////////////////////
  2. //  ObjectArrayEditor
  3. //  by Charles Lloyd
  4. ////////////////////////
  5.  
  6.  
  7.  
  8. ///////////////////
  9. //    User Options
  10. ///////////////////
  11. id labelArray;
  12. id keyArray;
  13. id objectArray;
  14. id columnWidthArray;
  15. id isEditable;
  16.  
  17. id borderSize;
  18. id cellPadding;
  19. id cellSpacing;
  20.  
  21. ////////////////////
  22. //  Internal State
  23. ////////////////////
  24. id colCount;
  25. id rowCount;
  26. id colIndex;
  27. id rowIndex;
  28. id fieldSize;
  29.  
  30. id labelString;
  31. id valueString;
  32.  
  33.  
  34. - awake
  35. {
  36.     borderSize = 1;
  37.     cellSpacing = 0;
  38.     cellPadding = 2;
  39.     fieldSize = 12;
  40. }
  41.  
  42. - setLabelArray:anArray
  43. {
  44.     labelArray = anArray;
  45.     colCount = [labelArray count];
  46. }
  47.  
  48. - setObjectArray:anArray
  49. {
  50.     objectArray = anArray;
  51.     rowCount = [objectArray count];
  52. }
  53.  
  54. - labelString
  55. {
  56.     return [labelArray objectAtIndex:colIndex];
  57. }
  58.  
  59. - valueString
  60. {
  61.     id aKey = [keyArray objectAtIndex:colIndex];
  62.     id anObject = [objectArray objectAtIndex:rowIndex];
  63.     id aDict = [anObject valuesForKeys:keyArray];
  64.     return [aDict objectForKey:aKey];
  65. }
  66.  
  67. - fieldSize
  68. {
  69.     if (columnWidthArray) {
  70.         return [columnWidthArray objectAtIndex:colIndex];
  71.     }
  72.     return fieldSize;
  73. }
  74.  
  75. - setValueString:aValue
  76. {
  77.     id aKey;
  78.     id aDict;
  79.     id aTargetObject;
  80.     if (!aValue) {
  81.         return nil;
  82.     }
  83.     aDict = [NSMutableDictionary dictionary];
  84.     aKey = [keyArray objectAtIndex:colIndex];
  85.     [aDict setObject:aValue forKey:aKey];
  86.     aTargetObject = [objectArray objectAtIndex:rowIndex];
  87.     [aTargetObject takeValuesFromDictionary:aDict];
  88. }
  89.  
  90.  
  91.