API  0.9.10
CPPredicateEditorRowTemplate Class Reference

#import <CPPredicateEditorRowTemplate.h>

+ Inheritance diagram for CPPredicateEditorRowTemplate:

Instance Methods

Initializing a Template

CPPredicateEditorRowTemplate describes available predicates and how to display them.

You can create instances of CPPredicateEditorRowTemplate programmatically or in Interface Builder. By default, a non-compound row template has three views: a popup (or static text field) on the left, a popup or static text field for operators, and either a popup or other view on the right. You can subclass CPPredicateEditorRowTemplate to create a row template with different numbers or types of views.

CPPredicateEditorRowTemplate is a concrete class, but it has five primitive methods which are called by CPPredicateEditor: -templateViews (CPPredicateEditorRowTemplate), -matchForPredicate: (CPPredicateEditorRowTemplate), -setPredicate: (CPPredicateEditorRowTemplate), -displayableSubpredicatesOfPredicate: (CPPredicateEditorRowTemplate), and -predicateWithSubpredicates: (CPPredicateEditorRowTemplate). CPPredicateEditorRowTemplate implements all of them, but you can override them for custom templates. The primitive methods are used by an instance of CPPredicateEditor as follows.

First, an instance of CPPredicateEditor is created, and some row templates are set on it—either through a nib file or programmatically. The first thing predicate editor does is ask each of the templates for their views, using templateViews.

After setting up the predicate editor, you typically send it a setObjectValue: (CPControl) message to restore a saved predicate. CPPredicateEditor needs to determine which of its templates should display each predicate in the predicate tree. It does this by sending each of its row templates a matchForPredicate: message and choosing the one that returns the highest value.

After finding the best match for a predicate, CPPredicateEditor copies that template to get fresh views, inserts them into the proper row, and then sets the predicate on the template using setPredicate:. Within that method, the CPPredicateEditorRowTemplate object must set its views' values to represent that predicate.

CPPredicateEditorRowTemplate next asks the template for the “displayable sub-predicates” of the predicate by sending a -displayableSubpredicatesOfPredicate: (CPPredicateEditorRowTemplate) message. If a template represents a predicate in its entirety, or if the predicate has no subpredicates, it can return nil for this. Otherwise, it should return a list of predicates to be made into sub-rows of that template's row. The whole process repeats for each sub-predicate.

At this point, the user sees the predicate that was saved. If the user then makes some changes to the views of the templates, this causes CPPredicateEditor to recompute its predicate by asking each of the templates to return the predicate represented by the new view values, passing in the subpredicates represented by the sub-rows (an empty array if there are none, or nil if they aren't supported by that predicate type).

(id) - initWithLeftExpressions:rightExpressions:modifier:operators:options:
 Initializes and returns a “pop-up-pop-up-pop-up”-style row template. More...
 
(id) - initWithLeftExpressions:rightExpressionAttributeType:modifier:operators:options:
 Initializes and returns a “pop-up-pop-up-view”-style row template. More...
 
(id) - initWithCompoundTypes:
 Initializes and returns a row template suitable for displaying compound predicates. More...
 
Primitive Methods
(double) - matchForPredicate:
 Returns a positive number if the receiver can represent a given predicate, and 0 if it cannot. More...
 
(CPArray) - templateViews
 Returns the views for the receiver. More...
 
(void) - setPredicate:
 Sets the value of the views according to the given predicate. More...
 
(CPArray) - displayableSubpredicatesOfPredicate:
 Returns the subpredicates that should be made sub-rows of a given predicate. More...
 
(CPPredicate) - predicateWithSubpredicates:
 Returns the predicate represented by the receiver’s views' values and the given sub-predicates. More...
 
Information About a Row Template
(CPArray) - leftExpressions
 Returns the left hand expressions for the receiver. More...
 
(CPArray) - rightExpressions
 Returns the right hand expressions for the receiver. More...
 
(CPArray) - compoundTypes
 Returns the compound predicate types for the receiver. More...
 
(CPComparisonPredicateModifier) - modifier
 Returns the comparison predicate modifier for the receiver. More...
 
(CPArray) - operators
 Returns Returns the array of operators for the receiver. More...
 
(int) - options
 Returns the comparison predicate options for the receiver. More...
 
(CPAttributeType) - rightExpressionAttributeType
 Returns the attribute type of the receiver’s right expression. More...
 
(CPAttributeType) - leftExpressionAttributeType
 Returns the attribute type of the receiver’s left expression. More...
 
- Instance Methods inherited from CPObject
(void) - addObserver:forKeyPath:options:context:
 
(void) - applyChange:toKeyPath:
 
(id) - autorelease
 
(id) - awakeAfterUsingCoder:
 
(void) - awakeFromCib
 
(void) - bind:toObject:withKeyPath:options:
 
(Class) - classForCoder
 
(Class) - classForKeyedArchiver
 
(CPString- className
 
(id) - copy
 
(void) - dealloc
 
(CPString- description
 
(CPDictionary- dictionaryWithValuesForKeys:
 
(void) - didChange:valuesAtIndexes:forKey:
 
(void) - didChangeValueForKey:
 
(void) - didChangeValueForKey:withSetMutation:usingObjects:
 
(void) - doesNotRecognizeSelector:
 
(CPArray) - exposedBindings
 
(id) - forwardingTargetForSelector:
 
(void) - forwardInvocation:
 
(unsigned) - hash
 
(BOOL) - implementsSelector:
 
(CPDictionary- infoForBinding:
 
(id) - init
 
(BOOL) - isEqual:
 
(BOOL) - isKindOfClass:
 
(BOOL) - isMemberOfClass:
 
(BOOL) - isProxy
 
(IMP) - methodForSelector:
 
(CPMethodSignature) - methodSignatureForSelector:
 
(id) - mutableArrayValueForKey:
 
(id) - mutableArrayValueForKeyPath:
 
(id) - mutableCopy
 
(id) - mutableSetValueForKey:
 
(id) - mutableSetValueForKeyPath:
 
(id) - performSelector:
 
(id) - performSelector:withObject:
 
(void) - performSelector:withObject:afterDelay:
 
(void) - performSelector:withObject:afterDelay:inModes:
 
(id) - performSelector:withObject:withObject:
 
(id) - performSelector:withObjects:
 
(void) - release
 
(void) - removeObserver:forKeyPath:
 
(id) - replacementObjectForArchiver:
 
(id) - replacementObjectForCoder:
 
(id) - replacementObjectForKeyedArchiver:
 
(BOOL) - respondsToSelector:
 
(id) - retain
 
(id) - self
 
(void) - setValue:forKey:
 
(void) - setValue:forKeyPath:
 
(void) - setValue:forUndefinedKey:
 
(void) - setValuesForKeysWithDictionary:
 
(CPString- UID
 
(void) - unbind:
 
(Class) - valueClassForBinding:
 
(id) - valueForKey:
 
(id) - valueForKeyPath:
 
(id) - valueForUndefinedKey:
 
(void) - willChange:valuesAtIndexes:forKey:
 
(void) - willChangeValueForKey:
 
(void) - willChangeValueForKey:withSetMutation:usingObjects:
 

Additional Inherited Members

- Class Methods inherited from CPObject
(BOOL) + accessInstanceVariablesDirectly
 
(id) + alloc
 
(id) + allocWithCoder:
 
(BOOL) + automaticallyNotifiesObserversForKey:
 
(void) + cancelPreviousPerformRequestsWithTarget:
 
(void) + cancelPreviousPerformRequestsWithTarget:selector:object:
 
(Class) + class
 
(BOOL) + conformsToProtocol:
 
(void) + exposeBinding:
 
(void) + initialize
 
(IMP) + instanceMethodForSelector:
 
(BOOL) + instancesImplementSelector:
 
(BOOL) + instancesRespondToSelector:
 
(BOOL) + isBindingExclusive:
 
(BOOL) + isSubclassOfClass:
 
(CPSet) + keyPathsForValuesAffectingValueForKey:
 
(void) + load
 
(id) + new
 
(void) + object:performSelector:withObject:afterDelay:inModes:
 
(void) + setVersion:
 
(Class) + superclass
 
(int) + version
 

Detailed Description

Definition at line 2 of file CPPredicateEditorRowTemplate.h.

Method Documentation

◆ compoundTypes()

- (CPArray) compoundTypes
implementation

Returns the compound predicate types for the receiver.

Returns
An array of CPNumber objects specifying compound predicate types. See CompoundPredicateTypes for possible values.

Definition at line 315 of file CPPredicateEditorRowTemplate.j.

◆ displayableSubpredicatesOfPredicate:()

- (CPArray) displayableSubpredicatesOfPredicate: (CPPredicate)  predicate
implementation

Returns the subpredicates that should be made sub-rows of a given predicate.

Parameters
predicateA predicate object.
Returns
The subpredicates that should be made sub-rows of predicate. For compound predicates (instances of CPCompoundPredicate), the array of subpredicates; for other types of predicate, returns nil. If a template represents a predicate in its entirety, or if the predicate has no subpredicates, returns nil. You can override this method to create custom templates that handle complicated compound predicates.

Definition at line 231 of file CPPredicateEditorRowTemplate.j.

◆ initWithCompoundTypes:()

- (id) initWithCompoundTypes: (CPArray)  compoundTypes
implementation

Initializes and returns a row template suitable for displaying compound predicates.

Parameters
compoundTypesAn array of CPNumber objects specifying compound predicate types. See CPCompoundPredicateTypes for possible values.
Returns
A row template initialized for displaying compound predicates of the types specified by compoundTypes. CPPredicateEditor contains such a template by default.

Definition at line 146 of file CPPredicateEditorRowTemplate.j.

◆ initWithLeftExpressions:rightExpressionAttributeType:modifier:operators:options:()

- (id) initWithLeftExpressions: (CPArray)  leftExpressions
rightExpressionAttributeType: (CPAttributeType)  attributeType
modifier: (CPComparisonPredicateModifier)  modifier
operators: (CPArray)  operators
options: (int)  options 
implementation

Initializes and returns a “pop-up-pop-up-view”-style row template.

Parameters
leftExpressionsAn array of CPExpression objects that represent the left hand side of a predicate.
attributeTypeAn attribute type for the right hand side of a predicate. This value dictates the type of view created, and how the control’s object value is coerced before putting it into a predicate.
modifierA modifier for the predicate (see CPComparisonPredicateModifier for possible values).
operatorsAn array of CPNumber objects specifying the operator type (see CPPredicateOperatorType for possible values).
optionsOptions for the predicate (see CPComparisonPredicateOptions for possible values).
Returns
A row template initialized using the given arguments.

Definition at line 118 of file CPPredicateEditorRowTemplate.j.

◆ initWithLeftExpressions:rightExpressions:modifier:operators:options:()

- (id) initWithLeftExpressions: (CPArray)  leftExpressions
rightExpressions: (CPArray)  rightExpressions
modifier: (int)  modifier
operators: (CPArray)  operators
options: (int)  options 
implementation

Initializes and returns a “pop-up-pop-up-pop-up”-style row template.

Parameters
leftExpressionsAn array of CPExpression objects that represent the left hand side of a predicate.
rightExpressionsAn array of CPExpression objects that represent the right hand side of a predicate.
modifierA modifier for the predicate (see CPComparisonPredicateModifier for possible values).
operatorsAn array of CPNumber objects specifying the operator type (see CPPredicateOperatorType for possible values).
optionsOptions for the predicate (see CPComparisonPredicateOptions for possible values).
Returns
A row template of the “pop-up-pop-up-pop-up”-form, with the left and right popups representing the left and right expression arrays -leftExpressions and -rightExpressions, and the center popup representing the operators.

Definition at line 86 of file CPPredicateEditorRowTemplate.j.

◆ leftExpressionAttributeType()

- (CPAttributeType) leftExpressionAttributeType
implementation

Returns the attribute type of the receiver’s left expression.

Returns
The attribute type of the receiver’s left expression.

Definition at line 378 of file CPPredicateEditorRowTemplate.j.

◆ leftExpressions()

- (CPArray) leftExpressions
implementation

Returns the left hand expressions for the receiver.

Returns
The left hand expressions for the receiver.

Definition at line 285 of file CPPredicateEditorRowTemplate.j.

◆ matchForPredicate:()

- (double) matchForPredicate: (CPPredicate)  predicate
implementation

Returns a positive number if the receiver can represent a given predicate, and 0 if it cannot.

Returns
A positive number if the template can represent predicate, and 0 if it cannot. By default, returns values in the range 0 to 1. The highest match among all the templates determines which template is responsible for displaying the predicate. You can override this to determine which predicates your custom template handles.

Definition at line 175 of file CPPredicateEditorRowTemplate.j.

◆ modifier()

- (CPComparisonPredicateModifier) modifier
implementation

Returns the comparison predicate modifier for the receiver.

Returns
The comparison predicate modifier for the receiver.

Definition at line 330 of file CPPredicateEditorRowTemplate.j.

◆ operators()

- (CPArray) operators
implementation

Returns Returns the array of operators for the receiver.

Returns
The array of operators for the receiver.

Definition at line 342 of file CPPredicateEditorRowTemplate.j.

◆ options()

- (int) options
implementation

Returns the comparison predicate options for the receiver.

Returns
The comparison predicate options for the receiver. See CPComparisonPredicateOptions for possible values. Returns 0 if this does not apply (for example, for a compound template initialized with -initWithCompoundTypes:).

Definition at line 357 of file CPPredicateEditorRowTemplate.j.

◆ predicateWithSubpredicates:()

- (CPPredicate) predicateWithSubpredicates: (CPArray)  subpredicates
implementation

Returns the predicate represented by the receiver’s views' values and the given sub-predicates.

Parameters
subpredicatesAn array of predicates.
Returns
The predicate represented by the values of the template's views and the given subpredicates. You can override this method to return the predicate represented by your custom views. This method is only called if -matchForPredicate: returned a positive value for the receiver.

You can override this method to return the predicate represented by a custom view.

Definition at line 253 of file CPPredicateEditorRowTemplate.j.

◆ rightExpressionAttributeType()

- (CPAttributeType) rightExpressionAttributeType
implementation

Returns the attribute type of the receiver’s right expression.

Returns
The attribute type of the receiver’s right expression.

Definition at line 369 of file CPPredicateEditorRowTemplate.j.

◆ rightExpressions()

- (CPArray) rightExpressions
implementation

Returns the right hand expressions for the receiver.

Returns
The right hand expressions for the receiver.

Definition at line 300 of file CPPredicateEditorRowTemplate.j.

◆ setPredicate:()

- (void) setPredicate: (CPPredicate)  predicate
implementation

Sets the value of the views according to the given predicate.

Parameters
predicateThe predicate value for the receiver. This method is only called if -matchForPredicate: returned a positive value for the receiver.

You can override this to set the values of custom views.

Definition at line 217 of file CPPredicateEditorRowTemplate.j.

◆ templateViews()

- (CPArray) templateViews
implementation

Returns the views for the receiver.

Returns
The views for the receiver. Instances of CPPopUpButton are treated specially by CPPredicateEditor; their menu items are merged into a single popup button, and matching menu item titles are combined. In this way, a single tree is built from the separate templates.

Definition at line 205 of file CPPredicateEditorRowTemplate.j.


The documentation for this class was generated from the following files: