Add delegate methods to handle alerts for when we can't parse a class or get an exception for preloaded headers

This commit is contained in:
Gregory John Casamento 2023-07-18 15:54:57 -04:00
parent ce1dd3c483
commit 0fd5177c93
4 changed files with 45 additions and 14 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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

View file

@ -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];