From c30d6c19132d7c2b94caab768a6041dfd8829294 Mon Sep 17 00:00:00 2001 From: Matt Rice Date: Tue, 19 Sep 2006 19:21:14 +0000 Subject: [PATCH] * GDL2Palette/KeyWrapper.h: Add LocalType. * GDL2Palette/ConnectInspector.m (_localKeysFromDisplayGroup): New method. (updateValues:): Add local keys. (_oaBrowserAction:): Enable ok button for LocalType. Handle relationships explicitly (browser:willDisplayCell:atRow:column:): Enable and set leaf for LocalType keys. * GDL2Palette/DisplayGroupInspector.[hm]: Add editor for local keys. * GDL2Palette/GDL2DisplayGroupInspector.gorm: Ditto. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@23563 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 13 ++++++ GDL2Palette/ConnectionInspector.m | 34 ++++++++++++-- GDL2Palette/DisplayGroupInspector.h | 11 ++++- GDL2Palette/DisplayGroupInspector.m | 43 ++++++++++++++++++ .../data.classes | 11 ++++- .../objects.gorm | Bin 2489 -> 5620 bytes GDL2Palette/KeyWrapper.h | 3 +- 7 files changed, 106 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 695a958..5cabe93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-09-19 Matt Rice + + * GDL2Palette/KeyWrapper.h: Add LocalType. + * GDL2Palette/ConnectInspector.m (_localKeysFromDisplayGroup): New + method. + (updateValues:): Add local keys. + (_oaBrowserAction:): Enable ok button for LocalType. + Handle relationships explicitly + (browser:willDisplayCell:atRow:column:): Enable and set leaf for + LocalType keys. + * GDL2Palette/DisplayGroupInspector.[hm]: Add editor for local keys. + * GDL2Palette/GDL2DisplayGroupInspector.gorm: Ditto. + 2006-09-18 Matt Rice * DBModeler/SQLGenerator.m (-executeSQL:): Fix memory leak, diff --git a/GDL2Palette/ConnectionInspector.m b/GDL2Palette/ConnectionInspector.m index 26a2b66..3274e33 100644 --- a/GDL2Palette/ConnectionInspector.m +++ b/GDL2Palette/ConnectionInspector.m @@ -210,6 +210,23 @@ static NSMapTable *_objectToAssociation; return AUTORELEASE(ret); } +- (NSArray *) _localKeysFromDisplayGroup:(EODisplayGroup *)dg +{ + NSMutableArray *ret = [[NSMutableArray alloc] init]; + NSArray *local = [dg localKeys]; + int i,c; + + for (i = 0, c = [local count]; i < c; i++) + { + id obj = [local objectAtIndex:i]; + id key = [KeyWrapper wrapperWithKey:obj type:LocalType]; + + [ret addObject:key]; + } + + return AUTORELEASE(ret); +} + /* for normal outlets/actions */ - (NSArray *) _keysFromArray:(NSArray *)arr { @@ -234,6 +251,7 @@ static NSMapTable *_objectToAssociation; id cd = [ds classDescriptionForObjects]; [_values addObjectsFromArray:[self _keysFromClassDescription:cd]]; } + [_values addObjectsFromArray:[self _localKeysFromDisplayGroup:dest]]; } } @@ -438,9 +456,12 @@ static NSMapTable *_objectToAssociation; for (i = 1; i < column; i++) { int aRow = [sender selectedRowInColumn:i]; - val = [vals objectAtIndex:aRow]; - if ([val keyType] != AttributeType) + val = [vals objectAtIndex:aRow]; + type = [val keyType]; + + if (type == ToManyRelationshipType + || type == ToOneRelationshipType) { classDesc = [classDesc classDescriptionForDestinationKey:[val key]]; @@ -458,7 +479,8 @@ static NSMapTable *_objectToAssociation; case 'M': wantsTypes |= ToManyRelationshipType; break; } } - [okButton setEnabled:(wantsTypes & type)]; + [okButton setEnabled:(wantsTypes & type) + || (type == LocalType)]; } } } @@ -682,11 +704,13 @@ willDisplayCell:(id)cell atRow:(int)row column:(int)column case 'M': wantsTypes |= ToManyRelationshipType; break; } } - [cell setLeaf: (type == AttributeType)]; + [cell setLeaf: (type == AttributeType + || type == LocalType)]; // TODO relationships should be NO... [cell setStringValue: [val key]]; [cell setEnabled:(wantsTypes & type) - || (wantsTypes & AttributeType)]; + || (wantsTypes & AttributeType) + || (type == LocalType)]; } } else if (sender == connectionsBrowser) diff --git a/GDL2Palette/DisplayGroupInspector.h b/GDL2Palette/DisplayGroupInspector.h index 464710a..32a1b9b 100644 --- a/GDL2Palette/DisplayGroupInspector.h +++ b/GDL2Palette/DisplayGroupInspector.h @@ -1,12 +1,21 @@ #include #include -#include + +@class NSButton; +@class NSTableView; +@class NSMutableArray; @interface GDL2DisplayGroupInspector : IBInspector { IBOutlet NSButton *_fetchesOnLoad; IBOutlet NSButton *_refresh; IBOutlet NSButton *_validate; + + IBOutlet NSTableView *_localKeysTable; + IBOutlet NSButton *_addKey; + IBOutlet NSButton *_removeKey; + + NSMutableArray *_localKeys; } -(IBAction) setValidatesImmediately:(id)sender; -(IBAction) setRefreshesAll:(id)sender; diff --git a/GDL2Palette/DisplayGroupInspector.m b/GDL2Palette/DisplayGroupInspector.m index 009a5e2..876846b 100644 --- a/GDL2Palette/DisplayGroupInspector.m +++ b/GDL2Palette/DisplayGroupInspector.m @@ -1,15 +1,24 @@ #include "DisplayGroupInspector.h" #include #include +#include +#include +#include @implementation GDL2DisplayGroupInspector - (id) init { self = [super init]; [NSBundle loadNibNamed:@"GDL2DisplayGroupInspector" owner:self]; + _localKeys = [[NSMutableArray alloc] init]; return self; } +- (void) dealloc +{ + RELEASE(_localKeys); +} + -(IBAction) setValidatesImmediately:(id)sender; { [(EODisplayGroup *)[self object] @@ -38,6 +47,40 @@ [_refresh setIntValue:[object usesOptimisticRefresh] ? NO : YES]; } +- (void) addKey:(id)sender +{ + [_localKeys addObject:@""]; + [_localKeysTable reloadData]; + [_localKeysTable selectRow:([_localKeys count] - 1) byExtendingSelection:NO]; +} + +- (void) removeKey:(id)sender +{ + int selRow = [_localKeysTable selectedRow]; + if (selRow != NSNotFound && selRow > 0 && selRow < [_localKeys count]) + { + [_localKeys removeObjectAtIndex:[_localKeysTable selectedRow]]; + [_localKeysTable reloadData]; + } +} + +- (int) numberOfRowsInTableView:(NSTableView *)tv +{ + return [_localKeys count]; +} + +- (id) tableView:(NSTableView *)tv objectValueForTableColumn:(NSTableColumn *)tc +row:(int)row +{ + return [_localKeys objectAtIndex:row]; +} + +- (void) tableView:(NSTableView *)tv setObjectValue:(id)newValue forTableColumn:(NSTableColumn *)tc row:(int) row; +{ + [_localKeys replaceObjectAtIndex:row withObject:newValue]; + [object setLocalKeys:_localKeys]; +} + @end diff --git a/GDL2Palette/GDL2DisplayGroupInspector.gorm/data.classes b/GDL2Palette/GDL2DisplayGroupInspector.gorm/data.classes index 6d68a30..449775f 100644 --- a/GDL2Palette/GDL2DisplayGroupInspector.gorm/data.classes +++ b/GDL2Palette/GDL2DisplayGroupInspector.gorm/data.classes @@ -2,6 +2,8 @@ "## Comment" = "Do NOT change this file, Gorm maintains it"; FirstResponder = { Actions = ( + "addKey:", + "removeKey:", "setFetchesOnLoad:", "setRefreshesAll:", "setValidatesImmediately:" @@ -12,12 +14,17 @@ Actions = ( "setValidatesImmediately:", "setRefreshesAll:", - "setFetchesOnLoad:" + "setFetchesOnLoad:", + "addKey:", + "removeKey:" ); Outlets = ( _fetchesOnLoad, _refresh, - _validate + _validate, + _addKey, + _localKeysTable, + _removeKey ); Super = IBInspector; }; diff --git a/GDL2Palette/GDL2DisplayGroupInspector.gorm/objects.gorm b/GDL2Palette/GDL2DisplayGroupInspector.gorm/objects.gorm index 7f8fd6189a4764ddecc7a91491dfd1ac4c97096c..d94795c9036b6b30192b6a4f310d7c7508f1fc17 100644 GIT binary patch literal 5620 zcmb^#S$o^YaS7d|?kkclJM^K%N*Z@omYalbYLQe#yLKqYaO|{otUx3rF#!RZhZMDG zqx4A98+EU=&4VBN^$C3Fd%pG`^cQtzcd-IVF?G|5pTObl?A$Xui(LMVTHUTBt!iPn zv}XhUEf6aYL0F&<;1IWu3{%6e|yD!F!*F=lXs4d%^_t#|A~9e*cB z07=g}R;_04Ta}8Cj?#MhASqzht0i}b2nC~oMFjh1@G)TI&0CghJA8-@C{XZ=(>5sw ze;Yi(5_$8sU8{I*Q814&V#55{*~HaD#uDjq#%2@QPY}%hg9$M`L}4KE14OP}L3R50 zFze5ocT4s@F8v1<$Qg;4ctkiG3_md=Mjn~;edy;SY*afhU9DONw2hCFLE%q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 @@ typedef enum KeyType AttributeType = 1, ToOneRelationshipType = 2, ToManyRelationshipType = 4, - OtherType = 8 + OtherType = 8, + LocalType = 16 }KeyType; @interface KeyWrapper: NSObject