home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright (c) 1996, NeXT Software, Inc.
- All rights reserved.
-
- You may freely copy, distribute and reuse the code in this example.
- NeXT disclaims any warranty of any kind, expressed or implied,
- as to its fitness for any particular use.
- */
- #import "ProductReturn.h"
- #import "OneObjectDataSource.h"
-
- @implementation ProductReturn
-
- - initWithCustomerGlobalID:(EOGlobalID *)gid parentEditingContext:(EOEditingContext *)ctx
- {
-
- [super init];
-
- //
- // Load the nib file
- //
- // Make sure the nib create a SUB editing context
- //
- [EOEditingContext setSubstitutionEditingContext:nil];
- [EOEditingContext setDefaultParentObjectStore:ctx];
-
- if (![NSBundle loadNibNamed:@"ProductReturn" owner:self]) {
- NSLog(@"Unable to load nib file: Transaction.nib, exiting");
- exit(1);
- }
-
- // Reset the default !
- [EOEditingContext setDefaultParentObjectStore:[EOObjectStoreCoordinator defaultCoordinator]];
-
- //
- // Install the customer in a custom datasource
- //
- [customerDisplayGroup setDataSource:[[[OneObjectDataSource alloc] initWithGlobalID:gid editingContext:[[customerDisplayGroup dataSource] editingContext]] autorelease]];
-
- // Fetch the customer
- //
- [customerDisplayGroup fetch];
-
- [NSApp runModalForWindow:panel];
-
- [panel close];
- [customerDisplayGroup setDataSource:nil];
- return self;
- }
-
- - (void)save:sender
- {
- [[[customerDisplayGroup dataSource] editingContext] saveChanges];
- [NSApp stopModal];
- }
-
- - (void)cancel:sender
- {
- [NSApp stopModal];
- }
-
- @end
-