Added code and gorm file to show inconsistencies in gorm files when they are detected.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@25813 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2008-01-01 02:24:35 +00:00
parent c1f3e4d48c
commit d047746fce
11 changed files with 126 additions and 46 deletions

View file

@ -1,3 +1,15 @@
2007-12-31 21:22-EST Gregory John Casamento <greg_casamento@yahoo.com>
* 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 <greg_casamento@yahoo.com> 2007-12-19 19:03-EST Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormGormWrapperLoader.m * GormCore/GormGormWrapperLoader.m

View file

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

Binary file not shown.

View file

@ -4,6 +4,7 @@
Actions = ( Actions = (
"archiveAction:", "archiveAction:",
"classesAction:", "classesAction:",
"consistencyAction:",
"orderFrontFontPanel:" "orderFrontFontPanel:"
); );
Super = NSObject; Super = NSObject;
@ -14,7 +15,8 @@
"inspectorAction:", "inspectorAction:",
"backupAction:", "backupAction:",
"archiveAction:", "archiveAction:",
"classesAction:" "classesAction:",
"consistencyAction:"
); );
Outlets = ( Outlets = (
window, window,
@ -22,7 +24,8 @@
inspectorButton, inspectorButton,
backupButton, backupButton,
archiveMatrix, archiveMatrix,
interfaceMatrix interfaceMatrix,
checkConsistency
); );
Super = NSObject; Super = NSObject;
}; };

View file

@ -145,6 +145,7 @@ Gorm_LOCALIZED_RESOURCE_FILES = \
GormHelpInspector.gorm \ GormHelpInspector.gorm \
Gorm.gorm \ Gorm.gorm \
GormImageInspector.gorm \ GormImageInspector.gorm \
GormInconsistenciesPanel.gorm \
GormInspectorPanel.gorm \ GormInspectorPanel.gorm \
GormObjectInspector.gorm \ GormObjectInspector.gorm \
GormNSSplitViewInspector.gorm \ GormNSSplitViewInspector.gorm \

View file

@ -36,6 +36,12 @@
#include <GormCore/GormFunctions.h> #include <GormCore/GormFunctions.h>
@interface GormGormWrapperLoader : GormWrapperLoader @interface GormGormWrapperLoader : GormWrapperLoader
{
NSMutableArray *_repairLog;
id message;
id textField;
id panel;
}
@end @end
@implementation GormGormWrapperLoader @implementation GormGormWrapperLoader
@ -44,6 +50,44 @@
return @"GSGormFileType"; 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 * 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 * versions of Gorm which might have some dangling references. This method
@ -80,7 +124,9 @@
if(sm == nil) if(sm == nil)
{ {
NSArray *menus = findAll(obj); 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 detachObjects: menus];
[document detachObject: obj]; [document detachObject: obj];
@ -104,7 +150,9 @@
{ {
id sm = [obj submenu]; 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]; [document detachObject: obj];
// if there are any submenus, detach those as well. // if there are any submenus, detach those as well.
@ -133,21 +181,24 @@
{ {
[document attachObject: v toParent: [v superview]]; [document attachObject: v toParent: [v superview]];
name = [document nameForObject: v]; 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)]) 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++; errorCount++;
} }
NSLog(@"Found view %@ with name %@", v, name); [_repairLog addObject: [NSString stringWithFormat: @"INFO: Checking view %@ with name %@\n", v, name]];
} }
} }
} }
[document reactivateEditors]; [document reactivateEditors];
/** /**
* Iterate over all connections... * Iterate over all connections... remove connections with nil sources.
*/ */
en = [connections objectEnumerator]; en = [connections objectEnumerator];
while((con = [en nextObject]) != nil) while((con = [en nextObject]) != nil)
@ -156,14 +207,8 @@
{ {
if([con source] == nil) if([con source] == nil)
{ {
NSLog(@"==> Removing bad connector with nil source: %@",con); [_repairLog addObject:
[document removeConnector: con]; [NSString stringWithFormat: @"ERROR ==> Removing bad connector with nil source: %@\n",con]];
errorCount++;
}
if([con destination] == nil)
{
NSLog(@"==> Removing bad connector with nil destination: %@",con);
[document removeConnector: con]; [document removeConnector: con];
errorCount++; errorCount++;
} }
@ -174,9 +219,7 @@
if(errorCount > 0) if(errorCount > 0)
{ {
errorMsg = [NSString stringWithFormat: @"%d inconsistencies were found, please save the file.",errorCount]; errorMsg = [NSString stringWithFormat: @"%d inconsistencies were found, please save the file.",errorCount];
NSRunAlertPanel(_(@"Warning"), [self _openMessagePanel: errorMsg];
errorMsg,
nil, nil, nil);
} }
} }

View file

@ -9,7 +9,7 @@
id window; id window;
id backupButton; id backupButton;
id interfaceMatrix; id interfaceMatrix;
id checkConsistency;
id _view; id _view;
} }
@ -27,6 +27,8 @@
* Show the classes view as a browser or an outline. * Show the classes view as a browser or an outline.
*/ */
- (void) classesAction: (id)sender; - (void) classesAction: (id)sender;
- (void) consistencyAction: (id)sender;
@end @end

View file

@ -36,6 +36,7 @@
static NSString *BACKUPFILE=@"BackupFile"; static NSString *BACKUPFILE=@"BackupFile";
static NSString *INTTYPE=@"ClassViewType"; static NSString *INTTYPE=@"ClassViewType";
static NSString *REPAIRFILE=@"GormRepairFileOnLoad";
@implementation GormGeneralPref @implementation GormGeneralPref
@ -59,6 +60,7 @@ static NSString *INTTYPE=@"ClassViewType";
NSString *intType = [defaults stringForKey: INTTYPE]; NSString *intType = [defaults stringForKey: INTTYPE];
[backupButton setState: [defaults integerForKey: BACKUPFILE]]; [backupButton setState: [defaults integerForKey: BACKUPFILE]];
[checkConsistency setState: ([defaults boolForKey: REPAIRFILE]?NSOnState:NSOffState)];
// set the interface matrix... // set the interface matrix...
if([intType isEqual: @"Outline"]) if([intType isEqual: @"Outline"])
@ -89,21 +91,12 @@ static NSString *INTTYPE=@"ClassViewType";
- (void) backupAction: (id)sender - (void) backupAction: (id)sender
{ {
if (sender != backupButton)
return;
else
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setInteger:[backupButton state] forKey:BACKUPFILE]; [defaults setInteger:[backupButton state] forKey:BACKUPFILE];
}
} }
- (void) classesAction: (id)sender - (void) classesAction: (id)sender
{ {
if (sender != interfaceMatrix)
return;
else
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; // NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
@ -120,7 +113,13 @@ static NSString *INTTYPE=@"ClassViewType";
// [nc postNotificationName: GormSwitchViewPreferencesNotification // [nc postNotificationName: GormSwitchViewPreferencesNotification
// object: nil]; // object: nil];
} }
- (void) consistencyAction: (id)sender
{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setBool: (([checkConsistency state] == NSOnState)?YES:NO)
forKey: REPAIRFILE];
} }
@end @end