mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-04-22 22:20:44 +00:00
Code to allow drag and drop parsing of headers.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21146 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
577c17a847
commit
91ddcae2a9
5 changed files with 195 additions and 6 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2005-04-23 02:50 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormCore/GormClassEditor.m: Implementation of editor/dragging
|
||||
methods.
|
||||
* GormCore/GormDocument.m: Uncommented the section of the
|
||||
changeToTopLevelEditorAcceptingTypes: method which switches to the
|
||||
classes view.
|
||||
* GormCore/GormGenericEditor.m: Added implementation for
|
||||
fileTypes.
|
||||
* GormCore/GormPrivate.h: Added declaration of fileTypes.
|
||||
|
||||
2005-04-22 17:15 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormCore/GormDocument.h: Changed signature.
|
||||
|
|
|
@ -49,8 +49,11 @@ NSString *GormClassPboardType = @"GormClassPboardType";
|
|||
alpha: 1.0 ];
|
||||
NSTableColumn *tableColumn;
|
||||
|
||||
document = doc; // loose connection
|
||||
// weak connections...
|
||||
document = doc;
|
||||
classManager = [doc classManager];
|
||||
|
||||
// set up the outline view...
|
||||
[self setDataSource: self];
|
||||
[self setDelegate: self];
|
||||
[self setAutoresizesAllColumnsToFit: YES];
|
||||
|
@ -61,7 +64,8 @@ NSString *GormClassPboardType = @"GormClassPboardType";
|
|||
[self setIndentationPerLevel: 10];
|
||||
[self setAttributeOffset: 30];
|
||||
[self setRowHeight: 18];
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType,
|
||||
GormLinkPboardType, nil]];
|
||||
[self setMenu: [(id<Gorm>)NSApp classMenu]];
|
||||
[self setBackgroundColor: salmonColor ];
|
||||
|
||||
|
@ -95,6 +99,11 @@ NSString *GormClassPboardType = @"GormClassPboardType";
|
|||
|
||||
// expand all of the items in the classesView...
|
||||
[self expandItem: @"NSObject"];
|
||||
|
||||
// register for types...
|
||||
[self registerForDraggedTypes: [NSArray arrayWithObjects: GormLinkPboardType,
|
||||
NSFilenamesPboardType,
|
||||
nil]];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -513,6 +522,171 @@ NSString *GormClassPboardType = @"GormClassPboardType";
|
|||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Dragging source protocol implementation
|
||||
*/
|
||||
- (void) draggedImage: (NSImage*)i endedAt: (NSPoint)p deposited: (BOOL)f
|
||||
{
|
||||
// no image.
|
||||
}
|
||||
|
||||
- (unsigned) draggingEntered: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *pb = [sender draggingPasteboard];
|
||||
NSArray *pbTypes = [pb types];
|
||||
unsigned int oper = NSDragOperationNone;
|
||||
NSString *ext = nil;
|
||||
|
||||
// Get the resource manager first, if nil don't bother calling the rest...
|
||||
if([pbTypes containsObject: NSFilenamesPboardType] == YES)
|
||||
{
|
||||
NSArray *types = [self fileTypes];
|
||||
NSArray *data = [pb propertyListForType: NSFilenamesPboardType];
|
||||
NSString *fileName = nil;
|
||||
NSEnumerator *en = [data objectEnumerator];
|
||||
|
||||
while((fileName = [en nextObject]) != nil)
|
||||
{
|
||||
ext = [fileName pathExtension];
|
||||
if([types containsObject: ext])
|
||||
{
|
||||
oper = NSDragOperationCopy;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
oper = NSDragOperationNone;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(oper == NSDragOperationNone)
|
||||
{
|
||||
[(GormDocument *)document changeToTopLevelEditorAcceptingTypes: pbTypes
|
||||
andFileType: ext];
|
||||
}
|
||||
|
||||
return oper;
|
||||
}
|
||||
|
||||
- (unsigned) draggingUpdate: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
return [self draggingEntered: sender];
|
||||
}
|
||||
|
||||
- (BOOL) performDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
NSPasteboard *pb = [sender draggingPasteboard];
|
||||
NSArray *types = [pb types];
|
||||
|
||||
if ([types containsObject: NSFilenamesPboardType])
|
||||
{
|
||||
NSArray *data;
|
||||
NSEnumerator *en = nil;
|
||||
NSString *fileName = nil;
|
||||
|
||||
data = [pb propertyListForType: NSFilenamesPboardType];
|
||||
if(data != nil)
|
||||
{
|
||||
en = [data objectEnumerator];
|
||||
while((fileName = [en nextObject]) != nil)
|
||||
{
|
||||
[classManager parseHeader: fileName];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) prepareForDragOperation: (id<NSDraggingInfo>)sender
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
// IBEditor protocol
|
||||
|
||||
- (BOOL) acceptsTypeFromArray: (NSArray*)types
|
||||
{
|
||||
return [types containsObject: NSFilenamesPboardType];
|
||||
}
|
||||
|
||||
- (BOOL) activate
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (id) initWithObject: (id)anObject inDocument: (id/*<IBDocuments>*/)aDocument
|
||||
{
|
||||
return [self initWithDocument: aDocument];
|
||||
}
|
||||
|
||||
- (void) close
|
||||
{
|
||||
// does nothing.
|
||||
}
|
||||
|
||||
- (void) closeSubeditors
|
||||
{
|
||||
// does nothing.
|
||||
}
|
||||
|
||||
- (void) deactivate
|
||||
{
|
||||
// does nothing.
|
||||
}
|
||||
|
||||
- (id /*<IBDocuments>*/) document
|
||||
{
|
||||
return document;
|
||||
}
|
||||
|
||||
- (id) editedObject
|
||||
{
|
||||
return selectedClass;
|
||||
}
|
||||
|
||||
- (void) orderFront
|
||||
{
|
||||
[[self window] orderFront: self];
|
||||
}
|
||||
|
||||
- (id<IBEditors>) openSubeditorForObject: (id)object
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) resetObject: (id)anObject
|
||||
{
|
||||
// does nothing.
|
||||
}
|
||||
|
||||
- (BOOL) wantsSelection
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void) validateEditing
|
||||
{
|
||||
// does nothing.
|
||||
}
|
||||
|
||||
- (NSWindow *) window
|
||||
{
|
||||
return [super window];
|
||||
}
|
||||
|
||||
- (NSArray *) fileTypes
|
||||
{
|
||||
return [NSArray arrayWithObject: @"h"];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation GormClassEditor (NSOutlineViewDataSource)
|
||||
|
|
|
@ -829,13 +829,11 @@ static NSImage *fileImage = nil;
|
|||
{
|
||||
[self changeToViewWithTag: 2];
|
||||
}
|
||||
/*
|
||||
else if([classesView acceptsTypeFromArray: types] &&
|
||||
[[classesView fileTypes] containsObject: fileType])
|
||||
{
|
||||
[self changeToViewWithTag: 3];
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -362,4 +362,9 @@
|
|||
{
|
||||
// does nothing.
|
||||
}
|
||||
|
||||
- (NSArray *)fileTypes
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -82,7 +82,7 @@ extern NSString *GormResizeCellNotification;
|
|||
- (NSString*) sizeInspectorClassName;
|
||||
@end
|
||||
|
||||
@interface GormClassEditor : GormOutlineView <IBSelectionOwners>
|
||||
@interface GormClassEditor : GormOutlineView <IBEditors, IBSelectionOwners>
|
||||
{
|
||||
GormDocument *document;
|
||||
GormClassManager *classManager;
|
||||
|
@ -101,6 +101,7 @@ extern NSString *GormResizeCellNotification;
|
|||
- (void) createSubclass;
|
||||
- (void) addAttributeToClass;
|
||||
- (void) deleteSelection;
|
||||
- (NSArray *) fileTypes;
|
||||
@end
|
||||
|
||||
@interface GormGenericEditor : NSMatrix <IBEditors, IBSelectionOwners>
|
||||
|
@ -143,6 +144,7 @@ extern NSString *GormResizeCellNotification;
|
|||
|
||||
- (NSArray *) objects;
|
||||
- (BOOL) isOpened;
|
||||
- (NSArray *) fileTypes;
|
||||
@end
|
||||
|
||||
// private methods...
|
||||
|
@ -174,7 +176,6 @@ extern NSString *GormResizeCellNotification;
|
|||
- (unsigned int) draggingSourceOperationMaskForLocal: (BOOL)flag;
|
||||
- (void) refreshCells;
|
||||
- (id) placeHolderWithPath: (NSString *)path;
|
||||
- (NSArray *) fileTypes;
|
||||
- (NSArray *) pbTypes;
|
||||
- (NSString *) resourceType;
|
||||
- (void) addSystemResources;
|
||||
|
|
Loading…
Reference in a new issue