home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / EODEV.Z / ProductReturn.m < prev    next >
Encoding:
Text File  |  1996-08-31  |  1.6 KB  |  63 lines

  1. /*
  2.         Copyright (c) 1996, NeXT Software, Inc.
  3.         All rights reserved.
  4.  
  5.         You may freely copy, distribute and reuse the code in this example.
  6.         NeXT disclaims any warranty of any kind, expressed or implied,
  7.         as to its fitness for any particular use.
  8. */
  9. #import "ProductReturn.h"
  10. #import "OneObjectDataSource.h"
  11.  
  12. @implementation ProductReturn
  13.  
  14. - initWithCustomerGlobalID:(EOGlobalID *)gid parentEditingContext:(EOEditingContext *)ctx
  15. {
  16.     
  17.     [super init];
  18.  
  19.     //
  20.     // Load the nib file
  21.     //
  22.     // Make sure the nib create a SUB editing context
  23.     //
  24.     [EOEditingContext setSubstitutionEditingContext:nil];
  25.     [EOEditingContext setDefaultParentObjectStore:ctx];
  26.  
  27.     if (![NSBundle loadNibNamed:@"ProductReturn" owner:self]) {
  28.         NSLog(@"Unable to load nib file: Transaction.nib, exiting");
  29.         exit(1);
  30.     }
  31.  
  32.     // Reset the default !
  33.     [EOEditingContext setDefaultParentObjectStore:[EOObjectStoreCoordinator defaultCoordinator]];
  34.  
  35.     //
  36.     // Install the customer in a custom datasource
  37.     //
  38.     [customerDisplayGroup setDataSource:[[[OneObjectDataSource alloc] initWithGlobalID:gid editingContext:[[customerDisplayGroup dataSource] editingContext]] autorelease]];
  39.  
  40.     // Fetch the customer
  41.     //
  42.     [customerDisplayGroup fetch];
  43.  
  44.     [NSApp runModalForWindow:panel];
  45.  
  46.     [panel close];
  47.     [customerDisplayGroup setDataSource:nil];
  48.     return self;
  49. }
  50.  
  51. - (void)save:sender
  52. {
  53.     [[[customerDisplayGroup dataSource] editingContext] saveChanges];
  54.     [NSApp stopModal];
  55. }
  56.  
  57. - (void)cancel:sender
  58. {
  59.     [NSApp stopModal];
  60. }
  61.  
  62. @end
  63.