Re: NSPredicateEditorRowTemplate for NSDate
Hey, boys and girls? Am I the first, who use NSPredicateEditor? I just found that there is no default template for time values... Please somebody confirm that miracle is over and I need to code all this data/time stuff myself :( On Sun, Jan 18, 2009 at 7:22 PM, Vitaly Ovchinnikov vitaly.ovchinni...@gmail.com wrote: Hello list, When I add a row template that edits date to predicate editor, it allows to perform simple comparisons. Like less or greater or equal etc. Smart folders in Finder allow to add clauses like Date is within last X weeks. I can't find a simple way to do the same. It seems that the only way is to use custom view with that implements what I want, but want to make sure that it is correct before I start. Maybe I missed something? Or maybe some standard implementation already exists? I googled the Internet and this list - nothing. Any ideas? Thank you. ___ 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 arch...@mail-archive.com
Re: NSPredicateEditorRowTemplate for NSDate
The miracle is over. The out-of-the-box templates in IB only provide three-view templates (left expression, operator, right expression). You'll need to subclass NSPredicateEditorRowTemplate and provide the views and logic you want to use in your template. I did a presentation for the local CocoaHeads a while back on NSPredicateEditor and my sample code does show a basic Date is within N days/weeks/months/years if you'd like a starting point. Go to http://groups.google.com/group/des-moines-cocoaheads/files and look for NSPredicateEditor.zip (I'd direct link but the URL is a monster). -- Jim http://nukethemfromorbit.com On Mon, Jan 19, 2009 at 2:13 PM, Vitaly Ovchinnikov vitaly.ovchinni...@gmail.com wrote: Hey, boys and girls? Am I the first, who use NSPredicateEditor? I just found that there is no default template for time values... Please somebody confirm that miracle is over and I need to code all this data/time stuff myself :( On Sun, Jan 18, 2009 at 7:22 PM, Vitaly Ovchinnikov vitaly.ovchinni...@gmail.com wrote: Hello list, When I add a row template that edits date to predicate editor, it allows to perform simple comparisons. Like less or greater or equal etc. Smart folders in Finder allow to add clauses like Date is within last X weeks. I can't find a simple way to do the same. It seems that the only way is to use custom view with that implements what I want, but want to make sure that it is correct before I start. Maybe I missed something? Or maybe some standard implementation already exists? I googled the Internet and this list - nothing. Any ideas? Thank you. ___ 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/jturner.lists%40gmail.com This email sent to jturner.li...@gmail.com ___ 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 arch...@mail-archive.com
Re: NSPredicateEditorRowTemplate for NSDate
On Jan 19, 2009, at 9:13 PM, Vitaly Ovchinnikov wrote: Hey, boys and girls? Am I the first, who use NSPredicateEditor? I just found that there is no default template for time values... I basically use this code for a date value row template (simplified version not tested): NSArray *operators = [NSArray arrayWithObjects: [NSNumber numberWithInteger:NSEqualToPredicateOperatorType], [NSNumber numberWithInteger:NSLessThanPredicateOperatorType], [NSNumber numberWithInteger:NSGreaterThanPredicateOperatorType], [NSNumber numberWithInteger:NSLessThanOrEqualToPredicateOperatorType], [NSNumber numberWithInteger:NSGreaterThanOrEqualToPredicateOperatorType], nil]; NSExpression *equipmentExpr = [NSExpression expressionForKeyPath:@date]; -- use the key path appropriate for your object NSPredicateEditorRowTemplate *dateTemplate = [[[NSPredicateEditorRowTemplate alloc] initWithLeftExpressions:expressions rightExpressionAttributeType:NSDateAttributeType modifier:NSDirectPredicateModifier operators:operators options:0] autorelease]; NSArray *templates = [NSArray arrayWithObjects: ... dateTemplate, ... nil]; [editor setRowTemplates:templates]; -- editor is a NSPredicateEditor ivar All is needed now is a predicate that matches the templates you defined and it should work. If you give the editor a predicate it cannot resolve using the row template you will get a console log entry telling you details (at least on Leopard). Hope this helps! Regards Markus -- __ Markus Spoettl smime.p7s Description: S/MIME cryptographic signature ___ 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 arch...@mail-archive.com
Re: NSPredicateEditorRowTemplate for NSDate
Hello Vitaly, The Cocoa frameworks do not yet have any classes for specifying a relative date, so you will have to handle this yourself with a subclass of NSPredicateEditorRowTemplate. You can leverage the superclass to do much of the work for you: your responsibility is limited to turning a RelativeDate into units (days, weeks) and a value in those units, and going the other direction as well. I wrote a sample showing one way to handle relative dates. For now it is at http://homepage.mac.com/gershwin/RelativeDatesPredicateEditor.zip As to no default template for time values, this is a limitation of IB's support for NSPredicateEditor. You can set up a time-editing NSDatePicker programmatically like so: * Create an NSPredicateEditorRowTemplate that edits dates in IB * Make an outlet to it * When your code starts, set the date picker elements to what you want: [[[template templateViews] objectAtIndex:2] setDatePickerElements:elements]; This is a mechanism that NSPredicateEditor supports. Hope this helps, -Peter On Jan 18, 2009, at 8:22 AM, Vitaly Ovchinnikov wrote: Hello list, When I add a row template that edits date to predicate editor, it allows to perform simple comparisons. Like less or greater or equal etc. Smart folders in Finder allow to add clauses like Date is within last X weeks. I can't find a simple way to do the same. It seems that the only way is to use custom view with that implements what I want, but want to make sure that it is correct before I start. Maybe I missed something? Or maybe some standard implementation already exists? I googled the Internet and this list - nothing. Any ideas? Thank you. ___ 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/pammon%40apple.com This email sent to pam...@apple.com ___ 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 arch...@mail-archive.com
Re: NSPredicateEditorRowTemplate for NSDate
Thanks to all for answers, now I need a few days to sleep with all these data. Thank you. On Tue, Jan 20, 2009 at 12:04 AM, Jim Turner jturner.li...@gmail.com wrote: The miracle is over. The out-of-the-box templates in IB only provide three-view templates (left expression, operator, right expression). You'll need to subclass NSPredicateEditorRowTemplate and provide the views and logic you want to use in your template. I did a presentation for the local CocoaHeads a while back on NSPredicateEditor and my sample code does show a basic Date is within N days/weeks/months/years if you'd like a starting point. Go to http://groups.google.com/group/des-moines-cocoaheads/files and look for NSPredicateEditor.zip (I'd direct link but the URL is a monster). -- Jim http://nukethemfromorbit.com On Mon, Jan 19, 2009 at 2:13 PM, Vitaly Ovchinnikov vitaly.ovchinni...@gmail.com wrote: Hey, boys and girls? Am I the first, who use NSPredicateEditor? I just found that there is no default template for time values... Please somebody confirm that miracle is over and I need to code all this data/time stuff myself :( On Sun, Jan 18, 2009 at 7:22 PM, Vitaly Ovchinnikov vitaly.ovchinni...@gmail.com wrote: Hello list, When I add a row template that edits date to predicate editor, it allows to perform simple comparisons. Like less or greater or equal etc. Smart folders in Finder allow to add clauses like Date is within last X weeks. I can't find a simple way to do the same. It seems that the only way is to use custom view with that implements what I want, but want to make sure that it is correct before I start. Maybe I missed something? Or maybe some standard implementation already exists? I googled the Internet and this list - nothing. Any ideas? Thank you. ___ 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/jturner.lists%40gmail.com This email sent to jturner.li...@gmail.com ___ 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 arch...@mail-archive.com
NSPredicateEditorRowTemplate for NSDate
Hello list, When I add a row template that edits date to predicate editor, it allows to perform simple comparisons. Like less or greater or equal etc. Smart folders in Finder allow to add clauses like Date is within last X weeks. I can't find a simple way to do the same. It seems that the only way is to use custom view with that implements what I want, but want to make sure that it is correct before I start. Maybe I missed something? Or maybe some standard implementation already exists? I googled the Internet and this list - nothing. Any ideas? Thank you. ___ 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 arch...@mail-archive.com