Improved gmodel importation.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19273 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2004-05-09 14:19:52 +00:00
parent edfcf12f7c
commit eb3003446b
3 changed files with 84 additions and 26 deletions

View file

@ -1,3 +1,14 @@
2004-05-09 10:16 Gregory John Casamento <greg_casamento@yahoo.com>
* GModelDecoder.m: defineClass:inFile: changed signature
to take the object and get the classname from it. This allows
a call to add the class under an assumed superclass, if the user
says no to the query. Also in loadGModel: added code to pull
the outlet/action from the connections and add them to the class
if they are not present on the imported header. This also allows,
in the above case, for Gorm to automatically get all outlets/actions
from the gmodel.
2004-05-08 08:53 Gregory John Casamento <greg_casamento@yahoo.com>
* GormDocument.m: [GormDocument loadDocument:] added code

View file

@ -191,8 +191,9 @@ static BOOL gormFileOwnerDecoded;
is, and at best, we could search the connections to see what
outlets and actions are used.
*/
- (void) defineClass: (NSString *)classname inFile: (NSString *)path
- (void) defineClass: (id)object inFile: (NSString *)path
{
NSString *classname = [object className];
int result;
NSString *header;
NSFileManager *mgr;
@ -237,9 +238,36 @@ static BOOL gormFileOwnerDecoded;
}
}
/* For now, just punt if we have no header. */
// make a guess and warn the user
if (result != NSAlertDefaultReturn)
return;
{
NSString *superClass = nil;
BOOL added = NO;
if([object isKindOfClass: [GormCustomView class]])
{
superClass = @"NSView";
}
else
{
superClass = @"NSObject";
}
added = [classManager addClassNamed: classname
withSuperClassNamed: superClass
withActions: [NSMutableArray array]
withOutlets: [NSMutableArray array]];
// inform the user...
if(added)
{
NSLog(@"Added class %@ with superclass of %@.", classname, superClass);
}
else
{
NSLog(@"Failed to add class %@ with superclass of %@.", classname, superClass);
}
}
[self parseHeader: header];
}
@ -268,7 +296,6 @@ static BOOL gormFileOwnerDecoded;
NSArray *gmobjects;
NSArray *gmconnections;
Class u = gmodel_class(@"GMUnarchiver");
GormClassManager *classManager = [(Gorm *)NSApp classManager];
NSLog (@"Loading gmodel file %@...", path);
gormNibOwner = nil;
@ -312,29 +339,10 @@ static BOOL gormFileOwnerDecoded;
if (gormNibOwner)
{
[self defineClass: [gormNibOwner className] inFile: path];
[self defineClass: gormNibOwner inFile: path];
[filesOwner setClassName: [gormNibOwner className]];
}
enumerator = [gmconnections objectEnumerator];
while ((con = [enumerator nextObject]) != nil)
{
NSNibConnector *newcon;
id source, dest;
source = [self connectionObjectForObject: [con source]];
dest = [self connectionObjectForObject: [con destination]];
if ([con isKindOfClass: NSClassFromString(@"NSIBOutletConnector")])
newcon = AUTORELEASE([[NSNibOutletConnector alloc] init]);
else
newcon = AUTORELEASE([[NSNibControlConnector alloc] init]);
[newcon setSource: source];
[newcon setDestination: dest];
[newcon setLabel: [con label]];
[connections addObject: newcon];
}
/*
* Now we merge the objects from the gmodel into our own data
* structures.
@ -348,9 +356,49 @@ static BOOL gormFileOwnerDecoded;
if([obj isKindOfClass: [GormObjectProxy class]])
{
NSLog(@"processing... %@",[obj className]);
[self defineClass: [obj className] inFile: path];
[self defineClass: obj inFile: path];
}
}
// build connections...
enumerator = [gmconnections objectEnumerator];
while ((con = [enumerator nextObject]) != nil)
{
NSNibConnector *newcon;
id source, dest;
source = [self connectionObjectForObject: [con source]];
dest = [self connectionObjectForObject: [con destination]];
NSLog(@"connector = %@",con);
if ([[con className] isEqual: @"IMOutletConnector"]) // We don't link the gmodel library at compile time...
{
newcon = AUTORELEASE([[NSNibOutletConnector alloc] init]);
if(![classManager isOutlet: [con label]
ofClass: [source className]])
{
[classManager addOutlet: [con label]
forClassNamed: [source className]];
}
}
else
{
newcon = AUTORELEASE([[NSNibControlConnector alloc] init]);
if(![classManager isAction: [con label]
ofClass: [dest className]])
{
[classManager addAction: [con label]
forClassNamed: [dest className]];
}
}
NSLog(@"conn = %@ source = %@ dest = %@ label = %@, src name = %@ dest name = %@", newcon, source, dest,
[con label], [source className], [dest className]);
[newcon setSource: source];
[newcon setDestination: dest];
[newcon setLabel: [con label]];
[connections addObject: newcon];
}
if ([gormRealObject isKindOfClass: [GModelApplication class]])
{
enumerator = [[gormRealObject windows] objectEnumerator];

View file

@ -253,7 +253,6 @@
{
[self addOutlet: outlet forClassNamed: subclassName];
}
}
- (void) replaceAction: (NSString *)oldAction