mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-04-22 12:55:44 +00:00
* DBModeler/ModelerAttributeEditor.m
(-displaygroupDidChangeSelection:): Activate self on selection change. * DBModeler/MainModelEditor.m (-_activateSelection): Move method to EOModeler. (viewSelectedObject): Remove method. (outlineViewSelectionDidChange:): Call -activateSelection. * EOModeler/EOModelerEditor.m: Add activateSelection extension/method. * EOModeler/EOModelerEditor.h: Ditto. * EOModeler/EOModelerDocument.m (-addAttribute): (-addRelationship): Add some Fixme's. Call -activateSelection on the editor. (-delete:): Revert the selection back to the viewed object, and activate the new selection. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@28035 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
20b7f118b4
commit
6b1e6b1085
6 changed files with 136 additions and 83 deletions
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2009-03-03 Matt Rice <ratmice@gmail.com>
|
||||
|
||||
* DBModeler/ModelerAttributeEditor.m
|
||||
(-displaygroupDidChangeSelection:): Activate self on selection change.
|
||||
* DBModeler/MainModelEditor.m (-_activateSelection): Move method to
|
||||
EOModeler.
|
||||
(viewSelectedObject): Remove method.
|
||||
(outlineViewSelectionDidChange:): Call -activateSelection.
|
||||
* EOModeler/EOModelerEditor.m: Add activateSelection extension/method.
|
||||
* EOModeler/EOModelerEditor.h: Ditto.
|
||||
* EOModeler/EOModelerDocument.m (-addAttribute):
|
||||
(-addRelationship): Add some Fixme's. Call -activateSelection on the
|
||||
editor.
|
||||
(-delete:): Revert the selection back to the viewed object, and
|
||||
activate the new selection.
|
||||
|
||||
|
||||
2009-03-02 Matt Rice <ratmice@gmail.com>
|
||||
|
||||
* DBModeler/ModelerAttributeEditor.m (dealloc): Remove observers and
|
||||
|
|
|
@ -212,80 +212,6 @@
|
|||
[super activate];
|
||||
}
|
||||
|
||||
- (void) viewSelectedObject
|
||||
{
|
||||
[self _activateSelection];
|
||||
[super viewSelectedObject];
|
||||
}
|
||||
|
||||
- (void) _activateSelection
|
||||
{
|
||||
id selection;
|
||||
if ([[self selectionWithinViewedObject] count] == 0)
|
||||
return;
|
||||
|
||||
selection = [[self selectionWithinViewedObject] objectAtIndex:0];
|
||||
#if DEBUG_STUFF == 1
|
||||
GSPrintf(stderr, @"viewing %@(%@)\n", NSStringFromClass([selection class]), [(EOModel *)selection name]);
|
||||
#endif
|
||||
if ([[self activeEditor] canSupportCurrentSelection])
|
||||
[self activateEmbeddedEditor: [self activeEditor]];
|
||||
else
|
||||
{
|
||||
NSArray *friends = [[self activeEditor] friendEditorClasses];
|
||||
int editorsCount;
|
||||
int i,j,c;
|
||||
|
||||
/* first look for instances of our friend classes that can support the
|
||||
current selection */
|
||||
for (i = 0, c = [friends count]; i < c; i++)
|
||||
{
|
||||
for (j = 0,editorsCount = [_editors count]; j < editorsCount; j++)
|
||||
{
|
||||
id friendEditor = [_editors objectAtIndex:j];
|
||||
id friendClass = [friends objectAtIndex:i];
|
||||
|
||||
if ([friendEditor isKindOfClass: friendClass])
|
||||
{
|
||||
if ([friendEditor canSupportCurrentSelection])
|
||||
{
|
||||
[self activateEmbeddedEditor:friendEditor];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* instantiate friends to see if we can support the current selection */
|
||||
for (i = 0,c = [friends count]; i < c; i++)
|
||||
{
|
||||
id friendClass = [friends objectAtIndex:i];
|
||||
id friend = [[friendClass alloc] initWithParentEditor:self];
|
||||
if ([friend canSupportCurrentSelection])
|
||||
{
|
||||
[self activateEmbeddedEditor:friend];
|
||||
RELEASE(friend);
|
||||
return;
|
||||
}
|
||||
RELEASE(friend);
|
||||
}
|
||||
/* look for any old editor this isn't very nice...
|
||||
* because it only works with registered editors, and we can only
|
||||
* register instances of editors, so a) can't load on demand non-friend
|
||||
* editors, or b) we should register instances of all editors */
|
||||
for (i = 0, c = [_editors count]; i < c; i++)
|
||||
{
|
||||
id anEditor = [_editors objectAtIndex:i];
|
||||
|
||||
if ([anEditor canSupportCurrentSelection])
|
||||
{
|
||||
[self activateEmbeddedEditor:anEditor];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* NSOutlineView datasource stuff */
|
||||
- (BOOL)outlineView: (NSOutlineView *)outlineView
|
||||
isItemExpandable: (id)item
|
||||
|
@ -430,7 +356,7 @@
|
|||
}
|
||||
#endif
|
||||
[self setSelectionPath:AUTORELEASE(foo)];
|
||||
[self _activateSelection];
|
||||
[self activateSelection];
|
||||
}
|
||||
|
||||
- (BOOL) outlineView:(NSOutlineView *)view
|
||||
|
|
|
@ -336,10 +336,17 @@
|
|||
if ([selWithin containsObject:_entityToObserve])
|
||||
{
|
||||
NSAssert([selWithin count] == 1, @"how on earth?");
|
||||
[[self parentEditor] viewSelectedObject];
|
||||
/* we need to turn
|
||||
(model, (entity)) into
|
||||
(model, entity, ())
|
||||
*/
|
||||
[[self parentEditor] viewSelectedObject];
|
||||
}
|
||||
/* now select the attribute/relationship */
|
||||
[self setSelectionWithinViewedObject: selObj];
|
||||
[self activate];
|
||||
}
|
||||
|
||||
RELEASE(selWithin);
|
||||
}
|
||||
|
||||
|
|
|
@ -369,18 +369,23 @@ NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey";
|
|||
[newEntity setClassName:@"EOGenericRecord"];
|
||||
[_editingContext insertObject:newEntity];
|
||||
[_model addEntity:AUTORELEASE(newEntity)];
|
||||
|
||||
/* FIXME -parentEditor */
|
||||
[(EOModelerCompoundEditor *)[EOMApp currentEditor] setSelectionWithinViewedObject:[NSArray arrayWithObject:newEntity]];
|
||||
}
|
||||
|
||||
- (void)addAttribute:(id)sender
|
||||
{
|
||||
EOAttribute *attrb;
|
||||
EOModelerEditor *currEd = [EOMApp currentEditor];
|
||||
EOModelerCompoundEditor *currEd;
|
||||
unsigned int attributeNumber;
|
||||
EOEntity *entityObject;
|
||||
NSArray *attributes;
|
||||
int i,c;
|
||||
|
||||
/* FIXME -parentEditor */
|
||||
currEd = (EOModelerCompoundEditor *)[EOMApp currentEditor];
|
||||
|
||||
/* the currentEditor must be in this document */
|
||||
if (![_editors containsObject:currEd])
|
||||
{
|
||||
|
@ -431,19 +436,22 @@ NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey";
|
|||
|
||||
if ([[[EOMApp currentEditor] selectionWithinViewedObject] count]
|
||||
&& [[[[EOMApp currentEditor] selectionWithinViewedObject] objectAtIndex:0] isKindOfClass:[EOEntity class]])
|
||||
[(EOModelerCompoundEditor *)[EOMApp currentEditor] viewSelectedObject];
|
||||
[currEd viewSelectedObject];
|
||||
|
||||
[(EOModelerCompoundEditor *)[EOMApp currentEditor] setSelectionWithinViewedObject:[NSArray arrayWithObject:attrb]];
|
||||
[currEd setSelectionWithinViewedObject:[NSArray arrayWithObject:attrb]];
|
||||
[currEd activateSelection];
|
||||
}
|
||||
|
||||
- (void)addRelationship:(id)sender
|
||||
{
|
||||
EORelationship *newRel;
|
||||
EOEntity *srcEntity;
|
||||
EOModelerEditor *currentEditor = [EOMApp currentEditor];
|
||||
EOModelerCompoundEditor *currentEditor;
|
||||
NSArray *relationships;
|
||||
int relationshipNum, i, c;
|
||||
|
||||
/* FIXME -parentEditor */
|
||||
currentEditor = (EOModelerCompoundEditor *)[EOMApp currentEditor];
|
||||
if (![_editors containsObject:currentEditor])
|
||||
{
|
||||
[[NSException exceptionWithName:NSInternalInconsistencyException
|
||||
|
@ -492,13 +500,17 @@ NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey";
|
|||
|
||||
if ([[[EOMApp currentEditor] selectionWithinViewedObject] count]
|
||||
&& [[[[EOMApp currentEditor] selectionWithinViewedObject] objectAtIndex:0] isKindOfClass:[EOEntity class]])
|
||||
[(EOModelerCompoundEditor *)[EOMApp currentEditor] viewSelectedObject];
|
||||
[(EOModelerCompoundEditor *)[EOMApp currentEditor] setSelectionWithinViewedObject:[NSArray arrayWithObject:newRel]];
|
||||
[currentEditor viewSelectedObject];
|
||||
|
||||
[currentEditor setSelectionWithinViewedObject:[NSArray arrayWithObject:newRel]];
|
||||
[currentEditor activateSelection];
|
||||
}
|
||||
|
||||
- (void)delete:(id)sender
|
||||
{
|
||||
NSArray *objects = [[EOMApp currentEditor] selectionWithinViewedObject];
|
||||
NSMutableArray *tmp = [NSMutableArray array];
|
||||
NSArray *vop = [[EOMApp currentEditor] viewedObjectPath];
|
||||
unsigned i,c = [objects count];
|
||||
|
||||
if (c == 0)
|
||||
|
@ -574,7 +586,17 @@ NSString *EOMConsistencyModelObjectKey = @"EOMConsistencyModelObjectKey";
|
|||
[[object entity] removeRelationship: object];
|
||||
}
|
||||
}
|
||||
[[EOMApp currentEditor] setSelectionWithinViewedObject:[NSArray array]];
|
||||
c = [vop count] - 1;
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
[tmp addObject: [vop objectAtIndex:i]];
|
||||
}
|
||||
[tmp addObject:[NSArray arrayWithObject:[vop lastObject]]];
|
||||
|
||||
[[EOMApp currentEditor] setSelectionPath: tmp];
|
||||
|
||||
/* FIXME -parentEditor */
|
||||
[(EOModelerCompoundEditor *)[EOMApp currentEditor] activateSelection];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,5 +80,10 @@
|
|||
- (void) selectionDidChange:(NSNotification *)notif;
|
||||
@end
|
||||
|
||||
/* gdl2 extension */
|
||||
@interface EOModelerCompoundEditor(activation)
|
||||
- (void) activateSelection;
|
||||
@end
|
||||
|
||||
#endif // __EOModelerEditor_H__
|
||||
|
||||
|
|
|
@ -138,6 +138,7 @@
|
|||
}
|
||||
printf("\n\n");
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation EOModelerCompoundEditor
|
||||
|
@ -476,3 +477,78 @@
|
|||
|
||||
@end
|
||||
|
||||
|
||||
@implementation EOModelerCompoundEditor(activation)
|
||||
/*
|
||||
* gdl2 extension.
|
||||
*/
|
||||
- (void) activateSelection
|
||||
{
|
||||
id selection;
|
||||
if ([[self selectionWithinViewedObject] count] == 0)
|
||||
return;
|
||||
|
||||
selection = [[self selectionWithinViewedObject] objectAtIndex:0];
|
||||
#if DEBUG_STUFF == 1
|
||||
GSPrintf(stderr, @"viewing %@(%@)\n", NSStringFromClass([selection class]), [(EOModel *)selection name]);
|
||||
#endif
|
||||
if ([[self activeEditor] canSupportCurrentSelection])
|
||||
[self activateEmbeddedEditor: [self activeEditor]];
|
||||
else
|
||||
{
|
||||
NSArray *friends = [[self activeEditor] friendEditorClasses];
|
||||
int editorsCount;
|
||||
int i,j,c;
|
||||
|
||||
/* first look for instances of our friend classes that can support the
|
||||
current selection */
|
||||
for (i = 0, c = [friends count]; i < c; i++)
|
||||
{
|
||||
for (j = 0,editorsCount = [_editors count]; j < editorsCount; j++)
|
||||
{
|
||||
id friendEditor = [_editors objectAtIndex:j];
|
||||
id friendClass = [friends objectAtIndex:i];
|
||||
|
||||
if ([friendEditor isKindOfClass: friendClass])
|
||||
{
|
||||
if ([friendEditor canSupportCurrentSelection])
|
||||
{
|
||||
[self activateEmbeddedEditor:friendEditor];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* instantiate friends to see if we can support the current selection */
|
||||
for (i = 0,c = [friends count]; i < c; i++)
|
||||
{
|
||||
id friendClass = [friends objectAtIndex:i];
|
||||
id friend = [[friendClass alloc] initWithParentEditor:self];
|
||||
if ([friend canSupportCurrentSelection])
|
||||
{
|
||||
[self activateEmbeddedEditor:friend];
|
||||
RELEASE(friend);
|
||||
return;
|
||||
}
|
||||
RELEASE(friend);
|
||||
}
|
||||
/* look for any old editor this isn't very nice...
|
||||
* because it only works with registered editors, and we can only
|
||||
* register instances of editors, so a) can't load on demand non-friend
|
||||
* editors, or b) we should register instances of all editors */
|
||||
for (i = 0, c = [_editors count]; i < c; i++)
|
||||
{
|
||||
id anEditor = [_editors objectAtIndex:i];
|
||||
|
||||
if ([anEditor canSupportCurrentSelection])
|
||||
{
|
||||
[self activateEmbeddedEditor:anEditor];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue