From bfd39c720e0ed3e670de4d7827e09c8afa895308 Mon Sep 17 00:00:00 2001 From: Dave Wetzel Date: Tue, 1 Jun 2010 09:30:14 +0000 Subject: [PATCH] * Apps/EOModelEditor/Inspectors/*.gsmarkup tried to fix on X11 * Apps/EOModelEditor/EOModelEditorApp.m new: to create new models manually * Apps/EOModelEditor/Inspectors/EntityInspector.m check for empty strings before filling fields * Apps/EOModelEditor/Inspectors/RelationshipInspector.m check for empty name * Apps/EOModelEditor/EOMEDocument.m addEntity, addRelationship, validateUserInterfaceItem git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@30519 72102866-910b-0410-8b05-ffd578937521 --- Apps/EOModelEditor/EOMEDocument.m | 75 ++++++++++++++++++- Apps/EOModelEditor/EOModelEditorApp.m | 10 +++ .../AdvancedEntityInspector.gsmarkup | 2 +- .../Inspectors/EntityInspector.gsmarkup | 2 +- .../Inspectors/EntityInspector.m | 13 ++-- .../EntityStoredProcedureInspector.gsmarkup | 2 +- .../Inspectors/RelationshipInspector.gsmarkup | 2 +- .../Inspectors/RelationshipInspector.m | 4 + .../Inspectors/UserInfoInspector.gsmarkup | 2 +- ChangeLog | 12 +++ 10 files changed, 113 insertions(+), 11 deletions(-) diff --git a/Apps/EOModelEditor/EOMEDocument.m b/Apps/EOModelEditor/EOMEDocument.m index f7264b3..29522ff 100644 --- a/Apps/EOModelEditor/EOMEDocument.m +++ b/Apps/EOModelEditor/EOMEDocument.m @@ -499,7 +499,6 @@ NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey"; - (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)typeName error:(NSError **)outError { - NSString * newUSLStr = nil; ASSIGN(_eomodel, [EOModel modelWithContentsOfFile: [absoluteURL path]]); ASSIGN(_entityNames,[_eomodel entityNames]); @@ -851,6 +850,46 @@ NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey"; [_outlineView reloadData]; } +- (IBAction)addEntity:(id)sender +{ + EOEntity * newEntity; + NSUInteger count; + + count = [[_eomodel entityNames] count]; + newEntity = [[EOEntity alloc] init]; + [newEntity setName:[NSString stringWithFormat:@"Entity%d", count]]; + [newEntity setClassName:@"EOGenericRecord"]; + + [_eomodel addEntity:newEntity]; + RELEASE(newEntity); + + [_outlineView reloadData]; +} + +- (IBAction)addRelationship:(id)sender +{ + EORelationship * newRel; + EOEntity * selectedEntity; + NSUInteger count = 0; + + selectedEntity = (EOEntity*) _outlineSelection; + + if ([selectedEntity relationships]) { + count = [[selectedEntity relationships] count]; + } + + newRel = [[EORelationship alloc] init]; + + [newRel setName:[NSString stringWithFormat:@"Relationship%d", count]]; + + [selectedEntity addRelationship:newRel]; + + RELEASE(newRel); + + [_bottomTableViewController setRepresentedObject:[selectedEntity relationships]]; + [_bottomTableView reloadData]; +} + - (IBAction)dataBrowser:(id)sender { EOEntity * entity = [self outlineSelection]; @@ -864,6 +903,10 @@ NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey"; } +- (IBAction)delete:(id)sender +{ +} + #pragma mark - #pragma mark key value observing @@ -896,4 +939,34 @@ NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey"; // NSLog(@"%s: %@, %@, %@", __PRETTY_FUNCTION__, keyPath, object, change); } +- (BOOL)validateUserInterfaceItem:(id < NSValidatedUserInterfaceItem >)anItem +{ + + SEL action = [anItem action]; + //NSLog(@"%s: %@", __PRETTY_FUNCTION__, anItem); + + + if ((action == @selector(addAttribute:))) { + if ((!_outlineSelection) || + (([_outlineSelection class] != [EOEntity class]) && ([_outlineSelection class] != [EOStoredProcedure class]))) { + return NO; + } + } + + if ((action == @selector(addRelationship:))) { + if ((!_outlineSelection) || + ([_outlineSelection class] != [EOEntity class])) { + return NO; + } + } + + if ((action == @selector(delete:))) { + if (!_outlineSelection) { + return NO; + } + } + + return [super validateUserInterfaceItem:anItem]; +} + @end diff --git a/Apps/EOModelEditor/EOModelEditorApp.m b/Apps/EOModelEditor/EOModelEditorApp.m index ac72ab9..76530aa 100644 --- a/Apps/EOModelEditor/EOModelEditorApp.m +++ b/Apps/EOModelEditor/EOModelEditorApp.m @@ -117,6 +117,16 @@ } } +- (void) new:(id)sender +{ + EOModel *newModel = [[EOModel alloc] init]; + +// [newModel setName: @"test"]; + [self newDocumentWithModel:newModel]; + RELEASE(newModel); + +} + - (EOMEDocument *) activeDocument { return (EOMEDocument *) [[NSDocumentController sharedDocumentController] currentDocument]; diff --git a/Apps/EOModelEditor/Inspectors/AdvancedEntityInspector.gsmarkup b/Apps/EOModelEditor/Inspectors/AdvancedEntityInspector.gsmarkup index 18595f8..f53267f 100644 --- a/Apps/EOModelEditor/Inspectors/AdvancedEntityInspector.gsmarkup +++ b/Apps/EOModelEditor/Inspectors/AdvancedEntityInspector.gsmarkup @@ -2,7 +2,7 @@ - + diff --git a/Apps/EOModelEditor/Inspectors/EntityInspector.gsmarkup b/Apps/EOModelEditor/Inspectors/EntityInspector.gsmarkup index 3f807c5..3836586 100644 --- a/Apps/EOModelEditor/Inspectors/EntityInspector.gsmarkup +++ b/Apps/EOModelEditor/Inspectors/EntityInspector.gsmarkup @@ -2,7 +2,7 @@ - + diff --git a/Apps/EOModelEditor/Inspectors/EntityInspector.m b/Apps/EOModelEditor/Inspectors/EntityInspector.m index 739d033..08728fa 100644 --- a/Apps/EOModelEditor/Inspectors/EntityInspector.m +++ b/Apps/EOModelEditor/Inspectors/EntityInspector.m @@ -88,14 +88,17 @@ - (void) refresh { - EOModel *activeModel = [[NSApp activeDocument] eomodel]; + NSString * stringValue = nil; + EOModel * activeModel = [[NSApp activeDocument] eomodel]; ASSIGN(_currentEntity, (EOEntity *) [self selectedObject]); - - [nameField setStringValue:[_currentEntity name]]; - [tableNameField setStringValue:[_currentEntity externalName]]; - [classNameField setStringValue:[_currentEntity className]]; + stringValue = [_currentEntity name]; + [nameField setStringValue:(stringValue) ? stringValue : @""]; + stringValue = [_currentEntity externalName]; + [tableNameField setStringValue:(stringValue) ? stringValue : @""]; + stringValue = [_currentEntity className]; + [classNameField setStringValue:(stringValue) ? stringValue : @""]; } diff --git a/Apps/EOModelEditor/Inspectors/EntityStoredProcedureInspector.gsmarkup b/Apps/EOModelEditor/Inspectors/EntityStoredProcedureInspector.gsmarkup index 7890dc6..1744ae1 100644 --- a/Apps/EOModelEditor/Inspectors/EntityStoredProcedureInspector.gsmarkup +++ b/Apps/EOModelEditor/Inspectors/EntityStoredProcedureInspector.gsmarkup @@ -2,7 +2,7 @@ - + diff --git a/Apps/EOModelEditor/Inspectors/RelationshipInspector.gsmarkup b/Apps/EOModelEditor/Inspectors/RelationshipInspector.gsmarkup index a350ce4..b0bddfb 100644 --- a/Apps/EOModelEditor/Inspectors/RelationshipInspector.gsmarkup +++ b/Apps/EOModelEditor/Inspectors/RelationshipInspector.gsmarkup @@ -2,7 +2,7 @@ - + diff --git a/Apps/EOModelEditor/Inspectors/RelationshipInspector.m b/Apps/EOModelEditor/Inspectors/RelationshipInspector.m index 85885db..2671a5d 100644 --- a/Apps/EOModelEditor/Inspectors/RelationshipInspector.m +++ b/Apps/EOModelEditor/Inspectors/RelationshipInspector.m @@ -241,6 +241,10 @@ if (!destinationEntity) { NSString * name = [[destinationEntityBrowser selectedCell] title]; + + if (!name) { + return 0; + } activeModel = [[NSApp activeDocument] eomodel]; destinationEntity = [activeModel entityNamed:name]; diff --git a/Apps/EOModelEditor/Inspectors/UserInfoInspector.gsmarkup b/Apps/EOModelEditor/Inspectors/UserInfoInspector.gsmarkup index 0e54d1e..5b37670 100644 --- a/Apps/EOModelEditor/Inspectors/UserInfoInspector.gsmarkup +++ b/Apps/EOModelEditor/Inspectors/UserInfoInspector.gsmarkup @@ -2,7 +2,7 @@ - + diff --git a/ChangeLog b/ChangeLog index b0ab33c..fed929e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2010-06-01 David Wetzel + * Apps/EOModelEditor/Inspectors/*.gsmarkup + tried to fix on X11 + * Apps/EOModelEditor/EOModelEditorApp.m + new: to create new models manually + * Apps/EOModelEditor/Inspectors/EntityInspector.m + check for empty strings before filling fields + * Apps/EOModelEditor/Inspectors/RelationshipInspector.m + check for empty name + * Apps/EOModelEditor/EOMEDocument.m + addEntity, addRelationship, validateUserInterfaceItem + 2010-05-31 David Wetzel * Apps/EOModeler/EOMInspectorController.m int -> NSUInteger, call sizeToCells