Implementation of resource manager handling for adding objects to the document.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21082 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2005-04-11 00:16:01 +00:00
parent 660c9fd7ad
commit d9cc373584
6 changed files with 53 additions and 37 deletions

View file

@ -1,3 +1,13 @@
2005-04-10 20:09 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormDocument.h
* GormCore/GormDocument.m: addition of the method
resourceManagerForPasteboard:.
* GormCore/GormObjectEditor.m: Changes to utilize IBResourceManager
* GormLib/IBResourceManager.h
* GormLib/IBResourceManager.m: Changes to add objects to the document
properly.
2005-04-10 18:13 Gregory John Casamento <greg_casamento@yahoo.com>
* GormCore/GormDocument.h: Organized methods.

View file

@ -104,6 +104,7 @@
- (void) closeAllEditors;
- (void) createResourceManagers;
- (NSArray *) resourceManagers;
- (IBResourceManager *) resourceManagerForPasteboard: (NSPasteboard *)pboard;
/* Managing classes */
- (GormClassManager*) classManager;

View file

@ -3491,6 +3491,23 @@ static NSImage *fileImage = nil;
{
return resourceManagers;
}
- (IBResourceManager *) resourceManagerForPasteboard: (NSPasteboard *)pboard
{
NSEnumerator *en = [resourceManagers objectEnumerator];
IBResourceManager *mgr = nil, *result = nil;
while((mgr = [en nextObject]) != nil)
{
if([mgr acceptsResourcesFromPasteboard: pboard])
{
result = mgr;
break;
}
}
return result;
}
@end
@implementation GormDocument (MenuValidation)

View file

@ -215,12 +215,16 @@ static NSMapTable *docMap = 0;
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
{
NSArray *types;
NSString *type;
dragPb = [sender draggingPasteboard];
types = [dragPb types];
if ([types containsObject: IBObjectPboardType] == YES)
resourceManager = [(GormDocument *)document resourceManagerForPasteboard: dragPb];
type = [[resourceManager resourcePasteboardTypes] firstObjectCommonWithArray: types];
if (type != nil)
{
dragType = IBObjectPboardType;
dragType = type;
}
else if ([types containsObject: GormLinkPboardType] == YES)
{
@ -235,7 +239,7 @@ static NSMapTable *docMap = 0;
- (unsigned) draggingUpdated: (id<NSDraggingInfo>)sender
{
if (dragType == IBObjectPboardType)
if ([[resourceManager resourcePasteboardTypes] containsObject: dragType])
{
return NSDragOperationCopy;
}
@ -428,9 +432,9 @@ static NSMapTable *docMap = 0;
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
{
if (dragType == IBObjectPboardType)
if ([[resourceManager resourcePasteboardTypes] containsObject: dragType])
{
NSArray *array;
// NSArray *array;
// NSEnumerator *enumerator;
// id obj;
@ -438,20 +442,13 @@ static NSMapTable *docMap = 0;
* Ask the document to get the dragged objects from the pasteboard and
* add them to it's collection of known objects.
*/
/*
array = [document pasteType: IBObjectPboardType
fromPasteboard: dragPb
parent: [objects objectAtIndex: 0]];
/*
enumerator = [array objectEnumerator];
while ((obj = [enumerator nextObject]) != nil)
{
RETAIN(obj);
[[(GormDocument *)document topLevelObjects] addObject: obj];
[self addObject: obj];
}
*/
[resourceManager addResourcesFromPasteboard: dragPb];
return YES;
}
else if (dragType == GormLinkPboardType)

View file

@ -132,15 +132,8 @@ static NSMapTable *_resourceManagers = NULL;
{
NSArray *types = [pboard types];
NSArray *resourcePbTypes = [self resourcePasteboardTypes];
id obj = [types firstObjectCommonWithArray: resourcePbTypes];
BOOL result = NO;
if(obj != nil)
{
result = YES;
}
return result;
NSString *type = [types firstObjectCommonWithArray: resourcePbTypes];
return (type != nil);
}
- (void) addResources: (NSArray *)resourceList
@ -150,19 +143,17 @@ static NSMapTable *_resourceManagers = NULL;
- (void) addResourcesFromPasteboard: (NSPasteboard *)pboard
{
NSArray *types = [pboard types];
NSArray *resourcePbTypes = [self resourcePasteboardTypes];
NSString *type = nil;
NSEnumerator *en = [resourcePbTypes objectEnumerator];
NSString *type = [types firstObjectCommonWithArray: resourcePbTypes];
while((type = [en nextObject]) != nil)
{
NSData *data = [pboard dataForType: type];
id obj = [NSUnarchiver unarchiveObjectWithData: data];
if(obj != nil)
{
[document attachObject: obj toParent: nil];
}
}
/*
* Ask the document to get the dragged objects from the pasteboard and
* add them to it's collection of known objects.
*/
[document pasteType: type
fromPasteboard: pboard
parent: nil];
}
- (void) application: (NSString *) appName didModifyFileAtPath: (NSString *)path