![]() |
API 0.9.5
|
A view for creating and configuring criteria. More...
#import <CPRuleEditor.h>
Instance Methods | |
Configuring a Rule Editor | |
(id) | - delegate |
Returns the receiver’s delegate. | |
(void) | - setDelegate: |
Sets the receiver’s delegate. | |
(BOOL) | - isEditable |
Returns a Boolean value that indicates whether the receiver is editable. | |
(void) | - setEditable: |
Sets whether the receiver is editable. | |
(CPRuleEditorNestingMode) | - nestingMode |
Returns the nesting mode for the receiver. | |
(void) | - setNestingMode: |
Sets the nesting mode for the receiver. | |
(BOOL) | - canRemoveAllRows |
Returns a Boolean value that indicates whether all the rows can be removed. | |
(void) | - setCanRemoveAllRows: |
Sets whether all the rows can be removed. | |
(BOOL) | - allowsEmptyCompoundRows |
Returns a Boolean value that indicates whether compounds rows can be childless. | |
(void) | - setAllowsEmptyCompoundRows: |
Sets whether compounds rows can be childless. | |
(CPInteger) | - rowHeight |
Returns the row height for the receiver. | |
(void) | - setRowHeight: |
Sets the row height for the receiver. | |
Working with Formatting | |
(CPDictionary) | - formattingDictionary |
Returns the formatting dictionary for the receiver. | |
(void) | - setFormattingDictionary: |
Sets the formatting dictionary for the receiver. | |
(CPString) | - formattingStringsFilename |
Returns the name of the strings file for the receiver. | |
(void) | - setFormattingStringsFilename: |
Sets the name of the strings file used for formatting. | |
Providing Data | |
(void) | - reloadCriteria |
Instructs the receiver to refetch criteria from its delegate. You can use this method to indicate that the available criteria may have changed and should be refetched from the delegate and the popups recalculated. | |
(void) | - setCriteria:andDisplayValues:forRowAtIndex: |
Modifies the row at a given index to contain the given items and values. | |
(id) | - criteriaForRow: |
Returns the currently chosen items for a given row. | |
Working with the Selection | |
(CPMutableArray) | - displayValuesForRow: |
Returns the chosen values for a given row. | |
(int) | - numberOfRows |
Returns the number of rows in the receiver. | |
(int) | - parentRowForRow: |
Returns the index of the parent of a given row. | |
(CPRuleEditorRowType) | - rowTypeForRow: |
Returns the type of a given row. | |
(CPIndexSet) | - subrowIndexesForRow: |
Returns the immediate subrows of a given row. | |
(CPIndexSet) | - selectedRowIndexes |
Returns the indexes of the receiver’s selected rows. | |
(void) | - selectRowIndexes:byExtendingSelection: |
Sets in the receiver the indexes of rows that are selected. | |
Manipulating Rows | |
(void) | - addRow: |
Adds a row to the receiver. | |
(void) | - insertRowAtIndex:withType:asSubrowOfRow:animate: |
Adds a new row of a given type at a given location. | |
(void) | - removeRowAtIndex: |
Removes the row at a given index. | |
(void) | - removeRowsAtIndexes:includeSubrows: |
Removes the rows at a given index. | |
Working with Predicates | |
(CPPredicate) | - predicate |
Returns the predicate for the receiver. | |
(void) | - reloadPredicate |
Instructs the receiver to regenerate its predicate by invoking the corresponding delegate method. You typically invoke this method because something has changed (for example, a view's value). | |
(CPPredicate) | - predicateForRow: |
Returns the predicate for a given row. | |
Supporting Bindings | |
(Class) | - rowClass |
Returns the class used to create a new row in the “rows” binding. | |
(void) | - setRowClass: |
Sets the class to use to create a new row in the "rows” binding. | |
(CPString) | - rowTypeKeyPath |
Returns the key path for the row type. | |
(void) | - setRowTypeKeyPath: |
Sets the key path for the row type. | |
(CPString) | - subrowsKeyPath |
Returns the key path for the subrows. | |
(void) | - setSubrowsKeyPath: |
Sets the key path for the subrows. | |
(CPString) | - criteriaKeyPath |
Returns the criteria key path. | |
(void) | - setCriteriaKeyPath: |
Sets the key path for the criteria. | |
(CPString) | - displayValuesKeyPath |
Returns the display values key path. | |
(void) | - setDisplayValuesKeyPath: |
Sets the key path for the display values. | |
Configuring Rows Animation | |
(id) | - animation |
Returns the current animation for the receiver. | |
(void) | - setAnimation: |
Sets the current animation for the receiver. |
A view for creating and configuring criteria.
A CPRuleEditor object is a view that allows the user to visually create and configure a list of options which are expressed by the rule editor as a predicate (see Predicate documentation). The view has a delegate which offers a tree of choices to the view. The choices are presented by the view to the user as a row of popup buttons, static text fields, and custom views. Each row in the list represents a particular path down the tree of choices.
CPRuleEditor exposes one binding, rows. You can bind rows to an ordered collection (such as an instance of CPMutableArray). Each object in the collection should have the following properties:
@"rowType"
An integer representing the type of the row (CPRuleEditorRowType).
@"subrows"
An ordered to-many relation (such as an instance of CPMutableArray) containing the directly nested subrows for the given row.
@"displayValues"
An ordered to-many relation containing the display values for the row.
@"criteria"
An ordered to-many relation containing the criteria for the row.
Definition at line 2 of file CPRuleEditor.h.
- (void) addRow: | (id) | sender |
Adds a row to the receiver.
sender | Typically the object that sent the message. |
Definition at line 639 of file CPRuleEditor.j.
- (BOOL) allowsEmptyCompoundRows |
Returns a Boolean value that indicates whether compounds rows can be childless.
YES
if compounds rows can be childless, otherwise NO
. Definition at line 302 of file CPRuleEditor.j.
- (id) animation |
Returns the current animation for the receiver.
Definition at line 1019 of file CPRuleEditor.j.
- (BOOL) canRemoveAllRows |
Returns a Boolean value that indicates whether all the rows can be removed.
YES
if all the rows can be removed, otherwise NO
. Definition at line 281 of file CPRuleEditor.j.
- (id) criteriaForRow: | (int) | row |
Returns the currently chosen items for a given row.
row | The index of a row in the receiver. |
Definition at line 453 of file CPRuleEditor.j.
- (CPString) criteriaKeyPath |
Returns the criteria key path.
Definition at line 971 of file CPRuleEditor.j.
- (id) delegate |
Returns the receiver’s delegate.
Definition at line 195 of file CPRuleEditor.j.
- (CPMutableArray) displayValuesForRow: | (int) | row |
Returns the chosen values for a given row.
row | The index of a row in the receiver. |
Definition at line 472 of file CPRuleEditor.j.
- (CPString) displayValuesKeyPath |
Returns the display values key path.
Definition at line 994 of file CPRuleEditor.j.
- (CPDictionary) formattingDictionary |
Returns the formatting dictionary for the receiver.
Definition at line 352 of file CPRuleEditor.j.
- (CPString) formattingStringsFilename |
Returns the name of the strings file for the receiver.
Definition at line 375 of file CPRuleEditor.j.
- (void) insertRowAtIndex: | (int) | rowIndex | |
withType: | (unsigned int) | rowType | |
asSubrowOfRow: | (int) | parentRow | |
animate: | (BOOL) | shouldAnimate | |
Adds a new row of a given type at a given location.
rowIndex | The index at which the new row should be inserted. rowIndex must be greater than parentRow, and much specify a row that does not fall amongst the children of some other parent. |
rowType | The type of the new row. |
parentRow | The index of the row of which the new row is a child. Pass -1 to indicate that the new row should be a root row. |
shouldAnimate | YES if creation of the new row should be animated, otherwise NO . |
Definition at line 682 of file CPRuleEditor.j.
- (BOOL) isEditable |
Returns a Boolean value that indicates whether the receiver is editable.
YES
if the receiver is editable, otherwise NO
. The default is YES
. Definition at line 226 of file CPRuleEditor.j.
- (CPRuleEditorNestingMode) nestingMode |
Returns the nesting mode for the receiver.
Definition at line 254 of file CPRuleEditor.j.
- (int) numberOfRows |
Returns the number of rows in the receiver.
Definition at line 485 of file CPRuleEditor.j.
- (int) parentRowForRow: | (int) | rowIndex |
Returns the index of the parent of a given row.
rowIndex | The index of a row in the receiver. |
-1
. Definition at line 495 of file CPRuleEditor.j.
- (CPPredicate) predicate |
Returns the predicate for the receiver.
nil
. Definition at line 768 of file CPRuleEditor.j.
- (CPPredicate) predicateForRow: | (CPInteger) | aRow |
Returns the predicate for a given row.
aRow | The index of a row in the receiver. |
Definition at line 788 of file CPRuleEditor.j.
- (void) reloadCriteria |
Instructs the receiver to refetch criteria from its delegate. You can use this method to indicate that the available criteria may have changed and should be refetched from the delegate and the popups recalculated.
Definition at line 416 of file CPRuleEditor.j.
- (void) reloadPredicate |
Instructs the receiver to regenerate its predicate by invoking the corresponding delegate method. You typically invoke this method because something has changed (for example, a view's value).
Definition at line 777 of file CPRuleEditor.j.
- (void) removeRowAtIndex: | (int) | rowIndex |
Removes the row at a given index.
rowIndex | The index of a row in the receiver. |
CPRangeException
if rowIndex is less than 0
or greater than or equal to the number of rows. Definition at line 701 of file CPRuleEditor.j.
- (void) removeRowsAtIndexes: | (CPIndexSet) | rowIndexes | |
includeSubrows: | (BOOL) | includeSubrows | |
Removes the rows at a given index.
rowIndexes | Indexes of one or more rows in the receiver. |
includeSubrows | If YES , then sub-rows of deleted rows are also deleted; if NO , then each sub-row is adopted by its first non-deleted ancestor, or becomes a root row. |
CPRangeException
if any index in rowIndexes is less than 0 or greater than or equal to the number of rows. Definition at line 718 of file CPRuleEditor.j.
- (Class) rowClass |
Returns the class used to create a new row in the “rows” binding.
Definition at line 900 of file CPRuleEditor.j.
- (CPInteger) rowHeight |
Returns the row height for the receiver.
Definition at line 323 of file CPRuleEditor.j.
- (CPRuleEditorRowType) rowTypeForRow: | (int) | rowIndex |
Returns the type of a given row.
rowIndex | The index of a row in the receiver. |
CPRangeException
if rowIndex is less than 0
or greater than or equal to the number of rows. Definition at line 536 of file CPRuleEditor.j.
- (CPString) rowTypeKeyPath |
Returns the key path for the row type.
"rowType"
. The key path is used to get the row type in the “rows” binding. The corresponding property should be a number that specifies an CPRuleEditorRowType
value. Definition at line 925 of file CPRuleEditor.j.
- (CPIndexSet) selectedRowIndexes |
Returns the indexes of the receiver’s selected rows.
Definition at line 595 of file CPRuleEditor.j.
- (void) selectRowIndexes: | (CPIndexSet) | indexes | |
byExtendingSelection: | (BOOL) | extend | |
Sets in the receiver the indexes of rows that are selected.
indexes | The indexes of rows in the receiver to select. |
extend | If NO , the selected rows are specified by indexes. If YES , the rows indicated by indexes are added to the collection of already selected rows, providing multiple selection. |
Definition at line 605 of file CPRuleEditor.j.
- (void) setAllowsEmptyCompoundRows: | (BOOL) | allows |
Sets whether compounds rows can be childless.
allows | YES if compounds rows can be childless, otherwise NO . |
Definition at line 312 of file CPRuleEditor.j.
- (void) setAnimation: | (CPViewAnimation) | animation |
Sets the current animation for the receiver.
animation | A CPViewAnimation object used to animate rows. The default is a CPViewAnimation with a 0.5s duration and a CPAnimationEaseInOut curve. |
Definition at line 1030 of file CPRuleEditor.j.
- (void) setCanRemoveAllRows: | (BOOL) | canRemove |
Sets whether all the rows can be removed.
canRemove | YES if all the rows can be removed, otherwise NO . |
Definition at line 291 of file CPRuleEditor.j.
- (void) setCriteria: | (CPArray) | criteria | |
andDisplayValues: | (CPArray) | values | |
forRowAtIndex: | (int) | rowIndex | |
Modifies the row at a given index to contain the given items and values.
criteria | The array of criteria for the row at rowIndex. Pass an empty array to force the receiver to query its delegate. This value must not be nil. |
values | The array of values for the row at rowIndex. Pass an empty array to force the receiver to query its delegate. This value must not be nil . |
rowIndex | The index of a row in the receiver. |
It is your responsibility to ensure that each item in the array is a child of the previous item, and that the first item is a root item for the row type. If the last item has child items, then the items array will be extended by querying the delegate for child items until a childless item is reached.
Definition at line 431 of file CPRuleEditor.j.
- (void) setCriteriaKeyPath: | (CPString) | keyPath |
Sets the key path for the criteria.
keyPath | The key path for the criteria. |
Definition at line 981 of file CPRuleEditor.j.
- (void) setDelegate: | (id) | aDelegate |
Sets the receiver’s delegate.
aDelegate | The delegate for the receiver. CPRuleEditor requires a delegate that implements the required delegate methods to function. |
Definition at line 206 of file CPRuleEditor.j.
- (void) setDisplayValuesKeyPath: | (CPString) | keyPath |
Sets the key path for the display values.
keyPath | The key path for the the display values. |
Definition at line 1004 of file CPRuleEditor.j.
- (void) setEditable: | (BOOL) | editable |
Sets whether the receiver is editable.
editable | YES if the receiver is editable, otherwise NO . |
Definition at line 236 of file CPRuleEditor.j.
- (void) setFormattingDictionary: | (CPDictionary) | dictionary |
Sets the formatting dictionary for the receiver.
dictionary | The formatting dictionary for the receiver. If you set the formatting dictionary with this method, it sets the current formatting strings file name to nil . |
Definition at line 364 of file CPRuleEditor.j.
- (void) setFormattingStringsFilename: | (CPString) | stringsFilename |
Sets the name of the strings file used for formatting.
stringsFilename | The name of the strings file for the receiver. CPRuleEditor looks for a strings file with the given name in the main bundle and (if appropriate) the bundle containing the nib file from which it was loaded. If it finds a strings file resource with the given name, CPRuleEditor loads it and sets it as the formatting dictionary for the receiver. You can obtain the resulting dictionary using formattingDictionary. If you set the formatting dictionary with -setFormattingDictionary:, it sets the current formatting strings file name nil. |
Definition at line 387 of file CPRuleEditor.j.
- (void) setNestingMode: | (CPRuleEditorNestingMode) | mode |
Sets the nesting mode for the receiver.
mode | The nesting mode for the receiver. You typically set the nesting mode at view creation time and do not subsequently modify it. The default is CPRuleEditorNestingModeSimple . |
Definition at line 266 of file CPRuleEditor.j.
- (void) setRowClass: | (Class) | rowClass |
Sets the class to use to create a new row in the "rows” binding.
rowClass | The class to use to create a new row in the "rows” binding. |
Definition at line 910 of file CPRuleEditor.j.
- (void) setRowHeight: | (float) | height |
Sets the row height for the receiver.
height | The row height for the receiver. |
Definition at line 333 of file CPRuleEditor.j.
- (void) setRowTypeKeyPath: | (CPString) | keyPath |
Sets the key path for the row type.
keyPath | The key path for the row type. |
Definition at line 935 of file CPRuleEditor.j.
- (void) setSubrowsKeyPath: | (CPString) | keyPath |
Sets the key path for the subrows.
keyPath | The key path for the subrows. |
Definition at line 958 of file CPRuleEditor.j.
- (CPIndexSet) subrowIndexesForRow: | (int) | rowIndex |
Returns the immediate subrows of a given row.
rowIndex | The index of a row in the receiver, or -1 to get the top-level rows. |
0
. Definition at line 557 of file CPRuleEditor.j.
- (CPString) subrowsKeyPath |
Returns the key path for the subrows.
Definition at line 948 of file CPRuleEditor.j.