mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-23 19:51:00 +00:00
reimplemented addAction: and addOutlet: in the class manager.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@20430 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b1efb8b092
commit
d84f889c8d
5 changed files with 53 additions and 37 deletions
|
@ -1,3 +1,12 @@
|
|||
2004-12-08 19:52 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormClassEditor.m: Use new ivar to store selected class.
|
||||
* GormClassManager.m: Reimplement addAction:toClassNamed: and
|
||||
addOutlet:forClassNamed:.
|
||||
* GormImageEditor.m: Release the objects in dealloc.
|
||||
* GormPrivate.h: Added new ivar for GormClassEditor to store
|
||||
selected class in.
|
||||
|
||||
2004-12-05 18:21 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormClassEditor.m: Added new methods moved from GormDocument.
|
||||
|
|
|
@ -96,6 +96,12 @@
|
|||
return AUTORELEASE([(GormClassEditor *)[self alloc] initWithDocument: doc]);
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(selectedClass);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setSelectedClassName: (NSString*)cn
|
||||
{
|
||||
[self selectClass: cn];
|
||||
|
@ -122,6 +128,8 @@
|
|||
NSEnumerator *en;
|
||||
int row = 0;
|
||||
|
||||
ASSIGN(selectedClass, className);
|
||||
|
||||
if(className != nil)
|
||||
{
|
||||
if([className isEqual: @"CustomView"] ||
|
||||
|
@ -192,6 +200,7 @@
|
|||
int row = [self selectedRow];
|
||||
if (row >= 0)
|
||||
{
|
||||
selectedClass = [self selectedClassName];
|
||||
[document setSelectionFromEditor: (id)self];
|
||||
}
|
||||
}
|
||||
|
@ -231,16 +240,14 @@
|
|||
|
||||
- (NSArray*) selection
|
||||
{
|
||||
NSString *selectedClassName = [self selectedClassName];
|
||||
|
||||
// when asked for a selection, it returns a class proxy
|
||||
if (selectedClassName != nil)
|
||||
if (selectedClass != nil)
|
||||
{
|
||||
NSArray *array;
|
||||
GormClassProxy *classProxy;
|
||||
|
||||
classProxy = [[GormClassProxy alloc] initWithClassName:
|
||||
selectedClassName];
|
||||
selectedClass];
|
||||
array = [NSArray arrayWithObject: classProxy];
|
||||
RELEASE(classProxy);
|
||||
return array;
|
||||
|
|
|
@ -48,10 +48,20 @@
|
|||
@end
|
||||
|
||||
@interface NSMutableArray (Private)
|
||||
- (void) mergeObject: (id)object;
|
||||
- (void) mergeObjectsFromArray: (NSArray *)array;
|
||||
@end
|
||||
|
||||
@implementation NSMutableArray (Private)
|
||||
- (void) mergeObject: (id)object
|
||||
{
|
||||
if ([self containsObject: object] == NO)
|
||||
{
|
||||
[self addObject: object];
|
||||
[self sortUsingSelector: @selector(compare:)];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) mergeObjectsFromArray: (NSArray *)array
|
||||
{
|
||||
NSEnumerator *enumerator = [array objectEnumerator];
|
||||
|
@ -61,10 +71,7 @@
|
|||
{
|
||||
while ((obj = [enumerator nextObject]) != nil)
|
||||
{
|
||||
if ([self containsObject: obj] == NO)
|
||||
{
|
||||
[self addObject: obj];
|
||||
}
|
||||
[self mergeObject: obj];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -277,17 +284,13 @@
|
|||
{
|
||||
NSMutableDictionary *info = [classInformation objectForKey: className];
|
||||
NSMutableArray *extraActions = [info objectForKey: @"ExtraActions"];
|
||||
NSMutableArray *allActions = nil;
|
||||
NSMutableArray *allActions = [info objectForKey: @"AllActions"];
|
||||
NSString *anAction = [action copy];
|
||||
NSEnumerator *en = [[self subClassesOf: className] objectEnumerator];
|
||||
NSArray *subClasses = [self allSubclassesOf: className];
|
||||
NSEnumerator *en = [subClasses objectEnumerator];
|
||||
NSString *subclassName = nil;
|
||||
|
||||
// regenerate the key...
|
||||
[info removeObjectForKey: @"AllActions"];
|
||||
[self allActionsForClassNamed: className];
|
||||
allActions = [info objectForKey: @"AllActions"];
|
||||
|
||||
// check all actions...
|
||||
// check all
|
||||
if ([allActions containsObject: anAction])
|
||||
{
|
||||
return;
|
||||
|
@ -307,9 +310,8 @@
|
|||
[info setObject: extraActions forKey: @"ExtraActions"];
|
||||
}
|
||||
|
||||
[extraActions addObject: anAction];
|
||||
[allActions insertObject: anAction atIndex: 0];
|
||||
[allActions sortUsingSelector: @selector(compare:)];
|
||||
[extraActions mergeObject: anAction];
|
||||
[allActions mergeObject: anAction];
|
||||
|
||||
if(![className isEqualToString: @"FirstResponder"])
|
||||
{
|
||||
|
@ -317,8 +319,10 @@
|
|||
}
|
||||
|
||||
while((subclassName = [en nextObject]) != nil)
|
||||
{
|
||||
[self addAction: anAction forClassNamed: subclassName];
|
||||
{
|
||||
NSDictionary *subInfo = [classInformation objectForKey: subclassName];
|
||||
NSMutableArray *subAll = [subInfo objectForKey: @"AllActions"];
|
||||
[subAll mergeObject: anAction];
|
||||
}
|
||||
|
||||
[self touch];
|
||||
|
@ -329,20 +333,16 @@
|
|||
[self addOutlet: outlet forClassNamed: [anObject className]];
|
||||
}
|
||||
|
||||
- (void) addOutlet: (NSString *)outlet forClassNamed: (NSString *)className
|
||||
- (void) addOutlet: (NSString *)outlet forClassNamed: (NSString *)className
|
||||
{
|
||||
NSMutableDictionary *info = [classInformation objectForKey: className];
|
||||
NSMutableArray *extraOutlets = [info objectForKey: @"ExtraOutlets"];
|
||||
NSMutableArray *allOutlets = nil;
|
||||
NSMutableArray *allOutlets = [info objectForKey: @"AllOutlets"];
|
||||
NSString *anOutlet = [outlet copy];
|
||||
NSEnumerator *en = [[self subClassesOf: className] objectEnumerator];
|
||||
NSArray *subClasses = [self allSubclassesOf: className];
|
||||
NSEnumerator *en = [subClasses objectEnumerator];
|
||||
NSString *subclassName = nil;
|
||||
|
||||
// regenerate the key...
|
||||
[info removeObjectForKey: @"AllOutlets"];
|
||||
[self allOutletsForClassNamed: className];
|
||||
allOutlets = [info objectForKey: @"AllOutlets"];
|
||||
|
||||
// check all
|
||||
if ([allOutlets containsObject: anOutlet])
|
||||
{
|
||||
|
@ -355,13 +355,14 @@
|
|||
[info setObject: extraOutlets forKey: @"ExtraOutlets"];
|
||||
}
|
||||
|
||||
[extraOutlets addObject: anOutlet];
|
||||
[allOutlets insertObject: anOutlet atIndex: 0];
|
||||
[allOutlets sortUsingSelector: @selector(compare:)];
|
||||
[extraOutlets mergeObject: anOutlet];
|
||||
[allOutlets mergeObject: anOutlet];
|
||||
|
||||
while((subclassName = [en nextObject]) != nil)
|
||||
{
|
||||
[self addOutlet: outlet forClassNamed: subclassName];
|
||||
NSDictionary *subInfo = [classInformation objectForKey: subclassName];
|
||||
NSMutableArray *subAll = [subInfo objectForKey: @"AllOutlets"];
|
||||
[subAll mergeObject: anOutlet];
|
||||
}
|
||||
|
||||
[self touch];
|
||||
|
@ -402,7 +403,6 @@
|
|||
{
|
||||
int all_index = [allActions indexOfObject: oldAction];
|
||||
[allActions replaceObjectAtIndex: all_index withObject: newAction];
|
||||
[allActions sortUsingSelector: @selector(compare:)];
|
||||
}
|
||||
|
||||
[self touch];
|
||||
|
@ -687,7 +687,6 @@
|
|||
[allActions mergeObjectsFromArray: extraActions];
|
||||
}
|
||||
|
||||
[allActions sortUsingSelector: @selector(compare:)];
|
||||
[info setObject: allActions forKey: @"AllActions"];
|
||||
RELEASE(allActions);
|
||||
}
|
||||
|
@ -809,7 +808,6 @@
|
|||
[allOutlets mergeObjectsFromArray: extraOutlets];
|
||||
}
|
||||
|
||||
[allOutlets sortUsingSelector: @selector(compare:)];
|
||||
[info setObject: allOutlets forKey: @"AllOutlets"];
|
||||
RELEASE(allOutlets);
|
||||
}
|
||||
|
|
|
@ -263,7 +263,8 @@ static int handled_mask= NSDragOperationCopy|NSDragOperationGeneric|NSDragOperat
|
|||
|
||||
// TODO: This is a band-aid fix until I find the actual problem.
|
||||
// This *WILL* leak, but I don't want it crashing on people.
|
||||
|
||||
|
||||
RELEASE(objects);
|
||||
NSLog(@"Released...");
|
||||
}
|
||||
|
||||
|
|
|
@ -170,6 +170,7 @@ extern NSString *GormResizeCellNotification;
|
|||
{
|
||||
GormDocument *document;
|
||||
GormClassManager *classManager;
|
||||
NSString *selectedClass;
|
||||
}
|
||||
- (GormClassEditor*) initWithDocument: (GormDocument*)doc;
|
||||
+ (GormClassEditor*) classEditorForDocument: (GormDocument*)doc;
|
||||
|
|
Loading…
Reference in a new issue