Author: torehalset
Date: Fri Nov  3 15:39:27 2006
New Revision: 471058

URL: http://svn.apache.org/viewvc?view=rev&rev=471058
Log:
implemented CAYTreeController. almost a copy of CAYArrayController.

Added:
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYTreeController.h
    incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYTreeController.m
Modified:
    
incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CocoaCayenne.xcodeproj/project.pbxproj

Added: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYTreeController.h
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYTreeController.h?view=auto&rev=471058
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYTreeController.h 
(added)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYTreeController.h Fri 
Nov  3 15:39:27 2006
@@ -0,0 +1,37 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+#import "CAYObjectContext.h"
+
[EMAIL PROTECTED] CAYTreeController : NSTreeController {
+
+    CAYObjectContext *objectContext;
+    BOOL deleteObjectOnRemove;
+
+}
+
+-(void)setObjectContext:(CAYObjectContext *)ctxt;
+-(CAYObjectContext *)objectContext;
+
+-(void)setDeleteObjectOnRemove:(BOOL)d;
+-(BOOL)deleteObjectOnRemove;
+
[EMAIL PROTECTED]

Added: incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYTreeController.m
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYTreeController.m?view=auto&rev=471058
==============================================================================
--- incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYTreeController.m 
(added)
+++ incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CAYTreeController.m Fri 
Nov  3 15:39:27 2006
@@ -0,0 +1,100 @@
+/*****************************************************************
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ ****************************************************************/
+
+#import "CAYTreeController.h"
+
+
[EMAIL PROTECTED] CAYTreeController
+
+- (id)newObject
+{
+    /*
+    * Tip: If you are having trouble here, make sure that the views 
selectionIndexPaths are
+    * bound to the controllers selectionIndexPaths
+    */
+    
+    id r = [super newObject];
+    
+    if([self objectContext] && [r isKindOfClass:[CAYPersistentObject class]])
+    {
+        CAYPersistentObject *po = (CAYPersistentObject *)r;
+        if(![po objectContext])
+        {
+            [[self objectContext] registerNewObject:po];
+        }
+    }
+    
+    return r;
+}
+
+- (void)remove:(id)sender
+{
+    // TODO: look for deleteObjectOnRemove from binding? Problem is that it 
only are used
+    // in a core data environment
+    
+    // remember objects to delete for later
+    NSMutableArray *objectsToDelete = [NSMutableArray array];
+    if([self deleteObjectOnRemove])
+    {
+        [objectsToDelete addObjectsFromArray:[self selectedObjects]];
+    }
+    
+    // do the relationship handling
+    [super remove:sender];
+    
+    // delete objects if any
+    if([self deleteObjectOnRemove])
+    {
+        NSEnumerator *enumerator = [objectsToDelete objectEnumerator];
+        CAYPersistentObject *element = nil;
+        while(element = [enumerator nextObject])
+        {
+            [[element objectContext] deleteObject:element];
+        }
+    }
+}
+
+-(void)setObjectContext:(CAYObjectContext *)ctxt
+{
+    // do not need to retain our master
+       objectContext = ctxt;
+}
+
+-(CAYObjectContext *)objectContext
+{
+       return objectContext;
+}
+
+-(void)setDeleteObjectOnRemove:(BOOL)d
+{
+    deleteObjectOnRemove = d;
+}
+
+-(BOOL)deleteObjectOnRemove
+{
+    return deleteObjectOnRemove;
+}
+
+-(void)dealloc
+{
+    [self setObjectContext:nil];
+       [super dealloc];
+}
+
[EMAIL PROTECTED]

Modified: 
incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CocoaCayenne.xcodeproj/project.pbxproj
URL: 
http://svn.apache.org/viewvc/incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CocoaCayenne.xcodeproj/project.pbxproj?view=diff&rev=471058&r1=471057&r2=471058
==============================================================================
--- 
incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CocoaCayenne.xcodeproj/project.pbxproj
 (original)
+++ 
incubator/cayenne/sandbox/CocoaCayenne/CocoaCayenne/CocoaCayenne.xcodeproj/project.pbxproj
 Fri Nov  3 15:39:27 2006
@@ -79,7 +79,9 @@
                444F27A90AC9EDFF0097052B /* CAYCayenneRuntimeException.m in 
Sources */ = {isa = PBXBuildFile; fileRef = 444F27A70AC9EDFF0097052B /* 
CAYCayenneRuntimeException.m */; };
                444F27F50AC9F4B80097052B /* CAYMissingSessionException.h in 
Headers */ = {isa = PBXBuildFile; fileRef = 444F27F30AC9F4B80097052B /* 
CAYMissingSessionException.h */; settings = {ATTRIBUTES = (Public, ); }; };
                444F27F60AC9F4B80097052B /* CAYMissingSessionException.m in 
Sources */ = {isa = PBXBuildFile; fileRef = 444F27F40AC9F4B80097052B /* 
CAYMissingSessionException.m */; };
-               4485B3B70AF69DE500920481 /* CAYObjectIdQuery.h in Headers */ = 
{isa = PBXBuildFile; fileRef = 4485B3B50AF69DE500920481 /* CAYObjectIdQuery.h 
*/; };
+               445C275A0AFC024300D7D2AA /* CAYTreeController.h in Headers */ = 
{isa = PBXBuildFile; fileRef = 445C27580AFC024300D7D2AA /* CAYTreeController.h 
*/; settings = {ATTRIBUTES = (Public, ); }; };
+               445C275B0AFC024300D7D2AA /* CAYTreeController.m in Sources */ = 
{isa = PBXBuildFile; fileRef = 445C27590AFC024300D7D2AA /* CAYTreeController.m 
*/; };
+               4485B3B70AF69DE500920481 /* CAYObjectIdQuery.h in Headers */ = 
{isa = PBXBuildFile; fileRef = 4485B3B50AF69DE500920481 /* CAYObjectIdQuery.h 
*/; settings = {ATTRIBUTES = (Public, ); }; };
                4485B3B80AF69DE500920481 /* CAYObjectIdQuery.m in Sources */ = 
{isa = PBXBuildFile; fileRef = 4485B3B60AF69DE500920481 /* CAYObjectIdQuery.m 
*/; };
                448E1BA90AC0882F00D137DF /* CAYArrayController.h in Headers */ 
= {isa = PBXBuildFile; fileRef = 448E1BA70AC0882F00D137DF /* 
CAYArrayController.h */; settings = {ATTRIBUTES = (Public, ); }; };
                448E1BAA0AC0882F00D137DF /* CAYArrayController.m in Sources */ 
= {isa = PBXBuildFile; fileRef = 448E1BA80AC0882F00D137DF /* 
CAYArrayController.m */; };
@@ -168,6 +170,8 @@
                444F27A70AC9EDFF0097052B /* CAYCayenneRuntimeException.m */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.objc; path = CAYCayenneRuntimeException.m; sourceTree = "<group>"; 
};
                444F27F30AC9F4B80097052B /* CAYMissingSessionException.h */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; 
path = CAYMissingSessionException.h; sourceTree = "<group>"; };
                444F27F40AC9F4B80097052B /* CAYMissingSessionException.m */ = 
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = 
sourcecode.c.objc; path = CAYMissingSessionException.m; sourceTree = "<group>"; 
};
+               445C27580AFC024300D7D2AA /* CAYTreeController.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
CAYTreeController.h; sourceTree = "<group>"; };
+               445C27590AFC024300D7D2AA /* CAYTreeController.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= CAYTreeController.m; sourceTree = "<group>"; };
                4485B3B50AF69DE500920481 /* CAYObjectIdQuery.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
CAYObjectIdQuery.h; sourceTree = "<group>"; };
                4485B3B60AF69DE500920481 /* CAYObjectIdQuery.m */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path 
= CAYObjectIdQuery.m; sourceTree = "<group>"; };
                448E1BA70AC0882F00D137DF /* CAYArrayController.h */ = {isa = 
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = 
CAYArrayController.h; sourceTree = "<group>"; };
@@ -242,6 +246,7 @@
                                44463DCE0AA375F8006BAA58 /* query */,
                                4407C06F0ABACE700065409F /* model */,
                                444F26300AC974360097052B /* validation */,
+                               445C27570AFC021400D7D2AA /* controller */,
                                44463D7B0AA37577006BAA58 /* 
CAYGenericResponse.h */,
                                44463D7C0AA37577006BAA58 /* 
CAYGenericResponse.m */,
                                44463D850AA37577006BAA58 /* CAYObjectContext.h 
*/,
@@ -254,8 +259,6 @@
                                44463D940AA37577006BAA58 /* CAYRemoteSession.m 
*/,
                                444DA8030AA61E54006E1768 /* CAYCocoaCayenne.h 
*/,
                                444DA8040AA61E54006E1768 /* CAYCocoaCayenne.m 
*/,
-                               448E1BA70AC0882F00D137DF /* 
CAYArrayController.h */,
-                               448E1BA80AC0882F00D137DF /* 
CAYArrayController.m */,
                                444F27A60AC9EDFF0097052B /* 
CAYCayenneRuntimeException.h */,
                                444F27A70AC9EDFF0097052B /* 
CAYCayenneRuntimeException.m */,
                        );
@@ -399,6 +402,17 @@
                        name = validation;
                        sourceTree = "<group>";
                };
+               445C27570AFC021400D7D2AA /* controller */ = {
+                       isa = PBXGroup;
+                       children = (
+                               448E1BA70AC0882F00D137DF /* 
CAYArrayController.h */,
+                               448E1BA80AC0882F00D137DF /* 
CAYArrayController.m */,
+                               445C27580AFC024300D7D2AA /* CAYTreeController.h 
*/,
+                               445C27590AFC024300D7D2AA /* CAYTreeController.m 
*/,
+                       );
+                       name = controller;
+                       sourceTree = "<group>";
+               };
 /* End PBXGroup section */
 
 /* Begin PBXHeadersBuildPhase section */
@@ -445,6 +459,7 @@
                                444F27A80AC9EDFF0097052B /* 
CAYCayenneRuntimeException.h in Headers */,
                                444F27F50AC9F4B80097052B /* 
CAYMissingSessionException.h in Headers */,
                                4485B3B70AF69DE500920481 /* CAYObjectIdQuery.h 
in Headers */,
+                               445C275A0AFC024300D7D2AA /* CAYTreeController.h 
in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
@@ -541,6 +556,7 @@
                                444F27A90AC9EDFF0097052B /* 
CAYCayenneRuntimeException.m in Sources */,
                                444F27F60AC9F4B80097052B /* 
CAYMissingSessionException.m in Sources */,
                                4485B3B80AF69DE500920481 /* CAYObjectIdQuery.m 
in Sources */,
+                               445C275B0AFC024300D7D2AA /* CAYTreeController.m 
in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };


Reply via email to