diff --git a/ChangeLog b/ChangeLog index 7f1007f4..c0572546 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2002-12-05 Gregory John Casamento + + * GormDocument.[mh]: Added method named + -[GormDocument renameConnectionsForClassNamed:toName:] + to rename the object in the object editor so that the + connections stay in sync w/ the new name. + * Gorm.m/GormPrivate.h: Added -[GormObjectProxy setClassName:] + 2002-12-04 Adam Fedor * Version: 0.2.0 diff --git a/Gorm.m b/Gorm.m index a7ad7ddd..95d43d03 100644 --- a/Gorm.m +++ b/Gorm.m @@ -146,6 +146,12 @@ NSString *GormLinkPboardType = @"GormLinkPboardType"; { return @"GormNotApplicableInspector"; } + +- (void) setClassName: (NSString *)className +{ + RELEASE(theClass); + theClass = [className copy]; +} @end // add methods to all of the template objects for use diff --git a/GormDocument.h b/GormDocument.h index 82c14195..b4c05810 100644 --- a/GormDocument.h +++ b/GormDocument.h @@ -118,6 +118,8 @@ forClassNamed: (NSString *)className isAction: (BOOL)action; - (BOOL) removeConnectionsForClassNamed: (NSString *)name; +- (BOOL) renameConnectionsForClassNamed: (NSString *)name + toName: (NSString *)newName; @end #endif diff --git a/GormDocument.m b/GormDocument.m index d94f0a29..0f88c477 100644 --- a/GormDocument.m +++ b/GormDocument.m @@ -2833,6 +2833,56 @@ static NSImage *classesImage = nil; return removed; } +- (BOOL) renameConnectionsForClassNamed: (NSString *)className + toName: (NSString *)newName +{ + NSEnumerator *en = [connections objectEnumerator]; + id c = nil; + BOOL removed = YES; + int retval = -1; + NSString *title = [NSString stringWithFormat: @"Modifying Class"]; + NSString *msg = [NSString stringWithFormat: + @"Change class name '%@' to '%@'. Continue?", + className, newName]; + + // ask the user if he/she wants to continue... + retval = NSRunAlertPanel(title,msg,@"OK",@"Cancel",nil,nil); + if(retval == NSAlertDefaultReturn) + { + removed = YES; + } + else + { + removed = NO; + } + + // remove all. + while((c = [en nextObject]) != nil) + { + id source = [c source]; + id destination = [c destination]; + + // check both... + if([[[c source] className] isEqualToString: className]) + { + [source setClassName: newName]; + NSLog(@"Found matching source"); + } + else if([[[c destination] className] isEqualToString: className]) + { + [destination setClassName: newName]; + NSLog(@"Found matching destination"); + } + } + + // Get the object from the object editor so that we can change the name + // there too. + + // done... + NSDebugLog(@"Changed references to actions/outlets for objects of %@", className); + return removed; +} + // --- NSOutlineView dataSource --- - (id) outlineView: (NSOutlineView *)anOutlineView objectValueForTableColumn: (NSTableColumn *)aTableColumn @@ -2931,8 +2981,8 @@ objectValueForTableColumn: (NSTableColumn *)aTableColumn { if(![anObject isEqualToString: @""]) { - BOOL removed = [self removeConnectionsForClassNamed: item]; - if(removed) + BOOL rename = [self renameConnectionsForClassNamed: item toName: anObject]; + if(rename) { [classManager renameClassNamed: item newName: anObject]; [self detachObject: [self objectForName: item]]; diff --git a/GormPrivate.h b/GormPrivate.h index ffcc9e83..051bdc35 100644 --- a/GormPrivate.h +++ b/GormPrivate.h @@ -26,6 +26,7 @@ extern NSString *GormLinkPboardType; * This is done so that we can provide our own decoding method * (GSNibItem tries to morph into the actual class) */ +- (void) setClassName: (NSString *)className; @end // Additions to template classes within gorm.