From 1f430325c8e80a900f4c1253f741c655e97fb5d5 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Fri, 13 Feb 2004 03:38:01 +0000 Subject: [PATCH] Modifications to prevent problem in reparenting. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@18590 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 12 ++++++++++++ GormClassInspector.m | 33 +++++++++++++++++++++++++++++---- GormDocument.m | 10 ++++++++-- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 33a94779..e0d4778f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-02-12 22:42 Gregory John Casamento + + * GormClassInspector.m: Added category to allow direct manipulation + of the classes view from the class inspector. The new method is + - (void) collapseClass: (NSString *)className. + Modified [GormClassInspector selectClass:] to notify the user when + the change has been made and only proceed on confirmation. + Added code to delegate to prevent selection of a subclass of the + current class. + * GormDocument.m: Cleaned up some of the code formatting in + [GormDocument handleNotification:]. + 2004-02-12 02:02 Gregory John Casamento * GormClassInspector.m: Added new ivars/methods to support diff --git a/GormClassInspector.m b/GormClassInspector.m index d45e71c2..5549f49c 100644 --- a/GormClassInspector.m +++ b/GormClassInspector.m @@ -35,6 +35,11 @@ NSNotificationCenter *nc = nil; +// interfaces +@interface GormDocument (GormClassInspectorAdditions) +- (void) collapseClass: (NSString *)className; +@end + // the data source classes for each of the tables... @interface GormOutletDataSource : NSObject { @@ -57,6 +62,16 @@ NSNotificationCenter *nc = nil; - (void) setInspector: (id)ins; @end +// implementation +@implementation GormDocument (GormClassInspectorAdditions) +- (void) collapseClass: (NSString *)className +{ + NSDebugLog(@"%@",className); + [classesView expandItem: className]; + [classesView collapseItem: className]; +} +@end + @implementation GormOutletDataSource - (int) numberOfRowsInTableView: (NSTableView *)tv { @@ -373,15 +388,23 @@ objectValueForTableColumn: (NSTableColumn *)tc NSArray *list = [classManager allClassNames]; int row = [parentClass selectedRow]; NSString *newParent = [list objectAtIndex: row]; + NSString *name = [self _currentClass]; BOOL removed = NO; - [classManager setSuperClassNamed: newParent forClassNamed: [self _currentClass]]; + // check to see if the user wants to do this and remove the connections. removed = [(GormDocument *)[(id )NSApp activeDocument] - removeConnectionsForClassNamed: [self _currentClass]]; + removeConnectionsForClassNamed: name]; + + // if removed, move the class and notify... if(removed) { + NSString *oldSuper = [classManager superClassNameForClassNamed: name]; + + [classManager setSuperClassNamed: newParent forClassNamed: name]; [nc postNotificationName: IBInspectorDidModifyObjectNotification object: classManager]; + [(GormDocument *)[(id )NSApp activeDocument] collapseClass: oldSuper]; + [(GormDocument *)[(id )NSApp activeDocument] collapseClass: name]; } } @@ -464,9 +487,11 @@ shouldEditTableColumn: (NSTableColumn *)aTableColumn { NSArray *list = [classManager allClassNames]; NSString *className = [list objectAtIndex: rowIndex]; + NSString *name = [self _currentClass]; BOOL isFirstResponder = [className isEqualToString: @"FirstResponder"]; - BOOL isCurrentClass = [className isEqualToString: [self _currentClass]]; - if(isFirstResponder || isCurrentClass) + BOOL isCurrentClass = [className isEqualToString: name]; + BOOL isSubClass = [classManager isSuperclass: name linkedToClass: className]; + if(isFirstResponder || isCurrentClass || isSubClass) { NSBeep(); result = NO; diff --git a/GormDocument.m b/GormDocument.m index e2d173ce..75c704f4 100644 --- a/GormDocument.m +++ b/GormDocument.m @@ -1540,11 +1540,17 @@ static NSImage *classesImage = nil; } else if ([name isEqual: IBClassNameChangedNotification] == YES) { - if ([aNotification object] == classManager) [classesView reloadData]; + if ([aNotification object] == classManager) + { + [classesView reloadData]; + } } else if ([name isEqual: IBInspectorDidModifyObjectNotification] == YES) { - if ([aNotification object] == classManager) [classesView reloadData]; + if ([aNotification object] == classManager) + { + [classesView reloadData]; + } } }