diff --git a/GormCore/GormAbstractDelegate.m b/GormCore/GormAbstractDelegate.m index 1f017509..b9159b19 100644 --- a/GormCore/GormAbstractDelegate.m +++ b/GormCore/GormAbstractDelegate.m @@ -149,7 +149,8 @@ [super dealloc]; } -// Gorm specific methods... +// Handle all alerts here... + - (BOOL) shouldUpgradeOlderArchive { NSInteger retval = NSRunAlertPanel(_(@"Compatibility Warning"), @@ -208,9 +209,8 @@ { NSString *title; NSString *msg; - NSInteger retval; - BOOL removed = YES; - + NSInteger retval = -1; + if(prompted == NO) { title = [NSString stringWithFormat: @@ -224,6 +224,25 @@ return (retval == NSAlertDefaultReturn); } +- (void) couldNotParseClassAtPath: (NSString *)path +{ + NSString *file = [path lastPathComponent]; + NSString *message = [NSString stringWithFormat: + _(@"Unable to parse class in %@"),file]; + NSRunAlertPanel(_(@"Problem parsing class"), + message, + nil, nil, nil); +} + +- (void) exceptionWhileParsingClass: (NSException *)localException +{ + NSString *message = [localException reason]; + NSRunAlertPanel(_(@"Problem parsing class"), + message, + nil, nil, nil); +} + +// Gorm specific methods... - (BOOL) isInTool { return NO; diff --git a/GormCore/GormDocument.m b/GormCore/GormDocument.m index 2c795de7..fd64b7f1 100644 --- a/GormCore/GormDocument.m +++ b/GormCore/GormDocument.m @@ -193,6 +193,7 @@ static NSImage *fileImage = nil; { NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + id delegate = [NSApp delegate]; // initialize... openEditors = [[NSMutableArray alloc] init]; @@ -271,20 +272,12 @@ static NSImage *fileImage = nil; { if(![classManager parseHeader: header]) { - NSString *file = [header lastPathComponent]; - NSString *message = [NSString stringWithFormat: - _(@"Unable to parse class in %@"),file]; - NSRunAlertPanel(_(@"Problem parsing class"), - message, - nil, nil, nil); + [delegate couldNotParseClassAtPath: header]; } } NS_HANDLER { - NSString *message = [localException reason]; - NSRunAlertPanel(_(@"Problem parsing class"), - message, - nil, nil, nil); + [delegate exceptionWhileParsingClass: localException]; } NS_ENDHANDLER; } diff --git a/GormCore/GormProtocol.h b/GormCore/GormProtocol.h index c395a186..ff23e987 100644 --- a/GormCore/GormProtocol.h +++ b/GormCore/GormProtocol.h @@ -54,11 +54,15 @@ // Check if we are in the app or the tool - (BOOL) isInTool; + +// Delegate methods to handle issues that may occur - (BOOL) shouldUpgradeOlderArchive; - (BOOL) shouldLoadNewerArchive; - (BOOL) shouldBreakConnectionsForClassNamed: (NSString *)className; - (BOOL) shouldRenameConnectionsForClassNamed: (NSString *)className toClassName: (NSString *)newName; - (BOOL) shouldBreakConnectionsModifyingLabel: (NSString *)name isAction: (BOOL)action prompted: (BOOL)prompted; +- (void) couldNotParseClassAtPath: (NSString *)path; +- (void) exceptionWhileParsingClass: (NSException *)localException; @end diff --git a/Tools/gormtool/AppDelegate.m b/Tools/gormtool/AppDelegate.m index 7b894c74..4265edfc 100644 --- a/Tools/gormtool/AppDelegate.m +++ b/Tools/gormtool/AppDelegate.m @@ -30,11 +30,14 @@ // AppDelegate... @implementation AppDelegate +// Are we in a tool? - (BOOL) isInTool { return YES; } +// Handle all alerts... + - (BOOL) shouldUpgradeOlderArchive { NSLog(@"Upgrading archive to latest version of .gorm format"); @@ -65,6 +68,18 @@ return YES; } +- (void) couldNotParseClassAtPath: (NSString *)path; +{ + NSLog(@"Could not parse class at path: %@", path); +} + +- (void) exceptionWhileParsingClass: (NSException *)localException +{ + NSLog(@"Exception while parsing class: %@", [localException reason]); +} + +// Handle arguments + - (NSDictionary *) parseArguments { GormDocumentController *dc = [GormDocumentController sharedDocumentController];