diff --git a/ChangeLog b/ChangeLog index 4c95a4b0..a03abe03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-12-31 21:22-EST Gregory John Casamento + + * English.lproj/GormInconsistenciesPanel.gorm: Error panel to show + detected inconsistencies. + * English.lproj/GormPrefGeneral.gorm: Added option to turn on + repair method. + * GNUmakefile: Added reference to new gorm file. + * GormCore/GormGormWrapperLoader.m: Added code to bring up the + new panel and show the errors. + * GormPrefs/GormGeneralPref.[mh]: Added new method and ivar to + handle switch for consistency checking. + 2007-12-19 19:03-EST Gregory John Casamento * GormCore/GormGormWrapperLoader.m diff --git a/English.lproj/GormInconsistenciesPanel.gorm/data.classes b/English.lproj/GormInconsistenciesPanel.gorm/data.classes new file mode 100644 index 00000000..c4293162 --- /dev/null +++ b/English.lproj/GormInconsistenciesPanel.gorm/data.classes @@ -0,0 +1,20 @@ +{ + "## Comment" = "Do NOT change this file, Gorm maintains it"; + GormGormWrapperLoader = { + Actions = ( + ); + Outlets = ( + message, + textField, + panel + ); + Super = GormWrapperLoader; + }; + GormWrapperLoader = { + Actions = ( + ); + Outlets = ( + ); + Super = NSObject; + }; +} \ No newline at end of file diff --git a/English.lproj/GormInconsistenciesPanel.gorm/data.info b/English.lproj/GormInconsistenciesPanel.gorm/data.info new file mode 100644 index 00000000..aa4d5224 Binary files /dev/null and b/English.lproj/GormInconsistenciesPanel.gorm/data.info differ diff --git a/English.lproj/GormInconsistenciesPanel.gorm/objects.gorm b/English.lproj/GormInconsistenciesPanel.gorm/objects.gorm new file mode 100644 index 00000000..8b53ca3d Binary files /dev/null and b/English.lproj/GormInconsistenciesPanel.gorm/objects.gorm differ diff --git a/English.lproj/GormPrefGeneral.gorm/data.classes b/English.lproj/GormPrefGeneral.gorm/data.classes index 568a8e91..49dcb616 100644 --- a/English.lproj/GormPrefGeneral.gorm/data.classes +++ b/English.lproj/GormPrefGeneral.gorm/data.classes @@ -4,6 +4,7 @@ Actions = ( "archiveAction:", "classesAction:", + "consistencyAction:", "orderFrontFontPanel:" ); Super = NSObject; @@ -14,7 +15,8 @@ "inspectorAction:", "backupAction:", "archiveAction:", - "classesAction:" + "classesAction:", + "consistencyAction:" ); Outlets = ( window, @@ -22,7 +24,8 @@ inspectorButton, backupButton, archiveMatrix, - interfaceMatrix + interfaceMatrix, + checkConsistency ); Super = NSObject; }; diff --git a/English.lproj/GormPrefGeneral.gorm/data.info b/English.lproj/GormPrefGeneral.gorm/data.info index 152bdecf..aa4d5224 100644 Binary files a/English.lproj/GormPrefGeneral.gorm/data.info and b/English.lproj/GormPrefGeneral.gorm/data.info differ diff --git a/English.lproj/GormPrefGeneral.gorm/objects.gorm b/English.lproj/GormPrefGeneral.gorm/objects.gorm index ebd20a0b..45cc7a78 100644 Binary files a/English.lproj/GormPrefGeneral.gorm/objects.gorm and b/English.lproj/GormPrefGeneral.gorm/objects.gorm differ diff --git a/GNUmakefile b/GNUmakefile index 33026480..ab9c1f83 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -145,6 +145,7 @@ Gorm_LOCALIZED_RESOURCE_FILES = \ GormHelpInspector.gorm \ Gorm.gorm \ GormImageInspector.gorm \ + GormInconsistenciesPanel.gorm \ GormInspectorPanel.gorm \ GormObjectInspector.gorm \ GormNSSplitViewInspector.gorm \ diff --git a/GormCore/GormGormWrapperLoader.m b/GormCore/GormGormWrapperLoader.m index 2fd332fe..8934e442 100644 --- a/GormCore/GormGormWrapperLoader.m +++ b/GormCore/GormGormWrapperLoader.m @@ -36,6 +36,12 @@ #include @interface GormGormWrapperLoader : GormWrapperLoader +{ + NSMutableArray *_repairLog; + id message; + id textField; + id panel; +} @end @implementation GormGormWrapperLoader @@ -44,6 +50,44 @@ return @"GSGormFileType"; } +- (id) init +{ + if((self = [super init]) != nil) + { + _repairLog = [[NSMutableArray alloc] init]; + } + return self; +} + +- (void) dealloc +{ + RELEASE(_repairLog); + [super dealloc]; +} + +- (void) _openMessagePanel: (NSString *) msg +{ + NSEnumerator *en = [_repairLog objectEnumerator]; + id m = nil; + + if([NSBundle loadNibNamed: @"GormInconsistenciesPanel" + owner: self] == NO) + { + NSLog(@"Failed to open message panel..."); + } + else + { + [message setStringValue: msg]; + + while((m = [en nextObject]) != nil) + { + [textField insertText: m]; + } + + [panel orderFront: self]; + } +} + /** * The sole purpose of this method is to clean up .gorm files from older * versions of Gorm which might have some dangling references. This method @@ -80,7 +124,9 @@ if(sm == nil) { NSArray *menus = findAll(obj); - NSLog(@"Found and removed a dangling menu %@, %@.",obj,[document nameForObject: obj]); + [_repairLog addObject: + [NSString stringWithFormat: @"ERROR ==> Found and removed a dangling menu %@, %@.\n", + obj,[document nameForObject: obj]]]; [document detachObjects: menus]; [document detachObject: obj]; @@ -104,7 +150,9 @@ { id sm = [obj submenu]; - NSLog(@"Found and removed a dangling menu item %@, %@.",obj,[document nameForObject: obj]); + [_repairLog addObject: + [NSString stringWithFormat: @"ERROR ==> Found and removed a dangling menu item %@, %@.\n", + obj,[document nameForObject: obj]]]; [document detachObject: obj]; // if there are any submenus, detach those as well. @@ -133,21 +181,24 @@ { [document attachObject: v toParent: [v superview]]; name = [document nameForObject: v]; - NSLog(@"==> Found view %@ without an associated name, adding to the nametable as %@", v, name); + [_repairLog addObject: + [NSString stringWithFormat: + @"ERROR ==> Found view %@ without an associated name, adding to the nametable as %@\n", + v, name]]; if([v respondsToSelector: @selector(stringValue)]) { - NSLog(@"View string value is %@",[v stringValue]); + [_repairLog addObject: [NSString stringWithFormat: @"INFO: View string value is %@\n",[v stringValue]]]; } errorCount++; } - NSLog(@"Found view %@ with name %@", v, name); + [_repairLog addObject: [NSString stringWithFormat: @"INFO: Checking view %@ with name %@\n", v, name]]; } } } [document reactivateEditors]; /** - * Iterate over all connections... + * Iterate over all connections... remove connections with nil sources. */ en = [connections objectEnumerator]; while((con = [en nextObject]) != nil) @@ -156,14 +207,8 @@ { if([con source] == nil) { - NSLog(@"==> Removing bad connector with nil source: %@",con); - [document removeConnector: con]; - errorCount++; - } - - if([con destination] == nil) - { - NSLog(@"==> Removing bad connector with nil destination: %@",con); + [_repairLog addObject: + [NSString stringWithFormat: @"ERROR ==> Removing bad connector with nil source: %@\n",con]]; [document removeConnector: con]; errorCount++; } @@ -174,9 +219,7 @@ if(errorCount > 0) { errorMsg = [NSString stringWithFormat: @"%d inconsistencies were found, please save the file.",errorCount]; - NSRunAlertPanel(_(@"Warning"), - errorMsg, - nil, nil, nil); + [self _openMessagePanel: errorMsg]; } } diff --git a/GormPrefs/GormGeneralPref.h b/GormPrefs/GormGeneralPref.h index d29b0966..24e7ef9d 100644 --- a/GormPrefs/GormGeneralPref.h +++ b/GormPrefs/GormGeneralPref.h @@ -9,7 +9,7 @@ id window; id backupButton; id interfaceMatrix; - + id checkConsistency; id _view; } @@ -27,6 +27,8 @@ * Show the classes view as a browser or an outline. */ - (void) classesAction: (id)sender; + +- (void) consistencyAction: (id)sender; @end diff --git a/GormPrefs/GormGeneralPref.m b/GormPrefs/GormGeneralPref.m index 18e88d40..43c456b3 100644 --- a/GormPrefs/GormGeneralPref.m +++ b/GormPrefs/GormGeneralPref.m @@ -36,6 +36,7 @@ static NSString *BACKUPFILE=@"BackupFile"; static NSString *INTTYPE=@"ClassViewType"; +static NSString *REPAIRFILE=@"GormRepairFileOnLoad"; @implementation GormGeneralPref @@ -59,6 +60,7 @@ static NSString *INTTYPE=@"ClassViewType"; NSString *intType = [defaults stringForKey: INTTYPE]; [backupButton setState: [defaults integerForKey: BACKUPFILE]]; + [checkConsistency setState: ([defaults boolForKey: REPAIRFILE]?NSOnState:NSOffState)]; // set the interface matrix... if([intType isEqual: @"Outline"]) @@ -89,38 +91,35 @@ static NSString *INTTYPE=@"ClassViewType"; - (void) backupAction: (id)sender { - if (sender != backupButton) - return; - else - { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - [defaults setInteger:[backupButton state] forKey:BACKUPFILE]; - } + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + [defaults setInteger:[backupButton state] forKey:BACKUPFILE]; } - (void) classesAction: (id)sender { - if (sender != interfaceMatrix) - return; - else + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + // NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; + + if([[interfaceMatrix cellAtRow: 0 column: 0] state] == NSOnState) { - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - // NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - - if([[interfaceMatrix cellAtRow: 0 column: 0] state] == NSOnState) - { - [defaults setObject: @"Outline" forKey: INTTYPE]; - } - else if([[interfaceMatrix cellAtRow: 1 column: 0] state] == NSOnState) - { - [defaults setObject: @"Browser" forKey: INTTYPE]; - } - - // let the world know it's changed. - // [nc postNotificationName: GormSwitchViewPreferencesNotification - // object: nil]; - + [defaults setObject: @"Outline" forKey: INTTYPE]; } + else if([[interfaceMatrix cellAtRow: 1 column: 0] state] == NSOnState) + { + [defaults setObject: @"Browser" forKey: INTTYPE]; + } + + // let the world know it's changed. + // [nc postNotificationName: GormSwitchViewPreferencesNotification + // object: nil]; + +} + +- (void) consistencyAction: (id)sender +{ + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + [defaults setBool: (([checkConsistency state] == NSOnState)?YES:NO) + forKey: REPAIRFILE]; } @end