mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-23 19:51:00 +00:00
Refactored code in GormClassEditor.m to re-use functionality, corrected a palette problem, and made GormClassManager deal with root classes more generically.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@21463 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1976bc7dba
commit
9b1d69cbc7
5 changed files with 63 additions and 66 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2005-07-13 02:17 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||
|
||||
* GormCore/GormClassEditor.m: Changed code in selectClass:editClass:
|
||||
to use the methods from the GormClassManager as appropriate. Removed
|
||||
do.. while construct since it did the same thing as
|
||||
allSuperClassesOf in GormClassManager.
|
||||
* GormCore/GormClassManager.[hm]: Added new method isRootClass: which
|
||||
returns true if the argument is a root class. Also replaced
|
||||
references to @"NSObject" in a number of places with calls to this
|
||||
method. This makes the code more generic.
|
||||
* GormCore/GormPalettesManager.m: Added check in
|
||||
importClasses:withDictionary: which should allow loading palettes
|
||||
which define root level classes.
|
||||
|
||||
2005-07-12 fabien <fabien@sonappart.net>
|
||||
|
||||
* GormCore/GormClassEditor.m: Fix OutlineView / BrowserView switch
|
||||
|
|
|
@ -257,13 +257,15 @@ NSString *GormSwitchViewPreferencesNotification = @"GormSwitchViewPreferencesNot
|
|||
// class selection...
|
||||
- (void) selectClass: (NSString *)className editClass: (BOOL)flag
|
||||
{
|
||||
NSString *currentClass = nil;
|
||||
NSArray *classes, *subclasses;
|
||||
NSEnumerator *en;
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
|
||||
if ( ( ! className )
|
||||
NSString *currentClass = nil;
|
||||
NSArray *classes, *subclasses;
|
||||
NSMutableArray *subClassesArray = [NSMutableArray array];
|
||||
NSEnumerator *en;
|
||||
NSString *superClass;
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
|
||||
if ( ( className == nil )
|
||||
|| ( [className isEqual: @"CustomView"] )
|
||||
|| ( [className isEqual: @"GormSound"] )
|
||||
|| ( [className isEqual: @"GormImage"] )
|
||||
|
@ -282,7 +284,6 @@ NSString *GormSwitchViewPreferencesNotification = @"GormSwitchViewPreferencesNot
|
|||
|
||||
// select the item in the outline view...
|
||||
row = [outlineView rowForItem: className];
|
||||
|
||||
if (row != -1)
|
||||
{
|
||||
[outlineView selectRow: row byExtendingSelection: NO];
|
||||
|
@ -290,51 +291,36 @@ NSString *GormSwitchViewPreferencesNotification = @"GormSwitchViewPreferencesNot
|
|||
}
|
||||
|
||||
// select class in browser...
|
||||
|
||||
NSMutableArray *subClassesArray = [[NSMutableArray alloc] init];
|
||||
int i;
|
||||
NSString *superClass;
|
||||
NSString *className2 = className;
|
||||
[subClassesArray addObject:className2];
|
||||
|
||||
do
|
||||
subClassesArray = [classManager allSuperClassesOf: className];
|
||||
if ((subClassesArray == nil) || ([subClassesArray count] == 0))
|
||||
{
|
||||
superClass = [classManager superClassNameForClassNamed: className2];
|
||||
if ( ! superClass )
|
||||
break;
|
||||
|
||||
className2 = superClass;
|
||||
[subClassesArray addObject:className2];
|
||||
|
||||
if ( [superClass isEqualToString:@"NSObject"] )
|
||||
break;
|
||||
|
||||
return;
|
||||
}
|
||||
while ( YES );
|
||||
|
||||
if (( ! subClassesArray ) || ( [subClassesArray count] == 0 ) )
|
||||
return;
|
||||
[subClassesArray addObject: className]; // include in the list.
|
||||
|
||||
// Get the super class position in the browser. Passing "nil" to subClassesOf causes it
|
||||
// to get all of the root classes.
|
||||
col = 0;
|
||||
|
||||
if ( [[subClassesArray objectAtIndex:([subClassesArray count] -1)]
|
||||
isEqualToString:@"NSObject"] ) {
|
||||
row = 0;
|
||||
}
|
||||
else
|
||||
row = 1;
|
||||
row = [[classManager subClassesOf: nil] indexOfObject: [subClassesArray objectAtIndex: 0]];
|
||||
|
||||
// reset the enumerator...
|
||||
currentClass = nil;
|
||||
[browserView reloadColumn:col];
|
||||
[browserView selectRow:row inColumn:col];
|
||||
|
||||
for (i=([subClassesArray count] - 2);i>=0;i--)
|
||||
{
|
||||
subclasses = [classManager subClassesOf:[[browserView selectedCellInColumn:col] stringValue]];
|
||||
row = [subclasses indexOfObject: [subClassesArray objectAtIndex:i]];
|
||||
col++;
|
||||
[browserView selectRow:row inColumn:col];
|
||||
// [browserView reloadColumn:col];
|
||||
|
||||
// if row is not NSNotFound, then we found something.
|
||||
if(row != NSNotFound)
|
||||
{
|
||||
[browserView selectRow: row inColumn: col];
|
||||
en = [subClassesArray objectEnumerator];
|
||||
[en nextObject]; // skip the first one.
|
||||
while((currentClass = [en nextObject]) != nil)
|
||||
{
|
||||
NSString *prevClass = [[browserView selectedCellInColumn: col] stringValue];
|
||||
subclasses = [classManager subClassesOf: prevClass];
|
||||
row = [subclasses indexOfObject: currentClass];
|
||||
col++;
|
||||
[browserView selectRow:row inColumn:col];
|
||||
}
|
||||
}
|
||||
|
||||
if(flag)
|
||||
|
|
|
@ -93,6 +93,7 @@
|
|||
linkedToClass: (NSString *)subclass;
|
||||
- (NSDictionary *) dictionaryForClassNamed: (NSString *)className;
|
||||
- (NSString *) uniqueClassNameFrom: (NSString *)name;
|
||||
- (BOOL) isRootClass: (NSString *)className;
|
||||
|
||||
/* Managing custom classes */
|
||||
- (BOOL) isCustomClass: (NSString *)className;
|
||||
|
|
|
@ -185,8 +185,7 @@
|
|||
|
||||
- (NSString *) addClassWithSuperClassName: (NSString*)name
|
||||
{
|
||||
if (([name isEqualToString: @"NSObject"]
|
||||
|| [classInformation objectForKey: name] != nil)
|
||||
if (([self isRootClass: name] || [classInformation objectForKey: name] != nil)
|
||||
&& [name isEqual: @"FirstResponder"] == NO)
|
||||
{
|
||||
NSMutableDictionary *classInfo;
|
||||
|
@ -278,7 +277,7 @@
|
|||
// We make an autoreleased copy of all of the inputs. This prevents changes
|
||||
// to the original objects from reflecting here. GJC
|
||||
|
||||
if ([superClassNameCopy isEqualToString: @"NSObject"] ||
|
||||
if ([self isRootClass: superClassNameCopy] ||
|
||||
([classInformation objectForKey: superClassNameCopy] != nil &&
|
||||
[superClassNameCopy isEqualToString: @"FirstResponder"] == NO))
|
||||
{
|
||||
|
@ -1462,8 +1461,7 @@
|
|||
if (superclass != nil
|
||||
&& subclass != nil
|
||||
&& [cn containsObject: subclass]
|
||||
&& ([cn containsObject: superclass]
|
||||
|| [superclass isEqualToString: @"NSObject"])
|
||||
&& ([cn containsObject: superclass] || [self isRootClass: superclass])
|
||||
&& [self isSuperclass: subclass linkedToClass: superclass] == NO)
|
||||
{
|
||||
NSMutableDictionary *info;
|
||||
|
@ -1503,10 +1501,6 @@
|
|||
{
|
||||
superName = [info objectForKey: @"Super"];
|
||||
}
|
||||
if (superName == nil)
|
||||
{
|
||||
superName = @"NSObject";
|
||||
}
|
||||
|
||||
return superName;
|
||||
}
|
||||
|
@ -1519,14 +1513,6 @@
|
|||
{
|
||||
return NO;
|
||||
}
|
||||
if ([superclass isEqualToString: @"NSObject"])
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
if ([subclass isEqualToString: @"NSObject"])
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
ssclass = [self superClassNameForClassNamed: subclass];
|
||||
if ([superclass isEqualToString: ssclass])
|
||||
|
@ -1814,11 +1800,16 @@
|
|||
return ([customClassMap count] == 0);
|
||||
}
|
||||
|
||||
- (BOOL) isRootClass: (NSString *)className
|
||||
{
|
||||
return ([self superClassNameForClassNamed: className] == nil);
|
||||
}
|
||||
|
||||
- (NSString *) nonCustomSuperClassOf: (NSString *)className
|
||||
{
|
||||
NSString *result = className;
|
||||
|
||||
if(![self isCustomClass: className] && ![className isEqual: @"NSObject"])
|
||||
if(![self isCustomClass: className] && ![self isRootClass: className])
|
||||
{
|
||||
result = [self superClassNameForClassNamed: result];
|
||||
}
|
||||
|
@ -1838,7 +1829,7 @@
|
|||
- (NSArray *) allSuperClassesOf: (NSString *)className
|
||||
{
|
||||
NSMutableArray *classes = [NSMutableArray array];
|
||||
while (![className isEqualToString: @"NSObject"] && className != nil)
|
||||
while (![self isRootClass: className] && className != nil)
|
||||
{
|
||||
NSDictionary *dict = [self classInfoForClassName: className];
|
||||
if(dict != nil)
|
||||
|
|
|
@ -703,7 +703,12 @@ static NSImage *dragImage = nil;
|
|||
NSMutableArray *actions = [self actionsForClass: cls];
|
||||
NSMutableArray *outlets = [self outletsForClass: cls];
|
||||
|
||||
[classDict setObject: superClassName forKey: @"Super"];
|
||||
// if the superclass is defined, set it. if not, don't since
|
||||
// this might be a palette which adds a root class.
|
||||
if(superClassName != nil)
|
||||
{
|
||||
[classDict setObject: superClassName forKey: @"Super"];
|
||||
}
|
||||
|
||||
// set the action/outlet keys
|
||||
if(actions != nil)
|
||||
|
|
Loading…
Reference in a new issue