Various bug fixes and updates.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@14154 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Gregory John Casamento 2002-07-15 05:58:01 +00:00
parent 5560ebae12
commit 933d1f405a
7 changed files with 198 additions and 72 deletions

View file

@ -1,3 +1,11 @@
2002-07-14 Gregory John Casamento <greg_casamento@yahoo.com>
* GormClassManager.[hm]: Added methods to support deletion of
classes, outlets, and actions.
* GormDocument.m: Made various bug fixes. Added methods to
support deletion.
* Gorm.m: Added menu item fro "Remove..."
2002-07-14 Gregory John Casamento <greg_casamento@yahoo.com>
* GormClassManager.[hm]: Added new methods:
@ -5,16 +13,20 @@
- (NSString *) addNewOutletToClassNamed: (NSString *)name;
- (BOOL) loadCustomClasses: (NSString*)path;
- (BOOL) isCustomClass: (NSString *)className;
- (BOOL) isAction: (NSString *)actionName ofClass: (NSString *)className;
- (BOOL) isOutlet: (NSString *)outletName ofClass: (NSString *)className;
Changed the format of the ".classes" file to store only the custom classes.
This is more efficient since the full class list is already loaded when the
GormClassManager is initialized. The custom class list is merged with this
- (BOOL) isAction: (NSString *)actionName
ofClass: (NSString *)className;
- (BOOL) isOutlet: (NSString *)
outletName ofClass: (NSString *)className;
Changed the format of the ".classes" file to store only the
custom classes. This is more efficient since the full class
list is already loaded when the GormClassManager is
initialized. The custom class list is merged with this
to create the display shown in the classes view.
* GormDocument.m: modified to utilize the above routines in the method which
loads the .gorm file and the data source.
* GormOutlineView.m: Added new methods to add new actions/outlets with generic
names so that the user can edit the actions/outlets once added.
* GormDocument.m: modified to utilize the above routines in
the method which loads the .gorm file and the data source.
* GormOutlineView.m: Added new methods to add new actions/outlets
with generic names so that the user can edit the actions/outlets
once added.
2002-07-13 Gregory John Casamento <greg_casamento@yahoo.com>

10
Gorm.m
View file

@ -418,9 +418,9 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
return [(id)[self activeDocument] addAttributeToClass: sender];
}
- (id) removeAttributeFromClass: (id)sender
- (id) remove: (id)sender
{
return [(id)[self activeDocument] removeAttributeFromClass: sender];
return [(id)[self activeDocument] remove: sender];
}
- (id) editClass: (id)sender
@ -639,11 +639,11 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
[aMenu addItemWithTitle: @"Instantiate"
action: @selector(instantiateClass:)
keyEquivalent: @""];
[aMenu addItemWithTitle: @"Add Outlet/Action.."
[aMenu addItemWithTitle: @"Add Outlet/Action..."
action: @selector(addAttributeToClass:)
keyEquivalent: @""];
[aMenu addItemWithTitle: @"Delete Outlet/Action.."
action: @selector(removeAttributeFromClass:)
[aMenu addItemWithTitle: @"Remove..."
action: @selector(remove:)
keyEquivalent: @""];
menuItem = [mainMenu addItemWithTitle: @"Classes"
action: NULL

View file

@ -23,13 +23,16 @@
- (NSArray*) subClassesOf: (NSString *)superclass;
- (void) removeAction: (NSString*)anAction forObject: (NSObject*)anObject;
- (void) removeOutlet: (NSString*)anOutlet forObject: (NSObject*)anObject;
- (void) removeAction: (NSString*)anAction fromClassNamed: (NSString*)anObject;
- (void) removeOutlet: (NSString*)anOutlet fromClassNamed: (NSString*)anObject;
- (void) addOutlet: (NSString *)anOutlet forClassNamed: (NSString *)className;
- (void) addAction: (NSString *)anAction forClassNamed: (NSString *)className;
- (NSString *) addNewActionToClassNamed: (NSString *)name;
- (NSString *) addNewOutletToClassNamed: (NSString *)name;
- (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;
- (void) removeClassNamed: (NSString *)className;
- (NSString*) addClassWithSuperClassName: (NSString*)name;
- (BOOL) addClassNamed: (NSString*)className
withSuperClassNamed: (NSString*)superClassName

View file

@ -679,6 +679,36 @@ NSString *IBClassNameChangedNotification = @"IBClassNameChangedNotification";
}
}
- (void) removeAction: (NSString*)anAction fromClassNamed: (NSString *)className
{
NSMutableDictionary *info = [classInformation objectForKey: className];
NSMutableArray *extraActions = [info objectForKey: @"ExtraActions"];
if ([extraActions containsObject: anAction] == YES)
{
NSString *superName = [info objectForKey: @"Super"];
if (superName != nil)
{
NSArray *superActions;
/*
* If this action is new in this class (ie not overriding an
* action in a parent) then we remove it from the list of all
* actions that the object responds to.
*/
superActions = [self allActionsForClassNamed: superName];
if ([superActions containsObject: anAction] == NO)
{
NSMutableArray *array = [info objectForKey: @"AllActions"];
[array removeObject: anAction];
}
}
[extraActions removeObject: anAction];
}
}
- (void) removeOutlet: (NSString*)anOutlet forObject: (id)anObject
{
NSMutableDictionary *info = [self classInfoForObject: anObject];
@ -695,6 +725,32 @@ NSString *IBClassNameChangedNotification = @"IBClassNameChangedNotification";
}
}
- (void) removeOutlet: (NSString*)anOutlet fromClassNamed: (NSString *)className
{
NSMutableDictionary *info = [classInformation objectForKey: className];
NSMutableArray *extraOutlets = [info objectForKey: @"ExtraOutlets"];
NSMutableArray *allOutlets = [info objectForKey: @"AllOutlets"];
if ([extraOutlets containsObject: anOutlet] == YES)
{
[extraOutlets removeObject: anOutlet];
}
if ([allOutlets containsObject: anOutlet] == YES)
{
[allOutlets removeObject: anOutlet];
}
}
- (void) removeClassNamed: (NSString *)className
{
if([customClasses containsObject: className])
{
[customClasses removeObject: className];
}
[classInformation removeObjectForKey: className];
}
- (BOOL) renameClassNamed: (NSString*)oldName newName: (NSString*)name
{
id classInfo = [classInformation objectForKey: oldName];
@ -841,8 +897,6 @@ NSString *IBClassNameChangedNotification = @"IBClassNameChangedNotification";
- (BOOL)loadCustomClasses: (NSString *)path
{
NSDictionary *dict;
NSEnumerator *enumerator;
NSString *key;
NSLog(@"Load custom classes from file %@",path);

View file

@ -707,9 +707,9 @@ static NSImage *classesImage = nil;
return self;
}
- (id) removeAttributeFromClass: (id)sender
- (id) remove: (id)sender
{
[classesView removeAttributeFromClass];
[classesView removeSelectedItem];
return self;
}
@ -2161,36 +2161,7 @@ static NSImage *classesImage = nil;
return YES;
}
// --- NSOutlineView dataSource ---
- (id) outlineView: (NSOutlineView *)anOutlineView
objectValueForTableColumn: (NSTableColumn *)aTableColumn
byItem: item
{
if (anOutlineView == classesView)
{
id identifier = [aTableColumn identifier];
id className = item;
id classNames = [classManager allClassNames];
if ([identifier isEqualToString: @"classes"])
{
return className;
}
else if ([identifier isEqualToString: @"outlets"])
{
return [NSString stringWithFormat: @"%d",
[[classManager allOutletsForClassNamed: className] count]];
}
else if ([identifier isEqualToString: @"actions"])
{
return [NSString stringWithFormat: @"%d",
[[classManager allActionsForClassNamed: className] count]];
}
}
return @"";
}
// convenience methods for formatting outlets/actions
- (NSString*) _identifierString: (NSString*)str
{
static NSCharacterSet *illegal = nil;
@ -2244,6 +2215,36 @@ objectValueForTableColumn: (NSTableColumn *)aTableColumn
return identifier;
}
// --- NSOutlineView dataSource ---
- (id) outlineView: (NSOutlineView *)anOutlineView
objectValueForTableColumn: (NSTableColumn *)aTableColumn
byItem: item
{
if (anOutlineView == classesView)
{
id identifier = [aTableColumn identifier];
id className = item;
id classNames = [classManager allClassNames];
if ([identifier isEqualToString: @"classes"])
{
return className;
}
else if ([identifier isEqualToString: @"outlets"])
{
return [NSString stringWithFormat: @"%d",
[[classManager allOutletsForClassNamed: className] count]];
}
else if ([identifier isEqualToString: @"actions"])
{
return [NSString stringWithFormat: @"%d",
[[classManager allActionsForClassNamed: className] count]];
}
}
return @"";
}
- (void) outlineView: (NSOutlineView *)anOutlineView
setObjectValue: (id)anObject
forTableColumn: (NSTableColumn *)aTableColumn
@ -2326,6 +2327,7 @@ numberOfChildrenOfItem: (id)item
return nil;
}
// GormOutlineView data source methods...
- (NSArray *)outlineView: (NSOutlineView *)anOutlineView
actionsForItem: (id)item
{
@ -2360,6 +2362,29 @@ numberOfChildrenOfItem: (id)item
return [classManager addNewOutletToClassNamed: item];
}
- (void) outlineView: (NSOutlineView)anOutlineView
removeItem: (id)item
{
if([item isKindOfClass: [GormOutletActionHolder class]])
{
id itemBeingEdited = [classesView itemBeingEdited];
if([classesView editType] == Actions)
{
[classManager removeAction: [item getName]
fromClassNamed: itemBeingEdited];
}
else if([classesView editType] == Outlets)
{
[classManager removeOutlet: [item getName]
fromClassNamed: itemBeingEdited];
}
}
else
{
[classManager removeClassNamed: item];
}
}
// Delegate methods
- (BOOL) outlineView: (NSOutlineView *)outlineView
shouldEditTableColumn: (NSTableColumn *)tableColumn

View file

@ -63,6 +63,7 @@ typedef enum {None, Outlets, Actions} GSAttributeType;
- (void) setMenuItem: (NSMenuItem *)item;
- (void) addAttributeToClass;
- (GSAttributeType)editType;
- (void) removeSelectedItem;
@end /* interface of GormOutlineView */
// informal protocol to define necessary methods on
@ -83,6 +84,13 @@ typedef enum {None, Outlets, Actions} GSAttributeType;
addNewActionForClass: (id)item;
- (NSString *)outlineView: (NSOutlineView *)anOutlineView
addNewOutletForClass: (id)item;
- (void)outlineView: (NSOutlineView *)anOutlineView
removeItem: (id)item;
@end
@interface NSObject (GormOutlineViewDelegate)
- (BOOL) outlineView: (GormOutlineView *)ov
shouldDeleteItem: (id)item;
@end
// a class to hold the outlet/actions so that the

View file

@ -196,6 +196,53 @@ static NSColor *darkGreyBlueColor = nil;
}
}
- (void)_addNewOutletToObject: (id)item
{
int insertionPoint = 0;
GormOutletActionHolder *holder = [[GormOutletActionHolder alloc] init];
NSString *name = nil;
_numberOfRows += 1;
name = [_dataSource outlineView: self addNewOutletForClass: _itemBeingEdited];
if(name != nil)
{
[holder setName: name];
insertionPoint = [_items indexOfObject: item];
[_items insertObject: holder atIndex: insertionPoint + 1];
[self setNeedsDisplay: YES];
[self noteNumberOfRowsChanged];
}
}
- (void)removeSelectedItem
{
id item = [self itemAtRow: [self selectedRow]];
int deletionPoint = 0;
if(![item isKindOfClass: [GormOutletActionHolder class]])
{
if(item == _itemBeingEdited)
return; // we do not delete a class while it's being edited
}
if(![_dataSource outlineView: self
shouldEditTableColumn: _outlineTableColumn
item: item])
{
return; // return if this is something we can't edit...
}
_numberOfRows -= 1;
[_dataSource outlineView: self removeItem: item];
deletionPoint = [_items indexOfObject: item];
if(deletionPoint != NSNotFound)
{
[_items removeObjectAtIndex: deletionPoint];
[self setNeedsDisplay: YES];
[self noteNumberOfRowsChanged];
}
}
- (void)_openActions: (id)item
{
int numchildren = 0;
@ -236,24 +283,6 @@ static NSColor *darkGreyBlueColor = nil;
[self noteNumberOfRowsChanged];
}
- (void)_addNewOutletToObject: (id)item
{
int insertionPoint = 0;
GormOutletActionHolder *holder = [[GormOutletActionHolder alloc] init];
NSString *name = nil;
_numberOfRows += 1;
name = [_dataSource outlineView: self addNewOutletForClass: _itemBeingEdited];
if(name != nil)
{
[holder setName: name];
insertionPoint = [_items indexOfObject: item];
[_items insertObject: holder atIndex: insertionPoint + 1];
[self setNeedsDisplay: YES];
[self noteNumberOfRowsChanged];
}
}
- (void)_openOutlets: (id)item
{
int numchildren = 0;
@ -633,11 +662,6 @@ static NSColor *darkGreyBlueColor = nil;
}
}
- (void)removeAttributeFromClass
{
NSLog(@"Remove attribute not yet implemented.");
}
- (void) editColumn: (int) columnIndex
row: (int) rowIndex
withEvent: (NSEvent *) theEvent