mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Eliminate confusion when opening a doc. The application will give some warnings if the user opens a gorm more than once or tries to open an objects.gorm file within an existing .gorm package.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@19271 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9ff9c837fd
commit
edfcf12f7c
4 changed files with 69 additions and 7 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2004-05-08 08:53 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormDocument.m: [GormDocument loadDocument:] added code
|
||||
to prevent users from invoking "open objects.gorm" or opening
|
||||
"objects.gorm" directly when in GWorkspace. This caused Gorm
|
||||
to convert the objects.gorm file as if it were an old-style file
|
||||
before gorm packages. It now issues a warning. Also added code
|
||||
to [GormDocument openDocument:] to check for a duplicate open
|
||||
of a model which is already opened. This can cause confusion.
|
||||
* Gorm.m: Added a new method [Gorm documentNameIsUnique:] which
|
||||
checks all existing open documents for a duplicate name and
|
||||
returns NO, if it's not unique.
|
||||
* GormPrivate.h: Added declaration of the method mentioned above
|
||||
to the Gorm class interface.
|
||||
|
||||
2004-05-08 08:53 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GModelDecoder.m: [GModelDecoder openGModel:]
|
||||
|
|
19
Gorm.m
19
Gorm.m
|
@ -1503,6 +1503,25 @@ NSString *GormResizeCellNotification = @"GormResizeCellNotification";
|
|||
[window orderFront: sender];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) documentNameIsUnique: (NSString *)filename
|
||||
{
|
||||
NSEnumerator *en = [documents objectEnumerator];
|
||||
id document;
|
||||
BOOL unique = YES;
|
||||
|
||||
while((document = [en nextObject]) != nil)
|
||||
{
|
||||
NSString *docPath = [document documentPath];
|
||||
if([docPath isEqual: filename])
|
||||
{
|
||||
unique = NO;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return unique;
|
||||
}
|
||||
@end
|
||||
|
||||
// custom class additions...
|
||||
|
|
|
@ -2049,6 +2049,20 @@ static NSImage *classesImage = nil;
|
|||
// if the data is in a directory, then load from objects.gorm
|
||||
if (isDir == NO)
|
||||
{
|
||||
NSString *lastComponent = [aFile lastPathComponent];
|
||||
NSString *parent = [aFile stringByDeletingLastPathComponent];
|
||||
NSString *parentExt = [parent pathExtension];
|
||||
|
||||
// test if we're doing it wrong...
|
||||
if([lastComponent isEqual: @"objects.gorm"] &&
|
||||
[parentExt isEqual: @"gorm"])
|
||||
{
|
||||
NSRunAlertPanel(NULL,
|
||||
_(@"Cannot load directly from objects.gorm file, please load from the gorm package."),
|
||||
@"OK", NULL, NULL);
|
||||
return nil;
|
||||
}
|
||||
|
||||
data = [NSData dataWithContentsOfFile: aFile];
|
||||
NSDebugLog(@"Loaded data from file...");
|
||||
}
|
||||
|
@ -2345,19 +2359,30 @@ static NSImage *classesImage = nil;
|
|||
{
|
||||
NSString *filename = [oPanel filename];
|
||||
NSString *ext = [filename pathExtension];
|
||||
BOOL uniqueName = [(Gorm *)NSApp documentNameIsUnique: filename];
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] setObject: [oPanel directory]
|
||||
forKey:@"OpenDir"];
|
||||
if ([ext isEqualToString:@"gorm"] || [ext isEqualToString:@"nib"])
|
||||
if(uniqueName)
|
||||
{
|
||||
return [self loadDocument: filename];
|
||||
[[NSUserDefaults standardUserDefaults] setObject: [oPanel directory]
|
||||
forKey:@"OpenDir"];
|
||||
if ([ext isEqualToString:@"gorm"] || [ext isEqualToString:@"nib"])
|
||||
{
|
||||
return [self loadDocument: filename];
|
||||
}
|
||||
else if ([ext isEqualToString:@"gmodel"])
|
||||
{
|
||||
return [self openGModel: filename];
|
||||
}
|
||||
}
|
||||
else if ([ext isEqualToString:@"gmodel"])
|
||||
else
|
||||
{
|
||||
return [self openGModel: filename];
|
||||
// if we get this far, we didn't succeed..
|
||||
NSRunAlertPanel(NULL,_( @"Attempted to load a model which is already opened."),
|
||||
_(@"OK"), NULL, NULL);
|
||||
}
|
||||
}
|
||||
return nil; /* Failed */
|
||||
|
||||
return nil; /* Failed */
|
||||
}
|
||||
|
||||
- (id<IBEditors>) openEditorForObject: (id)anObject
|
||||
|
|
|
@ -153,6 +153,9 @@ extern NSString *GormResizeCellNotification;
|
|||
- (void) createSubclass: (id)sender;
|
||||
- (void) instantiateClass: (id)sender;
|
||||
- (NSMenu*) classMenu;
|
||||
|
||||
// utility...
|
||||
- (BOOL) documentNameIsUnique: (NSString *)filename;
|
||||
@end
|
||||
|
||||
@interface GormClassEditor : NSObject <IBSelectionOwners>
|
||||
|
|
Loading…
Reference in a new issue