cappuccino/cappuccino — pull request #1547 by jc-bordes (2012-05-22 21:45:16+00:00)
Title: CPPredicateEditor / CPRuleEditor rewrite 

## What

* rewrite of CPRuleEditor and CPPredicateEditor
* works in the 4 modes : compound, simple, list and single with drag & drop
* bug correction in CPCompoundPredicate
* CPTextField override classes for signed/unsigned integer/float textfields
* extensive ojtest of CPRuleEditorModel.j (see below)
* demos of the components visible here http://dev.globimages.com/capp/ruleeditor and there http://dev.globimages.com/capp/repdicateeditor

## Why

* After several hours spent trying to debug CPRuleEditor and CPPredicateEditor, I got the conviction that this component was so complex (partly because of the design of its cocoa API) that it deserved a good underlying MVC architecture to be easier to maintain or override.

* Basically Drag & drop was not working and there were bugs in reparenting children of a removed compound row

## How

* SPRuleEditorModel is a tree-like collection of rows exposing both a flat index collection API and a tree like collection API (because of cocoa design). It posts notification whenever a row is added, removed or modified.

* SPRuleEditorView is a tree of SPRuleEditorRowView. It listens to SPRuleEditorModel notifications and update the UI consequently. It also delegates user actions execution (add, remove, drop) to SPRuleEditor.

* SPRuleEditor exposes a cocoa like API (NSRuleEditor). Its the controller, it creates SPRuleEditorModel and SPRuleEditorView, responds to SPRuleEditorView delegations by calling SPRuleEditorModel and ask its own delegate for how to create a row (ie criteria, see NSRuleEditor docs)

* SPPredicateEditor (which extends SPRuleEditor) has been rewritten in order to take advantage of the new SPRuleEditor design.

* SPPredicateEditorRowTemplate has been kept almost unchanged

# What's missing (compared to cocoa)

* KVO on CPRuleEditor : not much used I think, but should be easy to do listening to the new SPRuleEditorModel notifications

* row selection (highlighting) : though 2 methods are still present in cocoa API, this feature has been abandoned by Apple. They say in their forums that it was "confusing" for their users. I agree :)

* view animations