Remove class instances for classes which are deleted from the class editor.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20460 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-12-16 10:38:14 +00:00
parent 4bf6880f87
commit 94bed640ce
6 changed files with 66 additions and 21 deletions

View file

@ -1,3 +1,16 @@
2004-12-16 05:32 Gregory John Casamento <greg_casamento@yahoo.com>
* GormClassEditor.m: added call to removeAllInstancesOfClass: in
deleteSelection so that no objects in the objectView can refer to
a class that doesn't have a correstponding class in the
class manager/class editor.
* GormClassManager.h: Added declaration for classNameForObject:.
* GormClassManager.m: Added implemented for classNameForObject:.
* GormDocument.h: Added declaration of removeAllInstancesOfClass:.
* GormDocument.m: Addition of method to remove all instances
from the objects view if a class is removed from the classes
view.
2004-12-15 01:43 Gregory John Casamento <greg_casamento@yahoo.com>
* GormClassEditor.m: Code from -changeView added to select

View file

@ -390,6 +390,7 @@ NSString *GormClassPboardType = @"GormClassPboardType";
if (removed)
{
[self copySelection];
[document removeAllInstancesOfClass: anitem];
[classManager removeClassNamed: anitem];
[self reloadData];
[nc postNotificationName: GormDidModifyClassNotification

View file

@ -113,6 +113,7 @@
- (BOOL) isCustomClassMapEmpty;
- (NSString *) nonCustomSuperClassOf: (NSString *)className;
- (BOOL) isAction: (NSString *)actionName onCategoryForClassNamed: (NSString *)className;
- (NSString *) classNameForObject: (id)object;
/* Parsing and creating classes */
- (BOOL) makeSourceAndHeaderFilesForClass: (NSString *)className

View file

@ -1729,6 +1729,16 @@
return result;
}
- (NSString *) classNameForObject: (id)object
{
NSString *className = [self customClassForObject: object];
if(className == nil)
{
className = [object className];
}
return className;
}
- (void) setCustomClass: (NSString *)className
forName: (NSString *)object
{

View file

@ -135,6 +135,7 @@
- (id) instantiateClass: (id)sender;
- (void) selectClass: (NSString *)className;
- (BOOL) classIsSelected;
- (void) removeAllInstancesOfClass: (NSString *)classNamed;
// sound & image support
- (id) openSound: (id)sender;

View file

@ -1588,6 +1588,22 @@ static NSImage *fileImage = nil;
return [classesView currentSelectionIsClass];
}
- (void) removeAllInstancesOfClass: (NSString *)className
{
NSArray *objects = [objectsView objects];
NSEnumerator *en = [objects objectEnumerator];
id object = nil;
while((object = [en nextObject]) != nil)
{
NSString *clsForObj = [classManager classNameForObject: object];
if([className isEqual: clsForObj])
{
[objectsView removeObject: object];
}
}
}
- (void) selectClass: (NSString *)className
{
[classesView selectClass: className];
@ -3202,13 +3218,16 @@ static NSImage *fileImage = nil;
}
// remove all.
while ((c = [en nextObject]) != nil)
if(removed)
{
// check both...
if ([[[c source] className] isEqualToString: className]
|| [[[c destination] className] isEqualToString: className])
while ((c = [en nextObject]) != nil)
{
[self removeConnector: c];
// check both...
if ([[[c source] className] isEqualToString: className]
|| [[[c destination] className] isEqualToString: className])
{
[self removeConnector: c];
}
}
}
@ -3242,27 +3261,27 @@ static NSImage *fileImage = nil;
}
// remove all.
while ((c = [en nextObject]) != nil)
if(removed)
{
id source = [c source];
id destination = [c destination];
// check both...
if ([[[c source] className] isEqualToString: className])
while ((c = [en nextObject]) != nil)
{
[source setClassName: newName];
NSDebugLog(@"Found matching source");
}
else if ([[[c destination] className] isEqualToString: className])
{
[destination setClassName: newName];
NSDebugLog(@"Found matching destination");
id source = [c source];
id destination = [c destination];
// check both...
if ([[[c source] className] isEqualToString: className])
{
[source setClassName: newName];
NSDebugLog(@"Found matching source");
}
else if ([[[c destination] className] isEqualToString: className])
{
[destination setClassName: newName];
NSDebugLog(@"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;