]> err.no Git - scalable-opengroupware.org/blobdiff - SOPE/NGCards/CardGroup.m
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1031 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / SOPE / NGCards / CardGroup.m
index b7b60ca7118c4cdca638de4b8ff2bfe606617943..be1c71e01da6e6641a879c1554d58acb1d883ae5 100644 (file)
@@ -112,13 +112,7 @@ static NGCardsSaxHandler *sax = nil;
 
 + (id) groupWithTag: (NSString *) aTag
 {
-  id newGroup;
-
-  newGroup = [self new];
-  [newGroup autorelease];
-  [newGroup setTag: aTag];
-
-  return newGroup;
+  return [self elementWithTag: aTag];
 }
 
 + (id) groupWithTag: (NSString *) aTag
@@ -126,9 +120,7 @@ static NGCardsSaxHandler *sax = nil;
 {
   id newGroup;
 
-  newGroup = [self new];
-  [newGroup autorelease];
-  [newGroup setTag: aTag];
+  newGroup = [self elementWithTag: aTag];
   [newGroup addChildren: someChildren];
 
   return newGroup;
@@ -232,6 +224,33 @@ static NGCardsSaxHandler *sax = nil;
   [self addChild: aChild];
 }
 
+- (CardElement *) firstChildWithTag: (NSString *) aTag;
+{
+  Class mappedClass;
+  CardElement *child, *mappedChild;
+  NSArray *existing;
+
+  existing = [self childrenWithTag: aTag];
+  if ([existing count])
+    {
+      child = [existing objectAtIndex: 0];
+      mappedClass = [self classForTag: [aTag uppercaseString]];
+      if (mappedClass)
+        {
+          if ([child isKindOfClass: [CardGroup class]])
+            mappedChild = [(CardGroup *) child groupWithClass: mappedClass];
+          else
+            mappedChild = [child elementWithClass: mappedClass];
+        }
+      else
+        mappedChild = child;
+    }
+  else
+    mappedChild = nil;
+
+  return mappedChild;
+}
+
 - (void) addChildren: (NSArray *) someChildren
 {
   CardElement *currentChild;