mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 03:51:22 +00:00
It is now possible to edit classes in the class view. Some more work needs to be done, but it is useful now.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@14135 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1d6d8ea8ab
commit
06c961ce51
7 changed files with 147 additions and 20 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2002-07-12 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
|
* Gorm.m: [-removeAttributeFromClass] added method to be
|
||||||
|
used by new menu item "Delete Outlet/Action". Removed some
|
||||||
|
NSLog statements.
|
||||||
|
* GormClassManager.[hm]: Added methods to support adding and
|
||||||
|
replacing actions and outlets.
|
||||||
|
* GormDocument.m: Modified data source methods to use the methods
|
||||||
|
added to the class manager to edit the contents of the class list.
|
||||||
|
* GormOutlineView.[hm]: Added methods to add actions and outlets
|
||||||
|
to the data source from the outline view. Also changed the drawing
|
||||||
|
code so that the outlet/action being edited doesn't shift when
|
||||||
|
clicked.
|
||||||
|
|
||||||
2002-07-11 Gregory John Casamento <greg_casamento@yahoo.com>
|
2002-07-11 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* GormClassManager.m: Added stubs for two new method to add actions
|
* GormClassManager.m: Added stubs for two new method to add actions
|
||||||
|
|
10
Gorm.m
10
Gorm.m
|
@ -415,11 +415,14 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
|
|
||||||
- (id) addAttributeToClass: (id)sender
|
- (id) addAttributeToClass: (id)sender
|
||||||
{
|
{
|
||||||
NSLog(@"add outlet/action");
|
|
||||||
// return self;
|
|
||||||
return [(id)[self activeDocument] addAttributeToClass: sender];
|
return [(id)[self activeDocument] addAttributeToClass: sender];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) removeAttributeFromClass: (id)sender
|
||||||
|
{
|
||||||
|
return [(id)[self activeDocument] revoveAttributeFromClass: sender];
|
||||||
|
}
|
||||||
|
|
||||||
- (id) editClass: (id)sender
|
- (id) editClass: (id)sender
|
||||||
{
|
{
|
||||||
[self inspector: self];
|
[self inspector: self];
|
||||||
|
@ -639,6 +642,9 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
[aMenu addItemWithTitle: @"Add Outlet/Action.."
|
[aMenu addItemWithTitle: @"Add Outlet/Action.."
|
||||||
action: @selector(addAttributeToClass:)
|
action: @selector(addAttributeToClass:)
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
|
[aMenu addItemWithTitle: @"Delete Outlet/Action.."
|
||||||
|
action: @selector(removeAttributeFromClass:)
|
||||||
|
keyEquivalent: @""];
|
||||||
menuItem = [mainMenu addItemWithTitle: @"Classes"
|
menuItem = [mainMenu addItemWithTitle: @"Classes"
|
||||||
action: NULL
|
action: NULL
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
|
|
|
@ -17,7 +17,10 @@
|
||||||
- (NSArray*) subClassesOf: (NSString *)superclass;
|
- (NSArray*) subClassesOf: (NSString *)superclass;
|
||||||
- (void) removeAction: (NSString*)anAction forObject: (NSObject*)anObject;
|
- (void) removeAction: (NSString*)anAction forObject: (NSObject*)anObject;
|
||||||
- (void) removeOutlet: (NSString*)anOutlet forObject: (NSObject*)anObject;
|
- (void) removeOutlet: (NSString*)anOutlet forObject: (NSObject*)anObject;
|
||||||
|
- (void) addOutlet: (NSString *)anOutlet forClassNamed: (NSString *)className;
|
||||||
|
- (void) addAction: (NSString *)anAction forClassNamed: (NSString *)className;
|
||||||
|
- (void) replaceAction: (NSString *)oldAction withAction: (NSString *)newAction forClassNamed: className;
|
||||||
|
- (void) replaceOutlet: (NSString *)oldOutlet withOutlet: (NSString *)newOutlet forClassNamed: className;
|
||||||
- (BOOL) renameClassNamed: (NSString*)oldName newName: (NSString*)name;
|
- (BOOL) renameClassNamed: (NSString*)oldName newName: (NSString*)name;
|
||||||
- (NSString*) addClassWithSuperClassName: (NSString*)name;
|
- (NSString*) addClassWithSuperClassName: (NSString*)name;
|
||||||
- (BOOL) addClassNamed: (NSString*)className
|
- (BOOL) addClassNamed: (NSString*)className
|
||||||
|
|
|
@ -147,12 +147,78 @@ NSString *IBClassNameChangedNotification = @"IBClassNameChangedNotification";
|
||||||
[[info objectForKey: @"AllOutlets"] addObject: anOutlet];
|
[[info objectForKey: @"AllOutlets"] addObject: anOutlet];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) addAction: (NSString *)anOutlet forClassNamed: (NSString *)className
|
- (void) addAction: (NSString *)anAction forClassNamed: (NSString *)className
|
||||||
{
|
{
|
||||||
|
NSMutableDictionary *info = [classInformation objectForKey: className];
|
||||||
|
NSMutableArray *extraActions = [info objectForKey: @"ExtraActions"];
|
||||||
|
NSArray *allActions = [self allActionsForClassNamed: className];
|
||||||
|
|
||||||
|
if([allActions containsObject: anAction])
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(extraActions == nil)
|
||||||
|
{
|
||||||
|
extraActions = [[NSMutableArray alloc] initWithCapacity: 1];
|
||||||
|
[info setObject: extraActions forKey: @"ExtraActions"];
|
||||||
|
RELEASE(extraActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
[extraActions addObject: anAction];
|
||||||
|
[[info objectForKey: @"AllActions"] insertObject: anAction atIndex: 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) addOutlet: (NSString *)anOutlet forClassNamed: (NSString *)className
|
- (void) addOutlet: (NSString *)anOutlet forClassNamed: (NSString *)className
|
||||||
{
|
{
|
||||||
|
NSMutableDictionary *info = [classInformation objectForKey: className];
|
||||||
|
NSMutableArray *extraOutlets = [info objectForKey: @"ExtraOutlets"];
|
||||||
|
NSArray *allOutlets = [self allOutletsForClassNamed: className];
|
||||||
|
|
||||||
|
if([allOutlets containsObject: anOutlet])
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(extraOutlets == nil)
|
||||||
|
{
|
||||||
|
extraOutlets = [[NSMutableArray alloc] initWithCapacity: 1];
|
||||||
|
[info setObject: extraOutlets forKey: @"ExtraOutlets"];
|
||||||
|
RELEASE(extraOutlets);
|
||||||
|
}
|
||||||
|
|
||||||
|
[extraOutlets addObject: anOutlet];
|
||||||
|
[[info objectForKey: @"AllOutlets"] insertObject: anOutlet atIndex: 0];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) replaceAction: (NSString *)oldAction withAction: (NSString *)newAction forClassNamed: className
|
||||||
|
{
|
||||||
|
NSMutableDictionary *info = [classInformation objectForKey: className];
|
||||||
|
NSMutableArray *extraActions = [info objectForKey: @"ExtraActions"];
|
||||||
|
NSArray *allActions = [self allActionsForClassNamed: className];
|
||||||
|
|
||||||
|
if([extraActions containsObject: oldAction])
|
||||||
|
{
|
||||||
|
int all_index = [allActions indexOfObject: oldAction];
|
||||||
|
int extra_index = [allActions indexOfObject: oldAction];
|
||||||
|
|
||||||
|
[extraActions replaceObjectAtIndex: extra_index withObject: newAction];
|
||||||
|
[[info objectForKey: @"AllActions"] replaceObjectAtIndex: all_index withObject: newAction];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) replaceOutlet: (NSString *)oldOutlet withOutlet: (NSString *)newOutlet forClassNamed: className
|
||||||
|
{
|
||||||
|
NSMutableDictionary *info = [classInformation objectForKey: className];
|
||||||
|
NSMutableArray *extraOutlets = [info objectForKey: @"ExtraOutlets"];
|
||||||
|
NSArray *allOutlets = [self allOutletsForClassNamed: className];
|
||||||
|
|
||||||
|
if([extraOutlets containsObject: oldOutlet])
|
||||||
|
{
|
||||||
|
int all_index = [allOutlets indexOfObject: oldOutlet];
|
||||||
|
int extra_index = [allOutlets indexOfObject: oldOutlet];
|
||||||
|
|
||||||
|
[extraOutlets replaceObjectAtIndex: extra_index withObject: newOutlet];
|
||||||
|
[[info objectForKey: @"AllOutlets"] replaceObjectAtIndex: all_index withObject: newOutlet];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSArray*) allActionsForObject: (NSObject*)obj
|
- (NSArray*) allActionsForObject: (NSObject*)obj
|
||||||
|
|
|
@ -707,6 +707,12 @@ static NSImage *classesImage = nil;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (id) removeAttributeFromClass: (id)sender
|
||||||
|
{
|
||||||
|
[classesView removeAttributeFromClass];
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
- (id) loadClass: (id)sender
|
- (id) loadClass: (id)sender
|
||||||
{
|
{
|
||||||
NSArray *fileTypes = [NSArray arrayWithObjects: @"h", @"H", nil];
|
NSArray *fileTypes = [NSArray arrayWithObjects: @"h", @"H", nil];
|
||||||
|
@ -1221,6 +1227,7 @@ static NSImage *classesImage = nil;
|
||||||
[classesView setIndentationPerLevel: 10];
|
[classesView setIndentationPerLevel: 10];
|
||||||
[classesView setAttributeOffset: 30];
|
[classesView setAttributeOffset: 30];
|
||||||
[classesView setBackgroundColor: salmonColor ];
|
[classesView setBackgroundColor: salmonColor ];
|
||||||
|
[classesView setRowHeight: 18];
|
||||||
[classesScrollView setDocumentView: classesView];
|
[classesScrollView setDocumentView: classesView];
|
||||||
RELEASE(classesView);
|
RELEASE(classesView);
|
||||||
|
|
||||||
|
@ -2193,19 +2200,22 @@ objectValueForTableColumn: (NSTableColumn *)aTableColumn
|
||||||
forTableColumn: (NSTableColumn *)aTableColumn
|
forTableColumn: (NSTableColumn *)aTableColumn
|
||||||
byItem: (id)item
|
byItem: (id)item
|
||||||
{
|
{
|
||||||
NSLog(@"Edit item %@",item);
|
|
||||||
if([item isKindOfClass: [GormOutletActionHolder class]])
|
if([item isKindOfClass: [GormOutletActionHolder class]])
|
||||||
{
|
{
|
||||||
if([anOutlineView editType] == Actions)
|
if([anOutlineView editType] == Actions)
|
||||||
{
|
{
|
||||||
NSLog(@"the action %@",[item getName]);
|
[classManager replaceAction: [item getName] withAction: anObject forClassNamed: [anOutlineView itemBeingEdited]];
|
||||||
}
|
}
|
||||||
else if([anOutlineView editType] == Outlets)
|
else if([anOutlineView editType] == Outlets)
|
||||||
{
|
{
|
||||||
NSLog(@"the outlet %@",[item getName]);
|
[classManager replaceOutlet: [item getName] withOutlet: anObject forClassNamed: [anOutlineView itemBeingEdited]];
|
||||||
}
|
}
|
||||||
[item setName: anObject];
|
[item setName: anObject];
|
||||||
NSLog(@"Replaced by %@",anObject);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[classManager renameClassNamed: item newName: anObject];
|
||||||
|
[anOutlineView reloadData];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2269,5 +2279,19 @@ numberOfChildrenOfItem: (id)item
|
||||||
NSArray *outlets = [classManager allOutletsForClassNamed: item];
|
NSArray *outlets = [classManager allOutletsForClassNamed: item];
|
||||||
return outlets;
|
return outlets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)outlineView: (NSOutlineView *)anOutlineView
|
||||||
|
addAction: (NSString *)action
|
||||||
|
forClass: (id)item
|
||||||
|
{
|
||||||
|
[classManager addAction: action forClassNamed: item];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)outlineView: (NSOutlineView *)anOutlineView
|
||||||
|
addOutlet: (NSString *)outlet
|
||||||
|
forClass: (id)item
|
||||||
|
{
|
||||||
|
[classManager addOutlet: outlet forClassNamed: item];
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,12 @@ typedef enum {None, Outlets, Actions} GSAttributeType;
|
||||||
actionsForItem: (id)item;
|
actionsForItem: (id)item;
|
||||||
- (NSArray *) outlineView: (GormOutlineView *)ov
|
- (NSArray *) outlineView: (GormOutlineView *)ov
|
||||||
outletsForItem: (id)item;
|
outletsForItem: (id)item;
|
||||||
|
- (void)outlineView: (NSOutlineView *)anOutlineView
|
||||||
|
addAction: (NSString *)action
|
||||||
|
forClass: (id)item;
|
||||||
|
- (void)outlineView: (NSOutlineView *)anOutlineView
|
||||||
|
addOutlet: (NSString *)outlet
|
||||||
|
forClass: (id)item;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// a class to hold the outlet/actions so that the
|
// a class to hold the outlet/actions so that the
|
||||||
|
|
|
@ -183,10 +183,10 @@ static NSColor *darkGreyBlueColor = nil;
|
||||||
{
|
{
|
||||||
int insertionPoint = 0;
|
int insertionPoint = 0;
|
||||||
GormOutletActionHolder *holder = [[GormOutletActionHolder alloc] initWithName: actionname];
|
GormOutletActionHolder *holder = [[GormOutletActionHolder alloc] initWithName: actionname];
|
||||||
NSLog(@"Adding an action: %@", actionname);
|
|
||||||
_numberOfRows += 1;
|
_numberOfRows += 1;
|
||||||
insertionPoint = [_items indexOfObject: item];
|
insertionPoint = [_items indexOfObject: item];
|
||||||
[_items insertObject: holder atIndex: insertionPoint + 1];
|
[_items insertObject: holder atIndex: insertionPoint + 1];
|
||||||
|
[_dataSource outlineView: self addAction: actionname forClass: _itemBeingEdited];
|
||||||
[self setNeedsDisplay: YES];
|
[self setNeedsDisplay: YES];
|
||||||
[self noteNumberOfRowsChanged];
|
[self noteNumberOfRowsChanged];
|
||||||
}
|
}
|
||||||
|
@ -236,11 +236,10 @@ static NSColor *darkGreyBlueColor = nil;
|
||||||
{
|
{
|
||||||
int insertionPoint = 0;
|
int insertionPoint = 0;
|
||||||
GormOutletActionHolder *holder = [[GormOutletActionHolder alloc] initWithName: outletname];
|
GormOutletActionHolder *holder = [[GormOutletActionHolder alloc] initWithName: outletname];
|
||||||
NSLog(@"Adding an outlet: %@", outletname);
|
|
||||||
_numberOfRows += 1;
|
_numberOfRows += 1;
|
||||||
insertionPoint = [_items indexOfObject: item];
|
insertionPoint = [_items indexOfObject: item];
|
||||||
[_items insertObject: holder atIndex: insertionPoint + 1];
|
[_items insertObject: holder atIndex: insertionPoint + 1];
|
||||||
// [self editColumn: 0 row: insertionPoint+1 withEvent: nil select: YES];
|
[_dataSource outlineView: self addOutlet: outletname forClass: _itemBeingEdited];
|
||||||
[self setNeedsDisplay: YES];
|
[self setNeedsDisplay: YES];
|
||||||
[self noteNumberOfRowsChanged];
|
[self noteNumberOfRowsChanged];
|
||||||
}
|
}
|
||||||
|
@ -491,16 +490,13 @@ static NSColor *darkGreyBlueColor = nil;
|
||||||
_clickedItem = [self itemAtRow: _clickedRow];
|
_clickedItem = [self itemAtRow: _clickedRow];
|
||||||
isActionOrOutlet = [_clickedItem isKindOfClass: [GormOutletActionHolder class]];
|
isActionOrOutlet = [_clickedItem isKindOfClass: [GormOutletActionHolder class]];
|
||||||
|
|
||||||
NSLog(@"clickedItem = %@",_clickedItem);
|
|
||||||
tb = [_tableColumns objectAtIndex: _clickedColumn];
|
tb = [_tableColumns objectAtIndex: _clickedColumn];
|
||||||
if(tb == _actionColumn)
|
if(tb == _actionColumn)
|
||||||
{
|
{
|
||||||
NSLog(@"setting action image");
|
|
||||||
image = action;
|
image = action;
|
||||||
}
|
}
|
||||||
else if (tb == _outletColumn)
|
else if (tb == _outletColumn)
|
||||||
{
|
{
|
||||||
NSLog(@"setting outlet image");
|
|
||||||
image = outlet;
|
image = outlet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +528,6 @@ static NSColor *darkGreyBlueColor = nil;
|
||||||
if(_clickedItem != [self itemBeingEdited] &&
|
if(_clickedItem != [self itemBeingEdited] &&
|
||||||
!isActionOrOutlet)
|
!isActionOrOutlet)
|
||||||
{
|
{
|
||||||
NSLog(@"RESETTING......");
|
|
||||||
[self setItemBeingEdited: nil];
|
[self setItemBeingEdited: nil];
|
||||||
[self setIsEditing: NO];
|
[self setIsEditing: NO];
|
||||||
[self setBackgroundColor: salmonColor];
|
[self setBackgroundColor: salmonColor];
|
||||||
|
@ -542,7 +537,6 @@ static NSColor *darkGreyBlueColor = nil;
|
||||||
else if(isActionOrOutlet)
|
else if(isActionOrOutlet)
|
||||||
{
|
{
|
||||||
NSString *name = [_clickedItem getName];
|
NSString *name = [_clickedItem getName];
|
||||||
NSLog(@"clicked on action/outlet: %@",name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[super mouseDown: theEvent];
|
[super mouseDown: theEvent];
|
||||||
|
@ -616,7 +610,6 @@ static NSColor *darkGreyBlueColor = nil;
|
||||||
|
|
||||||
- (void)addAttributeToClass
|
- (void)addAttributeToClass
|
||||||
{
|
{
|
||||||
NSLog(@"got it here 2");
|
|
||||||
if(_isEditing == YES)
|
if(_isEditing == YES)
|
||||||
{
|
{
|
||||||
if(_edittype == Actions)
|
if(_edittype == Actions)
|
||||||
|
@ -632,6 +625,11 @@ static NSColor *darkGreyBlueColor = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)removeAttributeFromClass
|
||||||
|
{
|
||||||
|
NSLog(@"Remove attribute not yet implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
- (void) editColumn: (int) columnIndex
|
- (void) editColumn: (int) columnIndex
|
||||||
row: (int) rowIndex
|
row: (int) rowIndex
|
||||||
withEvent: (NSEvent *) theEvent
|
withEvent: (NSEvent *) theEvent
|
||||||
|
@ -647,6 +645,7 @@ static NSColor *darkGreyBlueColor = nil;
|
||||||
NSImage *image = nil;
|
NSImage *image = nil;
|
||||||
NSCell *imageCell = nil;
|
NSCell *imageCell = nil;
|
||||||
id value = nil;
|
id value = nil;
|
||||||
|
BOOL isOutletOrAction = NO;
|
||||||
|
|
||||||
// We refuse to edit cells if the delegate can not accept results
|
// We refuse to edit cells if the delegate can not accept results
|
||||||
// of editing.
|
// of editing.
|
||||||
|
@ -696,6 +695,7 @@ static NSColor *darkGreyBlueColor = nil;
|
||||||
byItem: item];
|
byItem: item];
|
||||||
if([value isKindOfClass: [GormOutletActionHolder class]])
|
if([value isKindOfClass: [GormOutletActionHolder class]])
|
||||||
{
|
{
|
||||||
|
isOutletOrAction = YES;
|
||||||
value = [value getName];
|
value = [value getName];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -755,9 +755,17 @@ static NSColor *darkGreyBlueColor = nil;
|
||||||
level = [self levelForItem: item];
|
level = [self levelForItem: item];
|
||||||
indentationFactor = _indentationPerLevel * level;
|
indentationFactor = _indentationPerLevel * level;
|
||||||
drawingRect = [self frameOfCellAtColumn: columnIndex row: rowIndex];
|
drawingRect = [self frameOfCellAtColumn: columnIndex row: rowIndex];
|
||||||
drawingRect.origin.x += indentationFactor + 5 + [image size].width;
|
if(isOutletOrAction)
|
||||||
drawingRect.size.width -= indentationFactor + 5 + [image size].width;
|
{
|
||||||
|
drawingRect.origin.x += _attributeOffset;
|
||||||
|
drawingRect.size.width -= _attributeOffset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
drawingRect.origin.x += indentationFactor + 5 + [image size].width;
|
||||||
|
drawingRect.size.width -= indentationFactor + 5 + [image size].width;
|
||||||
|
}
|
||||||
|
|
||||||
// create the image cell..
|
// create the image cell..
|
||||||
imageCell = [[NSCell alloc] initImageCell: image];
|
imageCell = [[NSCell alloc] initImageCell: image];
|
||||||
if(_indentationMarkerFollowsCell)
|
if(_indentationMarkerFollowsCell)
|
||||||
|
|
Loading…
Reference in a new issue