Added code to prevent a user from subclassing FirstResponder.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20456 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-12-15 02:10:54 +00:00
parent 2435542dcc
commit 4f20e420d3
2 changed files with 33 additions and 20 deletions

View file

@ -1,3 +1,8 @@
2004-12-14 21:04 Gregory John Casamento <greg_casamento@yahoo.com>
* GormClassEditor.m: Added code in pasteInSelection to prevent
the user from pasting a subclass onto FirstResponder.
2004-12-14 06:53 Gregory John Casamento <greg_casamento@yahoo.com>
* GormClassEditor.m: Further correction to previous issue.

View file

@ -397,33 +397,41 @@ NSString *GormClassPboardType = @"GormClassPboardType";
{
if(selectedClass != nil)
{
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSArray *types = [pb types];
if([types containsObject: GormClassPboardType])
if([selectedClass isEqual: @"FirstResponder"] == NO)
{
id classPlist = [pb propertyListForType: GormClassPboardType];
NSDictionary *classesDict = [NSDictionary dictionaryWithDictionary: classPlist];
id name = nil;
NSEnumerator *en = [classesDict keyEnumerator];
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSArray *types = [pb types];
while((name = [en nextObject]) != nil)
if([types containsObject: GormClassPboardType])
{
NSDictionary *classDict = [classesDict objectForKey: name];
NSString *className = [classManager uniqueClassNameFrom: name];
BOOL added = [classManager addClassNamed: className
withSuperClassNamed: selectedClass
withActions: [classDict objectForKey: @"Actions"]
withOutlets: [classDict objectForKey: @"Outlets"]];
if(!added)
id classPlist = [pb propertyListForType: GormClassPboardType];
NSDictionary *classesDict = [NSDictionary dictionaryWithDictionary: classPlist];
id name = nil;
NSEnumerator *en = [classesDict keyEnumerator];
while((name = [en nextObject]) != nil)
{
NSString *message = [NSString stringWithFormat: @"Addition of %@ with superclass %@ failed.", className,
selectedClass];
NSRunAlertPanel(_(@"Problem pasting class"),
message, nil, nil, nil);
NSDictionary *classDict = [classesDict objectForKey: name];
NSString *className = [classManager uniqueClassNameFrom: name];
BOOL added = [classManager addClassNamed: className
withSuperClassNamed: selectedClass
withActions: [classDict objectForKey: @"Actions"]
withOutlets: [classDict objectForKey: @"Outlets"]];
if(!added)
{
NSString *message = [NSString stringWithFormat: @"Addition of %@ with superclass %@ failed.", className,
selectedClass];
NSRunAlertPanel(_(@"Problem pasting class"),
message, nil, nil, nil);
}
}
}
}
else
{
NSRunAlertPanel(_(@"Problem pasting class"),
_(@"FirstResponder cannot have subclasses."), nil, nil, nil);
}
}
}
@end