From 779ab1bc2a0430a67439e71f010d6418c9917269 Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Sat, 5 Feb 2005 14:11:57 +0000 Subject: [PATCH] Remove windows opened during testing and addd titles to warning panels. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20660 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 11 +++++++++++ Gorm.m | 52 +++++++++++++++++++++++++++++++++++++++++--------- GormDocument.m | 36 +++++++++++++++++++++------------- GormPrivate.h | 1 + 4 files changed, 78 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0f4ed9ce..e33a6c49 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-02-05 09:16 Gregory John Casamento + + * GormDocument.m: Improved some of the panel messages when + gorm has a problem loading/saving. Added titles. + * Gorm.m: Made some of the warning panels have a title. Added code + to -testInterface: and -endTesting: to close extra windows opened + during testing. + * GormPrivate.h: testingWindows ivar to hold windows which were open + before testing, so that we know which ones to orderOut when testing + ends. + 2005-02-02 22:44 Gregory John Casamento * GormDocument.m: -[GormDocument removeConnectionsWithLabel:..] added diff --git a/Gorm.m b/Gorm.m index 92bea714..a4850a5d 100644 --- a/Gorm.m +++ b/Gorm.m @@ -372,8 +372,11 @@ static NSImage *testingImage = nil; if (edited == YES) { int result; - result = NSRunAlertPanel(nil, _(@"There are edited windows"), - _(@"Review Unsaved"),_( @"Quit Anyway"), _(@"Cancel")); + result = NSRunAlertPanel(_(@"Quit"), + _(@"There are edited windows"), + _(@"Review Unsaved"), + _( @"Quit Anyway"), + _(@"Cancel")); if (result == NSAlertDefaultReturn) { enumerator = [ documents objectEnumerator]; @@ -678,15 +681,27 @@ static NSImage *testingImage = nil; { NSUserDefaults *defaults; NSNotificationCenter *notifCenter = [NSNotificationCenter defaultCenter]; - GormDocument *activDoc = (GormDocument*)[self activeDocument]; + GormDocument *activeDoc = (GormDocument*)[self activeDocument]; NSData *data; NSArchiver *archiver; - - + NSEnumerator *en; + id obj; + + // which windows were open when testing started... + testingWindows = [[NSMutableArray alloc] init]; + en = [[self windows] objectEnumerator]; + while((obj = [en nextObject]) != nil) + { + if([obj isVisible]) + { + [testingWindows addObject: obj]; + } + } + isTesting = YES; // set here, so that beginArchiving and endArchiving do not use templates. [self setApplicationIconImage: testingImage]; archiver = [[NSArchiver alloc] init]; - [activDoc beginArchiving]; + [activeDoc beginArchiving]; [archiver encodeClassName: @"GormCustomView" intoClassName: @"GormTestCustomView"]; [archiver encodeClassName: @"GormNSMenu" @@ -708,9 +723,9 @@ static NSImage *testingImage = nil; intoClassName: @"NSOutlineView"]; */ [GSClassSwapper setIsInInterfaceBuilder: YES]; // do not allow custom classes during testing. - [archiver encodeRootObject: activDoc]; + [archiver encodeRootObject: activeDoc]; data = RETAIN([archiver archiverData]); // Released below... - [activDoc endArchiving]; + [activeDoc endArchiving]; RELEASE(archiver); [GSClassSwapper setIsInInterfaceBuilder: NO]; // beginal allowing custom classes... @@ -778,7 +793,7 @@ static NSImage *testingImage = nil; // display the current main menu... [[self mainMenu] display]; - + [notifCenter postNotificationName: IBDidBeginTestingInterfaceNotification object: self]; @@ -1032,6 +1047,7 @@ static NSImage *testingImage = nil; NSUserDefaults *defaults; NSEnumerator *e; id val; + CREATE_AUTORELEASE_POOL(pool); [nc postNotificationName: IBWillEndTestingInterfaceNotification @@ -1049,6 +1065,21 @@ static NSImage *testingImage = nil; } } + /* + * Make sure any peripheral windows: font panels, etc. which are brought + * up by the interface being tested are also closed. + */ + e = [[self windows] objectEnumerator]; + while ((val = [e nextObject]) != nil) + { + if ([testingWindows containsObject: val] == NO && + [val isKindOfClass: [NSWindow class]] && + [val isVisible]) + { + [val orderOut: self]; + } + } + // prevent saving of this, if the menuLocations have not previously been set. if(menuLocations != nil) { @@ -1081,6 +1112,9 @@ static NSImage *testingImage = nil; [nc postNotificationName: IBDidEndTestingInterfaceNotification object: self]; + + DESTROY(testingWindows); + RELEASE(pool); return self; diff --git a/GormDocument.m b/GormDocument.m index eaf78dba..c8d151bb 100644 --- a/GormDocument.m +++ b/GormDocument.m @@ -1729,9 +1729,9 @@ static NSImage *fileImage = nil; if([lastComponent isEqual: @"objects.gorm"] && [parentExt isEqual: @"gorm"]) { - NSRunAlertPanel(nil, + NSRunAlertPanel(_(@"Problem Loading"), _(@"Cannot load directly from objects.gorm file, please load from the gorm package."), - @"OK", nil, nil); + _(@"OK"), nil, nil); return nil; } @@ -1756,9 +1756,9 @@ static NSImage *fileImage = nil; // check the data... if (data == nil) { - NSRunAlertPanel(nil, + NSRunAlertPanel(_(@"Problem Loading"), [NSString stringWithFormat: @"Could not read '%@' data", aFile], - @"OK", nil, nil); + _(@"OK"), nil, nil); return nil; } @@ -1797,7 +1797,8 @@ static NSImage *fileImage = nil; c = [u decodeObject]; if (c == nil || [c isKindOfClass: [GSNibContainer class]] == NO) { - NSRunAlertPanel(nil, _(@"Could not unarchive document data"), + NSRunAlertPanel(_(@"Problem Loading"), + _(@"Could not unarchive document data"), _(@"OK"), nil, nil); return nil; } @@ -1823,8 +1824,9 @@ static NSImage *fileImage = nil; s = [s stringByAppendingPathExtension: @"classes"]; if (![classManager loadCustomClasses: s]) { - NSRunAlertPanel(nil, _(@"Could not open the associated classes file.\n" - @"You won't be able to edit connections on custom classes"), + NSRunAlertPanel(_(@"Problem Loading"), + _(@"Could not open the associated classes file.\n" + @"You won't be able to edit connections on custom classes"), _(@"OK"), nil, nil); } } @@ -1835,8 +1837,9 @@ static NSImage *fileImage = nil; s = [aFile stringByAppendingPathComponent: @"data.classes"]; if (![classManager loadCustomClasses: s]) { - NSRunAlertPanel(nil, _(@"Could not open the associated classes file.\n" - @"You won't be able to edit connections on custom classes"), + NSRunAlertPanel(_(@"Problem Loading"), + _(@"Could not open the associated classes file.\n" + @"You won't be able to edit connections on custom classes"), _(@"OK"), nil, nil); } @@ -2025,7 +2028,8 @@ static NSImage *fileImage = nil; } NS_HANDLER { - NSRunAlertPanel(nil, [NSString stringWithFormat: @"Failed to load file. Exception: %@",[localException reason]], + NSRunAlertPanel(_(@"Problem Loading"), + [NSString stringWithFormat: @"Failed to load file. Exception: %@",[localException reason]], _(@"OK"), nil, nil); return nil; // This will cause the calling method to release the document. } @@ -2111,7 +2115,8 @@ static NSImage *fileImage = nil; else { // if we get this far, we didn't succeed.. - NSRunAlertPanel(nil,_( @"Attempted to load a model which is already opened."), + NSRunAlertPanel(_(@"Problem Loading"), + _(@"Attempted to load a model which is already opened."), _(@"OK"), nil, nil); } } @@ -2886,7 +2891,8 @@ static NSImage *fileImage = nil; if (archiveResult == NO) { - NSRunAlertPanel(nil,_( @"Could not save document"), + NSRunAlertPanel(_(@"Problem Saving"), + _(@"Could not save document"), _(@"OK"), nil, nil); } else @@ -3094,7 +3100,11 @@ static NSImage *fileImage = nil; msg = [NSString stringWithFormat: _(@"Document '%@' has been modified"), [documentPath lastPathComponent]]; } - result = NSRunAlertPanel(nil, msg, _(@"Save"), _(@"Don't Save"), _(@"Cancel")); + result = NSRunAlertPanel(_(@"Close Document"), + msg, + _(@"Save"), + _(@"Don't Save"), + _(@"Cancel")); if (result == NSAlertDefaultReturn) { diff --git a/GormPrivate.h b/GormPrivate.h index 21cba1ac..a58ca8ea 100644 --- a/GormPrivate.h +++ b/GormPrivate.h @@ -113,6 +113,7 @@ extern NSString *GormResizeCellNotification; NSWindow *connectDWindow; NSRect connectDRect; NSPoint cascadePoint; + NSMutableArray *testingWindows; } - (id) activeDocument; - (id) connectSource;