//
//  PWTreeController.h
//  PWTreeControllerDemo
//
//  Created by Frank Illenberger on 04.03.06.
//  Copyright 2006 ProjectWizards, Melle, Germany. 
//

#import <Cocoa/Cocoa.h>

@class PWTreeControllerNode;
@class PWOutlineView;

@interface RubyPredicate :NSObject
- (NSNumber *) testObject: (id) obj;
@end

@interface PWTreeController : NSObject
{
	NSArray 				*sortDescriptors;
	NSArray 				*observedObjectsSortDescriptors;
	NSSet 					*sortDescriptorKeys;
	NSArray					*rootObjectsArray;
	NSSet					*rootObjectsSet;
	
	NSMutableArray			*rootNodes;
	NSArray					*filteredRootNodes;
	
	PWOutlineView			*outlineView;
	id						rootSource;
					
	BOOL					isAutosorting;
	BOOL					pendingAutosort;
	
	@public
	NSPredicate			*filterPredicate;
	NSMutableSet		 	*filteredObjectsAndAncestors;
	NSMutableSet			*filteredObjects;
	NSString 				*isLeafKeyPath;
	NSString 				*childrenKeyPath;
	NSString				*rootKeyPath;
	CFMutableDictionaryRef 	nodesForObjects;
	NSMutableArray		 	*attributeObservers;
	BOOL					isSetup;
}

- (void)setSortDescriptors:(NSArray *)descriptors;
- (NSArray *)sortDescriptors;

- (void)setChildrenKeyPath:(NSString *)keyPath;
- (NSString *)childrenKeyPath;

- (void)setRootKeyPath:(NSString *)keyPath;
- (NSString *)rootKeyPath;

- (void)setIsLeafKeyPath:(NSString *)keyPath;
- (NSString *)isLeafKeyPath;

- (void)setRootObjectsArray:(NSArray *)array;
- (NSArray *)rootObjectsArray;

- (void)setRootObjectsSet:(NSSet *)set;
- (NSSet *)rootObjectsSet;

- (void)setOutlineView:(PWOutlineView *)ov;
- (PWOutlineView *)outlineView;

- (void)setIsAutosorting:(BOOL)autosort;
- (BOOL)isAutosorting;

- (NSArray *)selectedObjects;
- (void)setSelectedObjects:(NSArray *)objects;

- (PWTreeControllerNode *)nodeForObservedObject:(id)object;

- (void)setFilterPredicate:(NSPredicate *)pred;
- (NSPredicate *)filterPredicate;

- (void)rearrangeObjects;
- (NSArray *)arrangedRootNodes;
- (NSArray *)rootNodes;
- (NSSet *)filteredObjects;
- (NSSet *)filteredObjectsAndAncestors;

@end
