From 052f9d5bcdb0d6aacf11843ad3e142bd9d8111ff Mon Sep 17 00:00:00 2001 From: helge Date: Wed, 3 Aug 2005 19:54:23 +0000 Subject: [PATCH] improved editing context support some cleanups git-svn-id: http://svn.opengroupware.org/SOPE/trunk@962 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-appserver/NGObjWeb/ChangeLog | 6 ++ sope-appserver/NGObjWeb/Version | 2 +- sope-appserver/NGObjWeb/WODisplayGroup.m | 119 +++++++++++------------ 3 files changed, 64 insertions(+), 63 deletions(-) diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index ed60d7ea..86d48a4a 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,3 +1,9 @@ +2005-08-03 Helge Hess + + * WODisplayGroup.m: detect whether an EOEditingContext is available at + runtime (previously compile time), consolidated categories in the + main class to allow for runtime overloading (v4.5.181) + 2005-08-02 Helge Hess * v4.5.180 diff --git a/sope-appserver/NGObjWeb/Version b/sope-appserver/NGObjWeb/Version index 5546ff2e..818fe82b 100644 --- a/sope-appserver/NGObjWeb/Version +++ b/sope-appserver/NGObjWeb/Version @@ -1,6 +1,6 @@ # version file -SUBMINOR_VERSION:=180 +SUBMINOR_VERSION:=181 # v4.5.122 requires libNGExtensions v4.5.153 # v4.5.91 requires libNGExtensions v4.5.134 diff --git a/sope-appserver/NGObjWeb/WODisplayGroup.m b/sope-appserver/NGObjWeb/WODisplayGroup.m index 68efaf0a..04124f87 100644 --- a/sope-appserver/NGObjWeb/WODisplayGroup.m +++ b/sope-appserver/NGObjWeb/WODisplayGroup.m @@ -37,6 +37,16 @@ @end #endif + +@interface NSObject(EditingContext) +- (id)editingContext; +- (void)addEditor:(id)_editor; +- (void)removeEditor:(id)_editor; +- (void)setMessageHandler:(id)_handler; +- (id)messageHandler; +@end + + @implementation WODisplayGroup static NSNumber *uint0 = nil; @@ -64,19 +74,19 @@ static NSArray *uint0Array = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; [self setDataSource:nil]; - RELEASE(self->_queryMatch); - RELEASE(self->_queryMin); - RELEASE(self->_queryMax); - RELEASE(self->_queryOperator); - RELEASE(self->_queryBindings); - RELEASE(self->defaultStringMatchFormat); - RELEASE(self->defaultStringMatchOperator); - RELEASE(self->qualifier); - RELEASE(self->objects); - RELEASE(self->displayObjects); - RELEASE(self->selectionIndexes); - RELEASE(self->sortOrderings); - RELEASE(self->insertedObjectDefaults); + [self->_queryMatch release]; + [self->_queryMin release]; + [self->_queryMax release]; + [self->_queryOperator release]; + [self->_queryBindings release]; + [self->defaultStringMatchFormat release]; + [self->defaultStringMatchOperator release]; + [self->qualifier release]; + [self->objects release]; + [self->displayObjects release]; + [self->selectionIndexes release]; + [self->sortOrderings release]; + [self->insertedObjectDefaults release]; [super dealloc]; } @@ -87,9 +97,9 @@ static NSArray *uint0Array = nil; BOOL doRedisplay; doRedisplay = YES; - if ((d = [self delegate])) { + if ((d = [self delegate]) != nil) { if ([d respondsToSelector: - @selector(displayGroup:shouldRedisplayForChangesInEditingContext:)]) { + @selector(displayGroup:shouldRedisplayForChangesInEditingContext:)]) { doRedisplay = [d displayGroup:self shouldRedisplayForEditingContextChangeNotification: _notification]; @@ -116,27 +126,31 @@ static NSArray *uint0Array = nil; } - (void)setDataSource:(EODataSource *)_ds { - if (_ds != self->dataSource) { -#if WITH_EC - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; - - id ec; - - if ((ec = [self->dataSource editingContext])) { + NSNotificationCenter *nc = nil; + id ec; + + if (_ds == self->dataSource) + return; + + /* unregister with old editing context */ + if ([self->dataSource respondsToSelector:@selector(editingContext)]) { + if ((ec = [self->dataSource editingContext]) != nil) { [ec removeEditor:self]; if ([ec messageHandler] == self) [ec setMessageHandler:nil]; - [nc removeObserver:self - name:@"EOObjectsChangedInEditingContext" - object:ec]; + [[NSNotificationCenter defaultCenter] + removeObserver:self + name:@"EOObjectsChangedInEditingContext" + object:ec]; } -#endif - - ASSIGN(self->dataSource, _ds); - -#if WITH_EC - if ((ec = [_ds editingContext])) { + } + + ASSIGN(self->dataSource, _ds); + + /* register with new editing context */ + if ([self->dataSource respondsToSelector:@selector(editingContext)]) { + if ((ec = [self->dataSource editingContext]) != nil) { [ec addEditor:self]; if ([ec messageHandler] == nil) [ec setMessageHandler:self]; @@ -146,21 +160,18 @@ static NSArray *uint0Array = nil; name:@"EOObjectsChangedInEditingContext" object:ec]; } -#endif - - if ([self->delegate respondsToSelector: - @selector(displayGroupDidChangeDataSource:)]) - [self->delegate displayGroupDidChangeDataSource:self]; } + + if ([self->delegate respondsToSelector: + @selector(displayGroupDidChangeDataSource:)]) + [self->delegate displayGroupDidChangeDataSource:self]; } - (EODataSource *)dataSource { return self->dataSource; } - (void)setSortOrderings:(NSArray *)_orderings { - id tmp = self->sortOrderings; - self->sortOrderings = [_orderings copy]; - RELEASE(tmp); + ASSIGNCOPY(self->sortOrderings, _orderings); } - (NSArray *)sortOrderings { return self->sortOrderings; @@ -174,9 +185,7 @@ static NSArray *uint0Array = nil; } - (void)setInsertedObjectDefaultValues:(NSDictionary *)_values { - id tmp = self->insertedObjectDefaults; - self->insertedObjectDefaults = [_values copy]; - RELEASE(tmp); + ASSIGNCOPY(self->insertedObjectDefaults, [_values copy]); } - (NSDictionary *)insertedObjectDefaultValues { return self->insertedObjectDefaults; @@ -869,12 +878,10 @@ static NSArray *uint0Array = nil; [self dataSource]]; } -@end /* WODisplayGroup */ - -@implementation WODisplayGroup(KVCArchiving) +/* KVCArchiving */ - (id)initWithKeyValueUnarchiver:(EOKeyValueUnarchiver *)_unarchiver { - if ((self = [self init])) { + if ((self = [self init]) != nil) { id tmp; if ((tmp = [_unarchiver decodeObjectForKey:@"formatForLikeQualifier"])) @@ -907,11 +914,7 @@ static NSArray *uint0Array = nil; forKey:@"selectFirstAfterFetch"]; } -@end /* KVCArchiving */ - -@implementation WODisplayGroup(EOEditorsImpl) - -#if 0 +/* EOEditorsImpl */ - (void)editingContextWillSaveChanges:(id)_ec { } @@ -919,13 +922,7 @@ static NSArray *uint0Array = nil; return NO; } -#endif - -@end /* WODisplayGroup(EOEditorsImpl) */ - -@implementation WODisplayGroup(EOMessageHandlersImpl) - -#if 0 +/* EOMessageHandlersImpl */ - (void)editingContext:(id)_ec presentErrorMessage:(NSString *)_msg @@ -935,11 +932,9 @@ static NSArray *uint0Array = nil; - (BOOL)editingContext:(id)_ec shouldContinueFetchingWithCurrentObjectCount:(unsigned)_oc originalLimit:(unsigned)_olimit - objectStore:(EOObjectStore *)_store + objectStore:(id)_store { return NO; } -#endif - -@end /* WODisplayGroup(EOMessageHandlersImpl) */ +@end /* WODisplayGroup */ -- 2.39.5