* GormCore/GormCustomView.m: Minor cleanup in initWithFrame:

* GormCore/GormGormWrapperLoader.m: Added logic to _repairFile
        to correct issue with views that don't have a name in the nametable.
        * GormCore/GormViewWithContentViewEditor.m: Properly add 
        the subview back into the document in ungroup method.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@23763 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2006-10-05 02:39:50 +00:00
parent 1e18b6b1db
commit 97f5a14d37
4 changed files with 92 additions and 39 deletions

View file

@ -1,3 +1,11 @@
2006-10-04 22:35-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormCustomView.m: Minor cleanup in initWithFrame:
* GormCore/GormGormWrapperLoader.m: Added logic to _repairFile
to correct issue with views that don't have a name in the nametable.
* GormCore/GormViewWithContentViewEditor.m: Properly add
the subview back into the document in ungroup method.
2006-10-04 00:12-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* English.lproj/GormDocument.gorm: Make connection to

View file

@ -41,16 +41,17 @@
- (id)initWithFrame:(NSRect)frameRect
{
self = [super initWithFrame: frameRect];
[self setBackgroundColor: [NSColor darkGrayColor]];
[self setTextColor: [NSColor whiteColor]];
[self setDrawsBackground: YES];
[self setAlignment: NSCenterTextAlignment];
[self setFont: [NSFont boldSystemFontOfSize: 0]];
[self setEditable: NO];
[self setSelectable: NO];
[self setClassName: @"CustomView"];
if(self != nil)
{
[self setBackgroundColor: [NSColor darkGrayColor]];
[self setTextColor: [NSColor whiteColor]];
[self setDrawsBackground: YES];
[self setAlignment: NSCenterTextAlignment];
[self setFont: [NSFont boldSystemFontOfSize: 0]];
[self setEditable: NO];
[self setSelectable: NO];
[self setClassName: @"CustomView"];
}
return self;
}

View file

@ -54,7 +54,9 @@
{
NSEnumerator *en = [[[document nameTable] allKeys] objectEnumerator];
NSString *key = nil;
int errorCount = 0;
NSString *errorMsg = nil;
NSRunAlertPanel(_(@"Warning"),
_(@"You are running with 'GormRepairFileOnLoad' set to YES."),
nil, nil, nil);
@ -62,6 +64,7 @@
while((key = [en nextObject]) != nil)
{
id obj = [[document nameTable] objectForKey: key];
if([obj isKindOfClass: [NSMenu class]] && ![key isEqual: @"NSMenu"])
{
id sm = [obj supermenu];
@ -78,6 +81,7 @@
// crash, so this extra retain is only here to stave off the
// release, so the autorelease can release the menu when it should.
RETAIN(obj); // extra retain to stave off autorelease...
errorCount++;
}
}
@ -97,13 +101,14 @@
NSArray *menus = findAll(sm);
[document detachObjects: menus];
}
errorCount++;
}
}
/**
* If it's a view and it does't have a window *AND* it's not a top level object
* then it's not a standalone view, it's an orphan. Delete it.
*/
*
if([obj isKindOfClass: [NSView class]])
{
if([obj window] == nil &&
@ -112,9 +117,47 @@
{
NSLog(@"Found and removed an orphan view %@, %@",obj,[document nameForObject: obj]);
[document detachObject: obj];
[obj removeFromSuperview];
errorCount++;
}
}
*/
/**
* If there is a view which is not associated with a name, give it one...
*/
if([obj isKindOfClass: [NSWindow class]])
{
NSArray *allViews = allSubviews([obj contentView]);
NSEnumerator *ven = [allViews objectEnumerator];
id v = nil;
while((v = [ven nextObject]) != nil)
{
if([document nameForObject: v] == nil)
{
NSString *name = nil;
[document attachObject: v toParent: [v superview]];
name = [document nameForObject: v];
NSLog(@"Found view %@ without an associated name, adding to the nametable as %@", v, name);
if([v respondsToSelector: @selector(stringValue)])
{
NSLog(@"View string value is %@",[v stringValue]);
}
errorCount++;
}
}
}
}
// report the number of errors...
if(errorCount > 0)
{
errorMsg = [NSString stringWithFormat: @"%d inconsistencies were found, please save the file.",errorCount];
NSRunAlertPanel(_(@"Warning"),
errorMsg,
nil, nil, nil);
}
}
/**
@ -352,6 +395,11 @@
[document setOlderArchive: YES];
}
/*
* Rebuild the mapping from object to name for the nameTable...
*/
[document rebuildObjToNameMapping];
/*
* repair the .gorm file, if needed.
*/
@ -360,11 +408,6 @@
[self _repairFile];
}
/*
* Rebuild the mapping from object to name for the nameTable...
*/
[document rebuildObjToNameMapping];
NSDebugLog(@"nameTable = %@",[container nameTable]);
// awaken all elements after the load is completed.

View file

@ -1151,6 +1151,28 @@ int _sortViews(id view1, id view2, void *context)
@class GormSplitViewEditor;
@class GormScrollViewEditor;
- (void) _addViewToDocument: (NSView *)view
{
NSEnumerator *en = nil;
NSView *sub = nil;
NSView *par = [view superview];
if([sub isKindOfClass: [GormViewEditor class]])
return;
if([par isKindOfClass: [GormViewEditor class]])
{
par = [(GormViewEditor *)par editedObject];
}
[document attachObject: view toParent: par];
en = [[view subviews] objectEnumerator];
while((sub = [en nextObject]) != nil)
{
[self _addViewToDocument: sub];
}
}
- (void) ungroup
{
NSView *toUngroup;
@ -1179,6 +1201,7 @@ int _sortViews(id view1, id view2, void *context)
{
id v = [views objectAtIndex: i];
[_editedObject addSubview: v];
[self _addViewToDocument: v];
[newSelection addObject:
[document editorForObject: v
inEditor: self
@ -1190,28 +1213,6 @@ int _sortViews(id view1, id view2, void *context)
}
- (void) _addViewToDocument: (NSView *)view
{
NSEnumerator *en = nil;
NSView *sub = nil;
NSView *par = [view superview];
if([sub isKindOfClass: [GormViewEditor class]])
return;
if([par isKindOfClass: [GormViewEditor class]])
{
par = [(GormViewEditor *)par editedObject];
}
[document attachObject: view toParent: par];
en = [[view subviews] objectEnumerator];
while((sub = [en nextObject]) != nil)
{
[self _addViewToDocument: sub];
}
}
- (void) pasteInView: (NSView *)view
{
NSPasteboard *pb = [NSPasteboard generalPasteboard];