mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-21 02:41:04 +00:00
* GSWDatabase/WODisplayGroup.m
respect GNUstep coding standard (curly brackets placement, indentation) fix _deleteObject: (undo selectors) fix _insertObjectWithObjectAndIndex: (NSAssert) fix insertObject:atIndex: (undo selectors) git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@37918 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
37ad587ea1
commit
3c024e08cd
2 changed files with 109 additions and 105 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2014-05-29 Manuel Guesdon <mguesdon@orange-concept.com>
|
||||||
|
* GSWDatabase/WODisplayGroup.m
|
||||||
|
respect GNUstep coding standard (curly brackets placement, indentation)
|
||||||
|
fix _deleteObject: (undo selectors)
|
||||||
|
fix _insertObjectWithObjectAndIndex: (NSAssert)
|
||||||
|
fix insertObject:atIndex: (undo selectors)
|
||||||
2014-05-22 Manuel Guesdon <mguesdon@orange-concept.com>
|
2014-05-22 Manuel Guesdon <mguesdon@orange-concept.com>
|
||||||
* GSWeb/GSWAssociation.h
|
* GSWeb/GSWAssociation.h
|
||||||
replace logTakeValue: by _logPullValue:inComponent:
|
replace logTakeValue: by _logPullValue:inComponent:
|
||||||
|
|
|
@ -283,60 +283,61 @@ static BOOL globalDefaultForValidatesChangesImmediately = NO;
|
||||||
-(BOOL)_deleteObject:(id)object
|
-(BOOL)_deleteObject:(id)object
|
||||||
{
|
{
|
||||||
BOOL result=NO;
|
BOOL result=NO;
|
||||||
|
|
||||||
|
|
||||||
if(_delegateRespondsTo.shouldDeleteObject
|
if(_delegateRespondsTo.shouldDeleteObject
|
||||||
&& ![_delegate displayGroup:self
|
&& ![_delegate displayGroup:self
|
||||||
shouldDeleteObject:object])
|
shouldDeleteObject:object])
|
||||||
result=NO;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BOOL deletionOK=NO;
|
|
||||||
NS_DURING
|
|
||||||
{
|
{
|
||||||
if(_dataSource)
|
|
||||||
[_dataSource deleteObject:object];
|
|
||||||
deletionOK=YES;
|
|
||||||
}
|
|
||||||
NS_HANDLER
|
|
||||||
{
|
|
||||||
NSLog(@"EXCEPTION: %@",localException);
|
|
||||||
[self _presentAlertWithTitle:@"Error Deleting Object"
|
|
||||||
message:[localException reason]];
|
|
||||||
result=NO;
|
result=NO;
|
||||||
}
|
}
|
||||||
NS_ENDHANDLER;
|
else
|
||||||
if (deletionOK)
|
|
||||||
{
|
{
|
||||||
EOUndoManager* undoManager=[self undoManager];
|
BOOL deletionOK=NO;
|
||||||
if (undoManager)
|
NS_DURING
|
||||||
{
|
{
|
||||||
[undoManager registerUndoWithTarget:self
|
if(_dataSource)
|
||||||
selector:@selector(_selectObjects:)
|
[_dataSource deleteObject:object];
|
||||||
arg:[self selectedObjects]];
|
deletionOK=YES;
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
NSLog(@"EXCEPTION: %@",localException);
|
||||||
|
[self _presentAlertWithTitle:@"Error Deleting Object"
|
||||||
|
message:[localException reason]];
|
||||||
|
result=NO;
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER;
|
||||||
|
if (deletionOK)
|
||||||
|
{
|
||||||
|
EOUndoManager* undoManager=[self undoManager];
|
||||||
|
if (undoManager)
|
||||||
|
{
|
||||||
|
[undoManager registerUndoWithTarget:self
|
||||||
|
selector:@selector(selectObjectsIdenticalTo:)
|
||||||
|
arg:[self selectedObjects]];
|
||||||
|
|
||||||
[undoManager registerUndoWithTarget:self
|
[undoManager registerUndoWithTarget:self
|
||||||
selector:@selector(_insertObjectWithObjectAndIndex:)
|
selector:@selector(_insertObjectWithObjectAndIndex:)
|
||||||
arg:[NSArray arrayWithObjects:object,
|
arg:[NSArray arrayWithObjects:object,
|
||||||
GSWIntNumber([_displayedObjects indexOfObjectIdenticalTo:object]),
|
GSWIntNumber([_displayedObjects indexOfObjectIdenticalTo:object]),
|
||||||
nil]];
|
nil]];
|
||||||
}
|
}
|
||||||
|
|
||||||
[_displayedObjects removeObjectIdenticalTo:object];
|
[_displayedObjects removeObjectIdenticalTo:object];
|
||||||
[_allObjects removeObjectIdenticalTo:object];
|
[_allObjects removeObjectIdenticalTo:object];
|
||||||
|
|
||||||
[self selectObjectsIdenticalTo:[self selectedObjects]
|
[self selectObjectsIdenticalTo:[self selectedObjects]
|
||||||
selectFirstOnNoMatch:NO];
|
selectFirstOnNoMatch:NO];
|
||||||
|
|
||||||
if (_delegateRespondsTo.didDeleteObject)
|
if (_delegateRespondsTo.didDeleteObject)
|
||||||
[_delegate displayGroup:self
|
[_delegate displayGroup:self
|
||||||
didDeleteObject:object];
|
didDeleteObject:object];
|
||||||
|
|
||||||
[self redisplay];
|
[self redisplay];
|
||||||
|
|
||||||
result=YES;
|
result=YES;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,9 +385,8 @@ static BOOL globalDefaultForValidatesChangesImmediately = NO;
|
||||||
id object=nil;
|
id object=nil;
|
||||||
NSNumber* indexObject=nil;
|
NSNumber* indexObject=nil;
|
||||||
int index=0;
|
int index=0;
|
||||||
|
|
||||||
|
NSAssert1([objectAndIndex count]==2,
|
||||||
NSAssert1([objectAndIndex count]==0,
|
|
||||||
@"Bad Array : %@",objectAndIndex);
|
@"Bad Array : %@",objectAndIndex);
|
||||||
|
|
||||||
object = [objectAndIndex objectAtIndex:0];
|
object = [objectAndIndex objectAtIndex:0];
|
||||||
|
@ -397,7 +397,6 @@ static BOOL globalDefaultForValidatesChangesImmediately = NO;
|
||||||
|
|
||||||
[self insertObject:object
|
[self insertObject:object
|
||||||
atIndex:index];
|
atIndex:index];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns 1st index of selection if any, -1 otherwise **/
|
/** Returns 1st index of selection if any, -1 otherwise **/
|
||||||
|
@ -1279,65 +1278,64 @@ shouldRedisplayForEditingContextChangeNotification:notification];
|
||||||
- (void)insertObject:(id)anObject
|
- (void)insertObject:(id)anObject
|
||||||
atIndex:(unsigned)index
|
atIndex:(unsigned)index
|
||||||
{
|
{
|
||||||
|
|
||||||
if ([self endEditing])
|
if ([self endEditing])
|
||||||
{
|
|
||||||
if (index>[_displayedObjects count])
|
|
||||||
{
|
{
|
||||||
[[NSException exceptionWithName:NSInvalidArgumentException
|
if (index>[_displayedObjects count])
|
||||||
reason:[NSString stringWithFormat:@"%@ %@: index %u is beyond the bounds of %d",
|
{
|
||||||
[self class],NSStringFromSelector(_cmd),
|
[[NSException exceptionWithName:NSInvalidArgumentException
|
||||||
index,[_displayedObjects count]]
|
reason:[NSString stringWithFormat:@"%@ %@: index %u is beyond the bounds of %d",
|
||||||
userInfo:nil] raise];
|
[self class],NSStringFromSelector(_cmd),
|
||||||
|
index,[_displayedObjects count]]
|
||||||
|
userInfo:nil] raise];
|
||||||
|
}
|
||||||
|
else if (_delegateRespondsTo.shouldInsertObject == YES
|
||||||
|
&& ![_delegate displayGroup:self
|
||||||
|
shouldInsertObject:anObject
|
||||||
|
atIndex:index])
|
||||||
|
{
|
||||||
|
// to nothing more
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BOOL insertionOK=NO;
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
if (_dataSource)
|
||||||
|
[_dataSource insertObject:anObject];
|
||||||
|
insertionOK=YES;
|
||||||
|
}
|
||||||
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
NSLog(@"EXCEPTION: %@",localException);
|
||||||
|
[self _presentAlertWithTitle:@"Error Inserting Object"
|
||||||
|
message:[localException reason]];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER;
|
||||||
|
if (insertionOK)
|
||||||
|
{
|
||||||
|
EOUndoManager* undoManager=[self undoManager];
|
||||||
|
if (undoManager)
|
||||||
|
{
|
||||||
|
[undoManager registerUndoWithTarget:self
|
||||||
|
selector:@selector(selectObjectsIdenticalTo:)
|
||||||
|
arg:[self selectedObjects]];
|
||||||
|
[undoManager registerUndoWithTarget:self
|
||||||
|
selector:@selector(_deleteObject:)
|
||||||
|
arg:anObject];
|
||||||
|
}
|
||||||
|
[_displayedObjects insertObject:anObject
|
||||||
|
atIndex:index];
|
||||||
|
[_allObjects insertObject:anObject
|
||||||
|
atIndex:index];
|
||||||
|
[self redisplay];
|
||||||
|
|
||||||
|
if (_delegateRespondsTo.didInsertObject)
|
||||||
|
[_delegate displayGroup:self
|
||||||
|
didInsertObject:anObject];
|
||||||
|
[self selectObjectsIdenticalTo:[NSArray arrayWithObject:anObject]];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (_delegateRespondsTo.shouldInsertObject == YES
|
|
||||||
&& ![_delegate displayGroup:self
|
|
||||||
shouldInsertObject:anObject
|
|
||||||
atIndex:index])
|
|
||||||
{
|
|
||||||
// to nothing more
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
BOOL insertionOK=NO;
|
|
||||||
NS_DURING
|
|
||||||
{
|
|
||||||
if (_dataSource)
|
|
||||||
[_dataSource insertObject:anObject];
|
|
||||||
insertionOK=YES;
|
|
||||||
}
|
|
||||||
NS_HANDLER
|
|
||||||
{
|
|
||||||
NSLog(@"EXCEPTION: %@",localException);
|
|
||||||
[self _presentAlertWithTitle:@"Error Inserting Object"
|
|
||||||
message:[localException reason]];
|
|
||||||
}
|
|
||||||
NS_ENDHANDLER;
|
|
||||||
if (insertionOK)
|
|
||||||
{
|
|
||||||
EOUndoManager* undoManager=[self undoManager];
|
|
||||||
if (undoManager)
|
|
||||||
{
|
|
||||||
[undoManager registerUndoWithTarget:self
|
|
||||||
selector:@selector(_selectObjects:)
|
|
||||||
arg:[self selectedObjects]];
|
|
||||||
[undoManager registerUndoWithTarget:self
|
|
||||||
selector:@selector(_deleteObject:)
|
|
||||||
arg:anObject];
|
|
||||||
}
|
|
||||||
[_displayedObjects insertObject:anObject
|
|
||||||
atIndex:index];
|
|
||||||
[_allObjects insertObject:anObject
|
|
||||||
atIndex:index];
|
|
||||||
[self redisplay];
|
|
||||||
|
|
||||||
if (_delegateRespondsTo.didInsertObject)
|
|
||||||
[_delegate displayGroup:self
|
|
||||||
didInsertObject:anObject];
|
|
||||||
[self selectObjectsIdenticalTo:[NSArray arrayWithObject:anObject]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue