cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From torehal...@apache.org
Subject svn commit: r472255 - in /incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne: CAYObjectContext.h CAYObjectContext.m CAYPersistentObject.m
Date Tue, 07 Nov 2006 20:58:22 GMT
Author: torehalset
Date: Tue Nov  7 12:58:21 2006
New Revision: 472255

URL: http://svn.apache.org/viewvc?view=rev&rev=472255
Log:
 * started to think about NSUndoManager support
 * willChange/didChange notification stuff for entity properties

Modified:
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h?view=diff&rev=472255&r1=472254&r2=472255
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.h Tue Nov  7 12:58:21
2006
@@ -29,6 +29,7 @@
     NSMutableArray *diffs;
     CAYEntityResolver *entityResolver;
     NSMutableDictionary *objectByObjectId;
+    NSUndoManager *undoManager;
 }
 
 -(NSArray *)performQuery:(CAYQuery *)query error:(NSError **)outError;
@@ -49,6 +50,9 @@
 -(void)registerNewObject:(CAYPersistentObject *)o;
 
 -(void)prepareForAccess:(CAYPersistentObject *)object forProperty:(NSString *)property withLazyFetching:(BOOL)lazyFaulting;
+
+-(void)setUndoManager:(NSUndoManager *)undoManager;
+-(NSUndoManager *)undoManager;
 
 -(void)updateClassMapping;
 

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m?view=diff&rev=472255&r1=472254&r2=472255
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYObjectContext.m Tue Nov  7 12:58:21
2006
@@ -424,6 +424,18 @@
     // TODO: resolve faults?
 }
 
+-(void)setUndoManager:(NSUndoManager *)um
+{
+    [um retain];
+    [undoManager release];
+    undoManager = um;
+}
+
+-(NSUndoManager *)undoManager
+{
+    return undoManager;
+}
+
 -(void)updateClassMapping
 {
     if([self entityResolver])
@@ -449,6 +461,7 @@
     diffs = nil;
     [objectByObjectId release];
     objectByObjectId = nil;
+    [self setUndoManager:nil];
 	[super dealloc];
 }
 

Modified: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m
URL: http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m?view=diff&rev=472255&r1=472254&r2=472255
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m (original)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYPersistentObject.m Tue Nov  7 12:58:21
2006
@@ -32,6 +32,7 @@
 @interface CAYPersistentObject (PrivateMethods) 
 
 -(void)createValidationError:(NSString *)errorMessage code:(int)errorCode error:(NSError
**)outError;
+-(NSUndoManager *)undoManager;
 
 @end
 
@@ -164,6 +165,7 @@
 -(void)setPrimitiveValue:(id)value forKey:(NSString *)key;
 {
     // NSLog(@"DEBUG: set value %@ for key %@ of type %@", value, key, [value class]);
+    [self willChangeValueForKey:key];
     
     // see if the key is a relationship
     CAYObjEntity *objEntity = [[[self objectContext] entityResolver] lookupObjEntity:self];
@@ -232,6 +234,8 @@
         CAYObjAttribute *attribute = [[objEntity attributes] valueForKey:key];
         NSLog(@"DEBUG: %@.%@. attribute: %@. oldValue: %@. oldValue class: %@",[objEntity
name], key, attribute, oldValue, [oldValue class]);
     }
+    
+    [self didChangeValueForKey:key];
 }
 
 // this method is called if setValue:forKey: was not able to find a user defined set method
for the key
@@ -559,6 +563,11 @@
                                                  code:errorCode
                                              userInfo:userInfoDict] autorelease];
     *outError = error;
+}
+
+-(NSUndoManager *)undoManager
+{
+    return [[self objectContext] undoManager];
 }
 
 @end



Mime
View raw message