I am trying to create an NSPredicateEditorRowTemplate with its last view a popup that contains a list of things (elsewhere in the window) that can be updated while the editor is being displayed. I can get it so that I can add an instance of the template, update the list of items and add another instance which shows the updated list, but the original does not update.

For example, the original templates specifies A,B,C in the last popup. I add a row with that template then I add a D to the list of items and then add another row to the Predicate Editor. This new row will show me a list of A,B,C,D but the original row still just shows A,B,C.

Is there a way to resync that existing row with the new list of items in its source template? Am I going to have to remove and re-add the row programmatically?


Guy

Here is some code from my hack to try to figure this out:

- (void) awakeFromNib
{
_lefts = [[NSArray arrayWithObject: [NSExpression expressionForKeyPath:@"Filled"]] retain]; _rights = [[NSMutableArray arrayWithObjects:[NSExpression expressionForConstantValue:@"Yabba"],
                                                [NSExpression 
expressionForConstantValue:@"Dabba"],
                                                 [NSExpression 
expressionForConstantValue:@"Doo"],nil] retain];
_ops = [[NSArray arrayWithObject: [NSNumber numberWithInt:NSEqualToPredicateOperatorType]] retain];;

        _filledTemplate = [self generateFilledTemplate];

[_editor setRowTemplates:[[_editor rowTemplates] arrayByAddingObject: _filledTemplate]];
        [_editor addRow:self];
}

- (IBAction)alterFilled:(id)sender
{
[_rights addObject:[NSExpression expressionForConstantValue:@"Sandwich!"]];
        _filledTemplate = [self generateFilledTemplate];
        
        NSArray* templates = [_editor rowTemplates];
        NSMutableArray* newRowTemplates = [NSMutableArray array];
        NSPredicateEditorRowTemplate* template;
        NSEnumerator* enumerator = [templates objectEnumerator];
        
        while (template = [enumerator nextObject])
        {
                NSArray* a = [template leftExpressions];
                if (a != nil)
                {
                        NSExpression* ex = [a objectAtIndex:0];
                
                        if (([ex expressionType] == NSKeyPathExpressionType))
                        {
                                if ([[ex keyPath] isEqual:@"Filled"])
                                {
                                        continue;
                                }
                        }
                }

                [newRowTemplates addObject: template];
        }
        
        [newRowTemplates addObject:_filledTemplate];
        [_editor setRowTemplates: newRowTemplates];
// [_editor reloadCriteria]; //thing makes many bad things happen if I uncomment it
}

- (NSPredicateEditorRowTemplate*) generateFilledTemplate
{
NSPredicateEditorRowTemplate* template = [FilledPredicateEditorRowTemplate alloc] ;
        [template initWithLeftExpressions:_lefts
                                                                                
          rightExpressions:_rights
                                                                                
                          modifier:NSDirectPredicateModifier
                                                                                
                         operators:_ops
                                                                                
                           options: 0];
        
        return template;
}

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to