Author:
caca...@gmail.com
Date: Sun Feb 1 01:39:03 2009
New Revision: 98
Modified:
branches/CPRuleEditor/AppController.j
branches/CPRuleEditor/CPCompoundPredicate.j
branches/CPRuleEditor/CPRuleEditor.j
branches/CPRuleEditor/CPRuleEditorViewSlice.j
branches/CPRuleEditor/CPRuleEditorViewSliceRow.j
branches/CPRuleEditor/RuleDelegate.j
branches/CPRuleEditor/RuleEditor.steam
branches/CPRuleEditor/_CPRuleEditorViewSliceHolder.j
branches/CPRuleEditor/criteria.plist
Log:
First usable version
Modified: branches/CPRuleEditor/AppController.j
==============================================================================
--- branches/CPRuleEditor/AppController.j (original)
+++ branches/CPRuleEditor/AppController.j Sun Feb 1 01:39:03 2009
@@ -1,48 +1,138 @@
@import <Foundation/CPObject.j>
@import "CPRuleEditor.j"
@import "RuleDelegate.j"
+@import "Localizer.j"
+@implementation CPDictionary (ReadFile)
-@implementation AppController : CPObject
++(id)dictionaryWithContentsOfURL:(CPURL)url
+{
+
+ var request = [CPURLRequest requestWithURL:url];
+ var data = [CPURLConnection sendSynchronousRequest:request
returningResponse:NULL error:NULL];
+ if (data)
+ {
+ var dict = [CPPropertyListSerialization propertyListFromData:data
format:CPPropertyListXMLFormat_v1_0 errorDescription:NULL];
+ return dict;
+ }
+
+ return nil;
+}
+
+@end
+
+@implementation CPArray (ReadFile)
+
++(id)arrayWithContentsOfURL:(CPURL)url
+{
+ var request = [CPURLRequest requestWithURL:url];
+ var data = [CPURLConnection sendSynchronousRequest:request
returningResponse:NULL error:NULL];
+ if (data)
+ {
+ var array = [CPPropertyListSerialization propertyListFromData:data
format:CPPropertyListXMLFormat_v1_0 errorDescription:NULL];
+ return array;
+ }
+
+ return nil;
+}
+
+@end
+
+@implementation CPString (ReadFile)
++(id)stringWithContentsOfURL:(CPURL)url
{
+ var request = [CPURLRequest requestWithURL:url];
+ var data = [CPURLConnection sendSynchronousRequest:request
returningResponse:NULL error:NULL];
+ if (data)
+ {
+ return [data string];
+ }
+
+ return nil;
}
+@end
+
+
+@implementation AppController : CPObject
+{
+CPTextField textField;
+CPTextField tableField;
+CPArray tableArray;
+CPView ruleEditor;
+}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
-
+
CPLogRegister(CPLogConsole);
+ var isWebkit = CPBrowserIsEngine(CPWebKitBrowserEngine);
+ if(!isWebkit)
+ {
+ var alert = [[CPAlert alloc] init];
+ [alert setAlertStyle:CPCriticalAlertStyle];
+ [alert setMessageText:"Works in Webkit only"];
+ [alert runModal];
+ }
- var array = [CPArray arrayWithObjects:"a","b","c",nil];
- var dict = [CPDictionary dictionaryWithObject:array forKey:"array"];
- var mut = [dict mutableArrayValueForKey:"array"];
- CPLogConsole("mut = "+ mut );
-
- var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero()
styleMask:CPBorderlessBridgeWindowMask],
+ var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero()
styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
-
- var ruleEditor = [[RuleEditor alloc]
initWithFrame:CGRectMake(0,0,400,200)];
- [ruleEditor setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin |
CPViewHeightSizable];
-
+
+ ruleEditor = [[RuleEditor alloc]
initWithFrame:CGRectMake(0,0,600,200)];
+ [ruleEditor setAutoresizingMask:CPViewMaxXMargin ];
+
var datasource = [[RuleDelegate alloc] init];
[ruleEditor setDelegate:datasource];
-
+
[ruleEditor setNestingMode:CPRuleEditorNestingModeSimple];
-
- var aView = [[CPView alloc] initWithFrame:CGRectMake(0,0,50,200)];
- [aView setBackgroundColor:[CPColor greenColor]];
-
- var split = [[CPSplitView alloc]
initWithFrame:CGRectMake(0,0,600,400)];
- [split addSubview:aView];
- [split addSubview:ruleEditor];
-
- [contentView addSubview:split];
+ [ruleEditor setFormattingStringsFilename:"format.strings"];
+ [ruleEditor setCanRemoveAllRows:NO];
+
+ [contentView addSubview:ruleEditor];
[ruleEditor addRow:self];
-
+ [self refresh:[ruleEditor predicate]];
+/*
+ var button = [[CPButton alloc]
initWithFrame:CGRectMake(610,20,100,20)];
+ [button setAction:@selector(addRow:)];
+ [button setTarget:ruleEditor];
+ [button setTitle:"Add Row"];
+ [contentView addSubview:button];
+*/
+
+tableArray = [CPArray arrayWithObjects:[CPDictionary
dictionaryWithObjects:["Jim ","McNulty",46]
forKeys:["firstName","lastName","age"]],
+ [CPDictionary dictionaryWithObjects:["Kima","Williams",41]
forKeys:["firstName","lastName","age"]],
+ [CPDictionary dictionaryWithObjects:["Omar","Little",29]
forKeys:["firstName","lastName","age"]],
+ [CPDictionary dictionaryWithObjects:["Avon","Barkstale",51]
forKeys:["firstName","lastName","age"]],nil];
+
+ textField = [[CPTextField alloc] initWithFrame:CGRectMake(0,200,600,50)];
+ [textField setBackgroundColor:[CPColor colorWithCalibratedWhite:0.0
alpha:1]];
+ [textField setTextColor:[CPColor greenColor]];
+ [textField setFont:[CPFont systemFontOfSize:14]];
+ [textField setLineBreakMode:CPLineBreakByWordWrapping];
+ [contentView addSubview:textField];
+
+ tableField = [[CPTextField alloc]
initWithFrame:CGRectMake(0,260,600,150)];
+ [tableField setBackgroundColor:[CPColor colorWithCalibratedWhite:0.0
alpha:1]];
+ [tableField setTextColor:[CPColor greenColor]];
+ [tableField setFont:[CPFont systemFontOfSize:14]];
+ [tableField setLineBreakMode:CPLineBreakByWordWrapping];
+ [contentView addSubview:tableField];
+
+
[theWindow orderFront:self];
-
- // Uncomment the following line to turn on the standard menu bar.
- // [CPMenu setMenuBarVisible:YES];
+ }
+
+-(void)refresh:predicate{
+[textField setStringValue:[predicate predicateFormat]];
+
+ var desc = "";
+
+ var filtered = [tableArray filteredArrayUsingPredicate:predicate];
+ for(var i=0;i<[filtered count];i++)
+ desc += [[[filtered objectAtIndex:i] allValues]
componentsJoinedByString:" "] +"\n";
+
+ [tableField setStringValue:desc];
+
}
@end
Modified: branches/CPRuleEditor/CPCompoundPredicate.j
==============================================================================
--- branches/CPRuleEditor/CPCompoundPredicate.j (original)
+++ branches/CPRuleEditor/CPCompoundPredicate.j Sun Feb 1 01:39:03 2009
@@ -2,11 +2,10 @@
@import <Foundation/CPArray.j>
@import <Foundation/CPString.j>
+var CPCompoundPredicateType;
CPNotPredicateType = 0;
CPAndPredicateType = 1;
-CPOrPredicateType = 2;
-
-var CPCompoundPredicateType;
+CPOrPredicateType = 2;
@implementation CPCompoundPredicate : CPPredicate
{
@@ -27,7 +26,7 @@
return [[self alloc] initWithType:CPNotPredicateType
subpredicates:[CPArray arrayWithObject:predicate]];
}
-+ (CPPredicate)andPredicateWithSubpredicates:(CPArray *)predicates
++ (CPPredicate)andPredicateWithSubpredicates:(CPArray)predicates
{
return [[self alloc] initWithType:CPAndPredicateType
subpredicates:predicates];
}
@@ -53,37 +52,40 @@
- (CPString)predicateFormat
{
- var result = [CPString string],
+ var result = "",
args = [CPArray array],
- count = [_predicates count],
i;
-
- for (i = 0;i < count;i++)
+
+ for (i = 0;i < [_predicates count];i++)
{
- var subpredicate = [_predicates objectAtIndex:i],
- precedence = [subpredicate predicateFormat];
-
- if ([subpredicate isKindOfClass:[CPCompoundPredicate class]] &&
- [subpredicate compoundPredicateType] != _type)
+ var subpredicate = [_predicates objectAtIndex:i];
+ var precedence = [subpredicate predicateFormat];
+
+ if ([subpredicate isKindOfClass:[CPCompoundPredicate class]] &&
[[subpredicate subpredicates] count]> 1 && [subpredicate
compoundPredicateType] != _type)
precedence = [CPString stringWithFormat:@"(%s)",precedence];
- [args addObject:precedence];
+ if(precedence != nil) [args addObject:precedence];
}
-
+
switch (_type)
{
case CPNotPredicateType:
- result = result + [CPString stringWithFormat:@"NOT %s",[args
objectAtIndex:0]];
+ result += "NOT %s" + [args objectAtIndex:0];
break;
case CPAndPredicateType:
- result = result + [CPString stringWithFormat:@"%s AND %s",[args
objectAtIndex:0],[args objectAtIndex:1]];
+ result += [args objectAtIndex:0];
+ for(var j=1;j<[args count];j++) result += " AND " + [args
objectAtIndex:j];
break;
case CPOrPredicateType:
- result = result + [CPString stringWithFormat:@"%s OR %s",[args
objectAtIndex:0],[args objectAtIndex:1]];
+ CPLogConsole("result = "+result);
+ result += [args objectAtIndex:0];
+
+ for(var j=1;j<[args count];j++) result += " OR " + [args
objectAtIndex:j];
break;
}
+
return result;
}
Modified: branches/CPRuleEditor/CPRuleEditor.j
==============================================================================
--- branches/CPRuleEditor/CPRuleEditor.j (original)
+++ branches/CPRuleEditor/CPRuleEditor.j Sun Feb 1 01:39:03 2009
@@ -1,4 +1,4 @@
-/*
+ /*
* Created by
caca...@gmail.com.
* Copyright (c) 2008 Pear, Inc. All rights reserved.
*/
@@ -11,6 +11,8 @@
@import "_CPRuleEditorViewUnboundRowHolder.j"
@import "CPRuleEditorViewSliceDropSeparator.j"
@import "CPRuleEditorViewSliceRow.j"
+@import "RowObject.j"
+@import "Localizer.j"
CPRuleEditorPredicateLeftExpression
= "CPRuleEditorPredicateLeftExpression";
CPRuleEditorPredicateRightExpression
= "CPRuleEditorPredicateRightExpression";
@@ -97,6 +99,11 @@
id _ruleReserved2;
}
+-(id)standardLocalizer
+{
+ return _standardLocalizer;
+}
+
+ (void)initialize
{
@@ -182,7 +189,7 @@
allowsEmptyCompoundRows = 0;
disallowEmpty = 0;
- _rowClass = [CPDictionary class];
+ _rowClass = [RowObject class];
_itemsKeyPath = @"criteria";
_subrowsArrayKeyPath = @"subrows";
_typeKeyPath = @"rowType";
@@ -200,7 +207,7 @@
_boundArrayOwner = [[RuleEditorViewUnboundRowHolder alloc] init];
[_boundArrayOwner addObserver:self forKeyPath:_boundArrayKeyPath
options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew
context:boundArrayContext];
-
+
[self registerForDraggedTypes:[CPArray
arrayWithObjects:CPRuleEditorItemPBoardType,nil]];
var center = [CPNotificationCenter defaultCenter];
@@ -210,7 +217,7 @@
- (RuleEditorViewSliceDropSeparator)_createSliceDropSeparator
{
- var view = [[RuleEditorViewSliceDropSeparator alloc]
initWithFrame:CGRectMake(0,-5, [self frame].size.width, 2)];
+ var view = [[RuleEditorViewSliceDropSeparator alloc]
initWithFrame:CGRectMake(0,-10, [self frame].size.width, 2)];
[view setAutoresizingMask:CPViewWidthSizable];
return view;
}
@@ -435,23 +442,19 @@
- (int)parentRowForRow:(int)rowIndex
{
if (rowIndex < 0 || rowIndex > [self numberOfRows])
- [CPException raise:CPRangeException reason:@"row %d is out of
range",rowIndex];
+ [CPException raise:CPRangeException reason:@"row "+rowIndex+" is out
of range"];
var targetObject = [[self _rowCacheForIndex:rowIndex] rowObject];
-CPLogConsole("rowTypeForRow0"+[self rowTypeForRow:0]);
+
var current_index;
for (current_index = 0; current_index < rowIndex; current_index ++){
if ([self rowTypeForRow:current_index] == CPRuleEditorRowTypeCompound)
{
var candidate = [[self _rowCacheForIndex:current_index] rowObject];
- var subObjects = [self _subrowObjectsOfObject:candidate];
-
- for(var i = 0;i< [subObjects count];i++)
- {
- var obj = [subObjects objectAtIndex:i];
- if(obj === targetObject)
- return current_index;
- }
+ var subObjects = [[self _subrowObjectsOfObject:candidate]
_representedObject];
+
+ if([subObjects indexOfObjectIdenticalTo:targetObject] != CPNotFound)
+ return current_index;
}
}
return -1;
@@ -482,7 +485,7 @@
var i;
for (i = rowIndex+1; i<[self numberOfRows]; i++) {
var candidate = [[self _rowCacheForIndex:i] rowObject];
- var indexInSubrows = [subobjects indexOfObjectIdenticalTo:candidate];
+ var indexInSubrows = [[subobjects _representedObject]
indexOfObjectIdenticalTo:candidate];
if (indexInSubrows != CPNotFound){
[indexes addIndex:i];
@@ -557,7 +560,7 @@
- (void)removeRowAtIndex:(int)rowIndex
{
// TO DO : remove compound row
- [self removeRowsAtIndexes:[CPIndexSet indexSetWithIndex:rowIndex]
includeSubrows:NO];
+ [self removeRowsAtIndexes:[CPIndexSet indexSetWithIndex:rowIndex]
includeSubrows:YES];
}
- (void)removeRowsAtIndexes:(CPIndexSet)indexes
includeSubrows:(BOOL)include
@@ -579,22 +582,24 @@
var childsIndexes = [CPMutableIndexSet indexSet];
while (current_index != CPNotFound) {
-
+CPLogConsole("current_index = "+current_index);
var rowObject = [[self _rowCacheForIndex:current_index] rowObject];
+CPLogConsole("rowObject = "+rowObject);
+ var relativeChildIndex = [[_subrows _representedObject]
indexOfObjectIdenticalTo:rowObject];
- var relativeChildIndex = [_subrows indexOfObjectIdenticalTo:rowObject];
-
if (relativeChildIndex != CPNotFound)[childsIndexes
addIndex:relativeChildIndex];
if (include && [self rowTypeForRow:current_index] ==
CPRuleEditorRowTypeCompound)
{
var more_childs = [self subrowIndexesForRow:current_index];
+ CPLogConsole("more_childs = "+more_childs+"current_index
= "+current_index);
[self removeRowsAtIndexes:more_childs includeSubrows:include];
}
current_index = [indexes indexGreaterThanIndex:current_index];
}
+CPLogConsole("childsIndexes = "+childsIndexes);
[_subrows removeObjectsAtIndexes:childsIndexes];
}
@@ -657,8 +662,9 @@
var rowTypeEvent = [self rowTypeForRow:rowIndexEvent];
var parentRowIndex = (rowTypeEvent == CPRuleEditorRowTypeCompound)?
rowIndexEvent:[self parentRowForRow:rowIndexEvent];
-
+CPLogConsole("rowIndexEvent "+rowIndexEvent +"
rowTypeEvent:"+rowTypeEvent+"parentRowIndex "+parentRowIndex);
[self insertRowAtIndex:rowIndexEvent + 1 withType:type
asSubrowOfRow:parentRowIndex animate:YES];
+
// [self _reconfigureSubviewsAnimate:YES];
// [self _updatePredicate];
@@ -689,7 +695,7 @@
parentRowIndex = -1; // bon ou pas bon ?
break;
default:
- [CPException raise:CPInvalidArgumentException format:@"Not supported
CPRuleEditorNestingMode %d",_nestingMode];
+ [CPException raise:CPInvalidArgumentException reason:@"Not supported
CPRuleEditorNestingMode %d"+_nestingMode];
// Compound mode: parentRowIndex=(lastRowType ==
CPRuleEditorRowTypeCompound)?lastRow :[self parentRowForRow:lastRow]; break;
}
@@ -705,15 +711,20 @@
if (rowtype == CPRuleEditorRowTypeCompound && ![self
_allowsEmptyCompoundRows])
{
var subrow = [self _insertNewRowAtIndex:insertIndex+1
ofType:CPRuleEditorRowTypeSimple withParentRow:insertIndex];
- [[newObject valueForKey:_subrowsArrayKeyPath] insertObject:subrow
atIndex:0];
+ [[self _subrowObjectsOfObject:newObject] insertObject:subrow atIndex:0];
}
-
- var parentRowObject = (parentRowIndex == -1 || _nestingMode ==
CPRuleEditorNestingModeList)?_boundArrayOwner:[[self
_rowCacheForIndex:parentRowIndex] rowObject];
-CPLogConsole([_boundArrayOwner
mutableArrayValueForKey:_boundArrayKeyPath]);
+CPLogConsole(_cmd);
+ var parentRowObject = (parentRowIndex === -1 || _nestingMode ==
CPRuleEditorNestingModeList) ? _boundArrayOwner:[[self
_rowCacheForIndex:parentRowIndex] rowObject];
+ var subrows_key_path = (parentRowObject === _boundArrayOwner) ?
_boundArrayKeyPath:_subrowsArrayKeyPath;
+CPLogConsole(_cmd);
var subrowsObjects = [self _subrowObjectsOfObject:parentRowObject];
-
- [subrowsObjects insertObject:newObject
atIndex:insertIndex-parentRowIndex-1];
-
+ var r_insertIndex = insertIndex-parentRowIndex-1;
+CPLogConsole(_cmd);
+// [parentRowObject willChange:CPKeyValueChangeInsertion
valuesAtIndexes:[CPIndexSet indexSetWithIndex:r_insertIndex]
forKey:subrows_key_path];
+ [subrowsObjects insertObject:newObject atIndex:r_insertIndex];
+ CPLogConsole([subrowsObjects className]);
+// [parentRowObject didChange:CPKeyValueChangeInsertion
valuesAtIndexes:[CPIndexSet indexSetWithIndex:r_insertIndex]
forKey:subrows_key_path];
+CPLogConsole(_cmd);
}
- (id)_insertNewRowAtIndex:(int)insertIndex
ofType:(CPRuleEditorRowType)rowtype withParentRow:(int)parentRowIndex
@@ -733,6 +744,7 @@
- (void)_startObservingRowObjectsRecursively:(id)rowObjects
{
+CPLogConsole(_cmd);
var i;
for (i =0;i <[rowObjects count];i++)
{
@@ -749,6 +761,7 @@
- (void)_stopObservingRowObjectsRecursively:(id)rowObjects
{
+CPLogConsole(_cmd);
var i;
for (i =0;i <[rowObjects count];i++)
{
@@ -757,7 +770,7 @@
[rowObject removeObserver:self forKeyPath:_valuesKeyPath];
[rowObject removeObserver:self forKeyPath:_subrowsArrayKeyPath];
- var subrows = [rowObject objectForKey:_subrowsArrayKeyPath];
+ var subrows = [rowObject valueForKey:_subrowsArrayKeyPath];
if([subrows count]>0)[self _stopObservingRowObjectsRecursively:subrows];
}
}
@@ -819,7 +832,7 @@
oldRows = changeOldValue;
[self _changedRowArray:newRows withOldRowArray:oldRows
forParent:object];
- [self _reconfigureSubviewsAnimate:NO];
+ [self _reconfigureSubviewsAnimate:YES];
[self reloadPredicate];
if ([newRows count] != [oldRows count])
@@ -836,40 +849,43 @@
}
- (void)_changedItem:(id)oldItem toItem:(id)newItem inRow:(int)rowIndex
atCriteriaIndex:(int)indexInCriteria
-{CPLogConsole(_cmd);
+{
+CPLogConsole(_cmd +" old "+[oldItem description]+"new "+[newItem
description]);
var criteria = [self criteriaForRow:rowIndex];
+CPLogConsole(_cmd +"in row "+rowIndex);
var values = [self displayValuesForRow:rowIndex];
var type = [self rowTypeForRow:rowIndex];
-CPLogConsole(_cmd);
+
var itemToAdd = newItem;
var relativeIndexInCriteria = 0;
- var num_childs = CPNotFound;
-CPLogConsole(_cmd);
- var remainingRange = CPMakeRange(0, MIN(indexInCriteria,[criteria
count]));
-
- var finalCriteria = [CPMutableArray arrayWithArray:[criteria
subarrayWithRange:remainingRange]];
+ var num_childs = 1000;
- var finalValues = [CPMutableArray arrayWithArray:[values
subarrayWithRange:remainingRange]];
-CPLogConsole(_cmd);
- while (num_childs >0){
+ var remainingRange = CPMakeRange(0, indexInCriteria);
+CPLogConsole("indexInCriteria = "+indexInCriteria+" ; criteria count
= "+[criteria count]);
+ var finalCriteria = [[CPMutableArray alloc] initWithArray:[criteria
subarrayWithRange:remainingRange]];
+ var finalValues = [[CPMutableArray alloc] initWithArray:[values
subarrayWithRange:remainingRange]];
+CPLogConsole("finalValues ="+[finalValues count]);
+ while (num_childs > 0){
[finalCriteria addObject:itemToAdd];
-
+CPLogConsole("finalCriteria ="+[finalCriteria count]);
var displayvalue = [self _queryValueForItem:itemToAdd inRow:rowIndex];
[finalValues addObject:displayvalue];
num_childs = [self _queryNumberOfChildrenOfItem:itemToAdd
withRowType:type];
-
- if (num_childs >0)
+CPLogConsole("num_childs ="+num_childs);
+ if (num_childs > 0)
itemToAdd = [self _queryChild:0 ofItem:itemToAdd withRowType:type];
-
+CPLogConsole("itemToAdd ="+[itemToAdd description]);
relativeIndexInCriteria++;
}
-CPLogConsole(_cmd);
+
var object = [[self _rowCacheForIndex:rowIndex] rowObject];
+CPLogConsole("finalValues ="+finalValues);
[object setValue:finalCriteria forKey:_itemsKeyPath];
[object setValue:finalValues forKey:_valuesKeyPath];
+
[[_slices objectAtIndex:rowIndex] _reconfigureSubviews];
CPLogConsole(_cmd);
[self _postRuleOptionChangedNotification];
@@ -877,6 +893,7 @@
- (void)_changedRowArray:(CPArray)newRows withOldRowArray:(CPArray)oldRows
forParent:(id)parentRowObject
{
+CPLogConsole(_cmd);
[self _stopObservingRowObjectsRecursively:oldRows];
[self _startObservingRowObjectsRecursively:newRows];
@@ -987,7 +1004,6 @@
- (void)_reconfigureSubviewsAnimate:(BOOL)animate
{
-CPLogConsole(_cmd);
[self _updateSliceRows];
var viewAnimations = [CPMutableArray array];
@@ -1012,7 +1028,7 @@
var animation = [CPDictionary dictionary];
[animation setObject:aslice forKey:"CPViewAnimationTargetKey"];
- [animation setObject:[CPValue valueWithJSObject:targetRect]
forKey:"CPViewAnimationEndFrameKey"];
+ [animation setObject:targetRect.origin.y
forKey:"CPViewAnimationEndFrameKey"];
[viewAnimations insertObject:animation atIndex:0];
}
@@ -1024,17 +1040,22 @@
[added_slice setNeedsDisplay:YES];
[_slicesHolder addSubview:added_slice positioned:CPWindowBelow
relativeTo:nil];
- CPLogConsole("holer:"+CPStringFromRect([_slicesHolder
frame])+"slice"+CPStringFromRect([added_slice frame]));
+ CPLogConsole("Added slice"+CPStringFromRect([added_slice frame]));
}
if (animate)
{
for (var k= 0;k< [viewAnimations count];k++)
- {
- var anime = [viewAnimations objectAtIndex:k];
- var endFrame = [[anim valueforKey:"CPViewAnimationEndFrameKey"]
JSObject];
- var target = [anim valueforKey:"CPViewAnimationTargetKey"];
- [[target _layer] setFrame:endFrame];
+ {
+CPLogConsole(_cmd);
+ var anim = [viewAnimations objectAtIndex:k];
+CPLogConsole([anim description]);
+ var endOrigin = [anim objectForKey:"CPViewAnimationEndFrameKey"];
+CPLogConsole(_cmd);
+ var target = [anim objectForKey:"CPViewAnimationTargetKey"];
+CPLogConsole(_cmd);
+var endFrame = CPRectMake(0,endOrigin,[self
frame].size.width,_sliceHeight);
+ [target setFrame:endFrame];
}
}
/*
@@ -1070,7 +1091,7 @@
var rowcache = [self _rowCacheForIndex:index];
if (rowcache){
- var values = [[rowcache rowObject]
mutableArrayValueForKey:_itemsKeyPath];
+ var values = [[rowcache rowObject] valueForKey:_itemsKeyPath];
return values;
}
@@ -1082,7 +1103,7 @@
var rowcache = [self _rowCacheForIndex:index];
if (rowcache){
- var values = [[rowcache rowObject]
mutableArrayValueForKey:_valuesKeyPath];
+ var values = [[rowcache rowObject] valueForKey:_valuesKeyPath];
return values;
}
@@ -1123,7 +1144,8 @@
while (current_index!=CPNotFound)
{
var subpredicate = [self predicateForRow:current_index];
- if (subpredicate)[subpredicates addObject:subpredicate];
+ CPLogConsole("Predicate For Row "+current_index+" = "+subpredicate);
+ if (subpredicate!=nil)[subpredicates addObject:subpredicate];
current_index = [subindexes indexGreaterThanIndex:current_index];
}
@@ -1133,6 +1155,8 @@
[self setPredicate:new_predicate];
//[self didChangeValueForKey:@"predicate"];
CPLogConsole(@"new Predicate:" + new_predicate);
+ [[[CPApplication sharedApplication] delegate] refresh:new_predicate];
+
}
- (void)_updatePredicate
@@ -1150,14 +1174,15 @@
if (![_ruleDelegate respondsToSelector:predicatePartsForCriterion])
{
- CPLogConsole(@"Delegate doesn't respond to " +
CPStringFromSelector(predicatePartsForCriterion));
+ [CPException raise:CPInternalInconsistencyException
+ reason:@"Delegate doesn't respond to " +
CPStringFromSelector(predicatePartsForCriterion)];
return NULL;
}
if (![_ruleDelegate respondsToSelector:displayValueForCriterion])
{
[CPException raise:CPInternalInconsistencyException
- format:@"Delegate doesn't respond to " +
CPStringFromSelector(displayValueForCriterion)];
+ reason:@"Delegate doesn't respond to " +
CPStringFromSelector(displayValueForCriterion)];
return NULL;
}
delegateWantsValidation = NO;
@@ -1166,18 +1191,20 @@
var predicateParts = [CPDictionary dictionary];
var items = [self criteriaForRow:row];
+ CPLogConsole("num items in row "+row+" = "+[items count]);
var i;
for (i = 0; i < [items count]; i++){
var item = [items objectAtIndex:i];
var displayValue = [self _queryValueForItem:item inRow:row]; // A voir.
On peut aussi prendre la valeur affichée dans le row cache.
var predpart = [_ruleDelegate ruleEditor:self
predicatePartsForCriterion:item withDisplayValue:displayValue inRow:row];
- if (predpart)[predicateParts setValuesForKeysWithDictionary:predpart];
+CPLogConsole("Predicate part = " + [predpart description]+" for item "+i+"
in row "+row);
+ if (predpart)[predicateParts addEntriesFromDictionary:predpart];
}
if ([self rowTypeForRow:row] == CPRuleEditorRowTypeCompound)
{
-
+ var compoundPredicate;
var subpredicates = [CPMutableArray array];
var subrowsIndexes = [self subrowIndexesForRow:row];
@@ -1185,13 +1212,16 @@
var current_index = [subrowsIndexes firstIndex];
while (current_index != CPNotFound) {
+
var subpredicate = [self predicateForRow:current_index];
- if (subpredicate)[subpredicates addObject:subpredicate];
+
+ if (subpredicate != nil)[subpredicates addObject:subpredicate];
+
current_index = [subrowsIndexes indexGreaterThanIndex:current_index];
}
-
+
var compoundType = [[predicateParts
objectForKey:CPRuleEditorPredicateCompoundType] intValue];
- var compoundPredicate;
+
if ([subpredicates count] == 0)
return nil;
@@ -1201,11 +1231,13 @@
try
{
compoundPredicate = [[CPCompoundPredicate alloc ]
initWithType:compoundType subpredicates:subpredicates];
+ CPLogConsole("compoundPredicate = " + [compoundPredicate
subpredicates]+ "type = "+compoundType);
+
}
catch(error)
{
- CPLogConsole(@"Compound predicate error: [%@]\npredicateType:%i",[e
description],compoundType);
- compoundPredicate = NULL;
+ CPLogConsole(@"Compound predicate error:
[%@]\npredicateType:%i",[error description],compoundType);
+ compoundPredicate = nil;
}
finally
{
@@ -1222,20 +1254,20 @@
var modifier = [predicateParts
objectForKey:CPRuleEditorPredicateComparisonModifier];
var selector = CPSelectorFromString([predicateParts
objectForKey:"CPRuleEditorPredicateCustomSelector"]);
- if (!lhs){ CPLogConsole(@"missing left expression in predicate parts
dictionary"); return NULL;}
- if (!rhs){ CPLogConsole(@"missing right expression in predicate parts
dictionary"); return NULL;}
- if (selector == 0 && !operator){ CPLogConsole(@"missing operator type
while no selector in predicate parts dictionary"); return NULL;}
+ if (lhs == nil){ CPLogConsole(@"missing left expression in predicate
parts dictionary"); return NULL;}
+ if (rhs == nil){ CPLogConsole(@"missing right expression in predicate
parts dictionary"); return NULL;}
+ if (selector == nil && operator == nil){ CPLogConsole(@"missing operator
type while no selector in predicate parts dictionary"); return NULL;}
- if (!modifier) CPLogConsole(@"missing modifier in predicate parts
dictionary. Setting default: CPDirectPredicateModifier");
- if (!options) CPLogConsole(@"missing options in predicate parts
dictionary. Setting default: CPCaseInsensitivePredicateOption");
+ if (modifier == nil) CPLogConsole(@"missing modifier in predicate parts
dictionary. Setting default: CPDirectPredicateModifier");
+ if (options == nil) CPLogConsole(@"missing options in predicate parts
dictionary. Setting default: CPCaseInsensitivePredicateOption");
var predicate;
- CPLogConsole(@"lhs: " + lhs + " operator:" + operator + " rhs:" + rhs + "
modifier:" + modifier + " options:" + options + " selector:" + selector);
+ CPLogConsole("At Row "+ row +" lhs: " + lhs + " operator:" + operator + "
rhs:" + rhs + " modifier:" + modifier + " options:" + options + "
selector:" + selector);
var error;
try
{
- if (selector != 0)
+ if (selector != nil)
predicate = [CPComparisonPredicate
predicateWithLeftExpression:lhs
rightExpression:rhs
@@ -1269,13 +1301,13 @@
- (CPColor)_sliceBottomBorderColor
{
- return [CPColor colorWithCalibratedRed:0.729412 green:0.729412
blue:0.729412 alpha:1];
+ return [CPColor colorWithCalibratedWhite:0.729412 alpha:1];
}
- (CPColor)_sliceLastBottomBorderColor
{
// return [CPColor controlShadowColor];
- return [CPColor blackColor];
+ return [CPColor colorWithCalibratedWhite:0.577788 alpha:1];
}
- (CPString)_toolTipForAddCompoundRowButton
@@ -1313,12 +1345,12 @@
- (CPColor)_selectedActiveRowColor
{
- return [CPColor controlColor];
+ return [CPColor redColor];
}
- (CPColor)_selectedInactiveRowColor
{
- return [CPColor secondarySelectedControlColor];
+ return [CPColor lightGrayColor];
}
- (CPArray)_selectedSlices
@@ -1356,8 +1388,8 @@
{
var slice = _slices[i];
- [slice _setSelected:NO];
- [slice _setLastSelected:NO];
+ [slice _setSelected:0];
+ [slice _setLastSelected:0];
}
}
@@ -1367,14 +1399,19 @@
if (modifierFlags & CPCommandKeyMask && [slice _rowType] ==
CPRuleEditorRowTypeSimple){
[slice _setSelected:![slice _isSelected]];
- if (![slice _isSelected])[slice _setLastSelected:YES];
+ if (![slice _isSelected])[slice _setLastSelected:1];
[slice setNeedsDisplay:YES];
}else{
+
[self _deselectAll];
- [slice _setSelected:YES];
- [slice _setLastSelected:YES];
- [_slices makeObjectsPerformSelector:@selector(setNeedsDisplay:)
withObject:YES];
+ [slice _setSelected:1];
+ [slice _setLastSelected:1];
+
+ for(i=0;i<[_slices count];i++)
+ [_slices[i] setNeedsDisplay:YES];
+ //[_slices makeObjectsPerformSelector:@selector(setNeedsDisplay:)
withObject:YES];
}
+ CPLogConsole(_cmd);
}
- (void)_setSuppressKeyDownHandling:(BOOL)flag
@@ -1384,8 +1421,8 @@
- (void)selectAll:(id)sender
{
- [_slices makeObjectsPerformSelector:@selector(_setSelected:)
withObject:YES];
- [_slices makeObjectsPerformSelector:@selector(setNeedsDisplay:)
withObject:YES];
+ [_slices makeObjectsPerformSelector:@selector(_setSelected:)
withObject:1];
+ [_slices makeObjectsPerformSelector:@selector(setNeedsDisplay:)
withObject:1];
}
- (CPIndexSet)selectedRowIndexes
@@ -1418,13 +1455,16 @@
return [_ruleDelegate ruleEditor:self displayValueForCriterion:item
inRow:row];
}
-/* MISC */
-- (void)drawInContext:(CGContext)context
+
+- (void)drawRect:(CPRect)rect
{
-CPLogConsole(_cmd);
- CGContextSetFillColor(context, [CPColor redColor]);
- CGContextFillRect(context, [self bounds]);
+CPLogConsole(_cmd+" In "+[self className]);
+var context = [CPGraphicsContext currentContext];
+
+ CGContextSetFillColor(context,[CPColor redColor]);
+ // CGContextFillRect(context,[self bounds]);
+
[self _drawSliceBackgroundsWithClipRect:rect];
}
@@ -1455,6 +1495,9 @@
- (void)bind:(CPString)binding toObject:(id)observableController
withKeyPath:(CPString)keyPath options:(CPDictionary)options
{
+ if([observableController respondsToSelector:@selector(objectClass)])
+ _rowClass = [observableController objectClass];
+
if ([binding isEqualToString:@"rows"])
[self _setBoundDataSource:observableController withKeyPath:keyPath
options:options];
}
@@ -1513,14 +1556,19 @@
- (void)setFormattingStringsFilename:(CPString)value
{
if (_stringsFilename != value)
- _stringsFilename = value;
+ {
+ _stringsFilename = value;
+ var strings = [CPString stringWithContentsOfURL:value];
+ _standardLocalizer = [[Localizer alloc] initWithStrings:strings];
+ }
}
- (void)mouseDragged:(CPEvent)event
{
var point = [self convertPoint:[event locationInWindow] fromView:nil];
var view = [self hitTest:point];
- CPLogConsole(@"Drag from %@",CPStringFromPoint(point));
+
+ CPLogConsole("Drag from "+CPStringFromPoint(point));
if ([self _dragShouldBeginFromMouseDown:view])
[self _performDragForSlice:view withEvent:event];
}
@@ -1530,8 +1578,65 @@
return (editable && [view isKindOfClass:[CPRuleEditorViewSliceRow
class]]);
}
+
+- (CPDragOperation)draggingEntered:(id < CPDraggingInfo >)sender
+{
+CPLogConsole(_cmd);
+ if ([sender draggingSource] == self){
+ [self _clearDropLine];
+ return CPDragOperationGeneric;
+ }
+
+ return CPDragOperationNone;
+}
+
+- (void)draggingExited:(id)sender
+{
+CPLogConsole(_cmd);
+ [self _clearDropLine];
+ [self setNeedsDisplay:YES];
+}
+
+
+- (void)_clearDropLine
+{
+CPLogConsole(_cmd);
+ var dropLineRect = [_dropLineView frame];
+ dropLineRect.origin.y = -5;
+ [_dropLineView setFrame:dropLineRect];
+}
+
+- (CPDragOperation)draggingUpdated:(id <CPDraggingInfo>)sender
+{
+CPLogConsole(_cmd);
+ var point = [self convertPoint:[sender draggingLocation] fromView:nil];
+ var y = point.y + _sliceHeight /2;
+ var indexOfDropLine = floor(y / _sliceHeight);
+
+ if (indexOfDropLine < 0 || indexOfDropLine > [self numberOfRows])
+ return CPDragOperationNone;
+
+ var current_index = [_draggingRows firstIndex];
+ while (current_index != CPNotFound) {
+
+ if (indexOfDropLine == 0 || indexOfDropLine == current_index ||
indexOfDropLine == current_index + 1)
+ {
+ [self _clearDropLine];
+ return CPDragOperationNone;
+ }
+ current_index = [_draggingRows indexGreaterThanIndex:current_index];
+ }
+
+ var dropLineRect = [_dropLineView frame];
+ dropLineRect.origin.y = indexOfDropLine * _sliceHeight;
+ [_dropLineView setFrame:dropLineRect];
+
+ return CPDragOperationMove;
+}
+
- (BOOL)_performDragForSlice:(id)slice withEvent:(CPEvent)event
{
+CPLogConsole(_cmd);
var size;
var dragPoint, pt;
@@ -1541,11 +1646,11 @@
if ([selected_indices containsIndex:mainRowIndex])[draggingRows
addIndexes:selected_indices];
_draggingRows = [self _includeSubslicesForSlicesAtIndexes:draggingRows];
-
+CPLogConsole(_draggingRows);
var pasteboard = [CPPasteboard pasteboardWithName: CPDragPboard];
[pasteboard declareTypes:[CPArray arrayWithObjects:
CPRuleEditorItemPBoardType, nil] owner: self];
-
+/*
var dragImage = [self _dragImageForIndices:_draggingRows];
dragPoint = CPMakePoint(0, ([_draggingRows lastIndex] + 1) *
_sliceHeight);
@@ -1557,7 +1662,7 @@
pasteboard: pasteboard
source: self
slideBack: YES];
-
+*/
return YES;
}
@@ -1591,29 +1696,6 @@
{
}
-- (CPDragOperation)draggingEntered:(id < CPDraggingInfo >)sender
-{
- if ([sender draggingSource] == self){
- [self _clearDropLine];
- return CPDragOperationGeneric;
- }
-
- return CPDragOperationNone;
-}
-
-- (void)_clearDropLine
-{
- var dropLineRect = [_dropLineView frame];
- dropLineRect.origin.y = -5;
- [_dropLineView setFrame:dropLineRect];
-}
-
-- (void)draggingExited:(id)sender
-{
- [self _clearDropLine];
- [self setNeedsDisplay:YES];
-}
-
- (BOOL)performDragOperation:(id)sender
{
CPLogConsole(@"ROW CACHE BEFORE %@", [_rowCache description]);
@@ -1637,32 +1719,6 @@
return CPDragOperationNone;
}
-- (CPDragOperation)draggingUpdated:(id <CPDraggingInfo>)sender
-{
- var point = [self convertPoint:[sender draggingLocation] fromView:nil];
- var y = point.y + _sliceHeight /2;
- var indexOfDropLine = floor(y / _sliceHeight);
-
- if (indexOfDropLine < 0 || indexOfDropLine > [self numberOfRows])
- return CPDragOperationNone;
-
- var current_index = [_draggingRows firstIndex];
- while (current_index != CPNotFound) {
-
- if (indexOfDropLine == 0 || indexOfDropLine == current_index ||
indexOfDropLine == current_index + 1)
- {
- [self _clearDropLine];
- return CPDragOperationNone;
- }
- current_index = [_draggingRows indexGreaterThanIndex:current_index];
- }
-
- var dropLineRect = [_dropLineView frame];
- dropLineRect.origin.y = indexOfDropLine * _sliceHeight;
- [_dropLineView setFrame:dropLineRect];
-
- return CPDragOperationMove;
-}
- (int)_updateDragging:(id)fp8
{
@@ -1693,7 +1749,7 @@
- (void)_postRuleOptionChangedNotification
{
- [[CPNotificationCenter defaultCenter]
postNotificationName:@"CPRuleEditorRulesDidChangeNotification" object:self];
+ [[CPNotificationCenter defaultCenter]
postNotificationName:CPRuleEditorRulesDidChangeNotification object:self];
}
/* DRAGGING PROTOCOL
@@ -1777,9 +1833,7 @@
- (void)setFormattingDictionary:(id)dict
{
}
-- (void)setFormattingStringsFileName:(id)name
-{
-}
+
- (void)_recursiveGenerateFormattingDictionaryPlistForItem:(id)item
rowType:(unsigned int)type intoArray:(id)array
withPriorValues:(id)priorValues hasSiblings:(BOOL)hasSiblings
{
}
Modified: branches/CPRuleEditor/CPRuleEditorViewSlice.j
==============================================================================
--- branches/CPRuleEditor/CPRuleEditorViewSlice.j (original)
+++ branches/CPRuleEditor/CPRuleEditorViewSlice.j Sun Feb 1 01:39:03 2009
@@ -9,7 +9,7 @@
CPRuleEditor _ruleEditor;
CPColor _backgroundColor;
int _indentation;
- CGRect _animationTargetRect;
+ CPRect _animationTargetRect;
BOOL selected;
BOOL lastSelected;
@@ -29,7 +29,7 @@
{
self = [super initWithCoder:coder];
if (self != nil) {
- [self setBackgroundColor:[CPColor grayColor]];
+
}
return self;
}
@@ -44,9 +44,8 @@
if (self = [super initWithFrame:frame]){
_ruleEditor = editor;
- selected = NO;
- lastSelected = NO;
- [self setBackgroundColor:[CPColor grayColor]];
+ selected = 0;
+ lastSelected = 0;
}
return self;
@@ -76,18 +75,18 @@
{
return selected;
}
-/*
-- (CPColor)backgroundColor
+
+- (CPColor)bgColor
{
return _backgroundColor ;
}
-- (void)setBackgroundColor:(CPColor)color
+- (void)setBgColor:(CPColor)color
{
if (_backgroundColor != color)
_backgroundColor = color;
}
-*/
+
- (int)indentation
{
return _indentation;
@@ -108,51 +107,51 @@
_rowIndex = value;
}
-- (void)_setAnimationTargetRect:(CGRect)rect
+- (void)_setAnimationTargetRect:(CPRect)rect
{
_animationTargetRect = rect;
}
-- (CGRect)_animationTargetRect
+- (CPRect)_animationTargetRect
{
return _animationTargetRect;
}
-/*
+
+
-(void)drawRect:(CPRect)rect{
+
+ var context = [[CPGraphicsContext currentContext] graphicsPort];
+ var bgColor;
if ([self _isSelected])
{
var isKey = [[self window] isKeyWindow];
-
- [(isKey) ? [_ruleEditor _selectedActiveRowColor]:[_ruleEditor
_selectedInactiveRowColor] set];
- CPRectFill(rect);
- }
+ bgColor = [(isKey) ? [_ruleEditor
_selectedActiveRowColor]:[_ruleEditor _selectedInactiveRowColor]];
+ }else
+ bgColor = [CPColor colorWithCalibratedWhite:0.91 alpha:1];
+
+ CGContextSetFillColor(context,bgColor);
+ CGContextFillRect(context,rect);
var drawrect = CGRectMake(0, 0, [self frame].size.width, 1);
-
- CPLogConsole([_ruleEditor _sliceLastBottomBorderColor]);
- CPLogConsole([_ruleEditor _sliceBottomBorderColor]);
if([self rowIndex] == [_ruleEditor numberOfRows] - 1)
- [[_ruleEditor _sliceLastBottomBorderColor] set];
+ CGContextSetFillColor(context,[_ruleEditor
_sliceLastBottomBorderColor]);
else
- [[_ruleEditor _sliceBottomBorderColor] set];
-
-
+ CGContextSetFillColor(context,[_ruleEditor _sliceBottomBorderColor]);
- CPLogConsole(_cmd);
-
+ CGContextFillRect(context,drawrect);
+
drawrect.origin.y += [self frame].size.height -1;
- [[_ruleEditor _sliceTopBorderColor] set];
-
- CPLogConsole(_cmd);
+ CGContextSetFillColor(context,[_ruleEditor _sliceTopBorderColor]);
+ CGContextFillRect(context,drawrect);
+ CPLogConsole(_cmd+[self className]);
}
-*/
- (void)mouseDown:(CPEvent)theEvent
{
- [_ruleEditor _mouseDownOnSlice:self withEvent:theEvent];
+ // [_ruleEditor _mouseDownOnSlice:self withEvent:theEvent];
}
/*
- (void)rightMouseDown:(CPEvent)theEvent
Modified: branches/CPRuleEditor/CPRuleEditorViewSliceRow.j
==============================================================================
--- branches/CPRuleEditor/CPRuleEditorViewSliceRow.j (original)
+++ branches/CPRuleEditor/CPRuleEditorViewSliceRow.j Sun Feb 1 01:39:03
2009
@@ -59,7 +59,7 @@
_buttonframe.origin.x -= CONTROL_HEIGHT + [self
_rowButtonsInterviewHorizontalPadding];
[_subtractButton setFrame:_buttonframe];
- [self setAutoresizingMask:CPViewWidthSizable & CPViewMinXMargin];
+ [self setAutoresizingMask:CPViewWidthSizable | CPViewMinXMargin];
if ([_ruleEditor isEditable])
{
@@ -101,26 +101,30 @@
- (CPMenuItem )_createMenuItemWithTitle:(CPString )title
{
- //var loc_title = CPLocalizedStringFromTable(title,[_ruleEditor
formattingStringsFilename],nil);
- return [[CPMenuItem alloc] initWithTitle:title action:0
keyEquivalent:@""];
+ var loc_title = [[_ruleEditor standardLocalizer]
localizedStringForString:title];
+
+CPLogConsole("TITLE="+title+" loc = "+[_ruleEditor
standardLocalizer]+"loc_title="+loc_title);
+
+ return [[CPMenuItem alloc] initWithTitle:loc_title action:0
keyEquivalent:@""];
}
- (CPPopUpButton )_createPopUpButtonWithItems:(CPArray )itemsArray
selectedItemIndex:(int)index
-{CPLogConsole([itemsArray description] );
+{
// [RuleEditorViewSliceRow _minimumVerticalPopupPadding]
+ var title = [[itemsArray objectAtIndex:index] title];
+ var size = [title sizeWithFont:[CPFont systemFontOfSize:12]];
- var popup = [[CPRuleEditorPopupButton alloc]
initWithFrame:CGRectMakeZero()];
- var menu = [[CPMenu alloc] initWithTitle:@""];
-
- [popup setFrame:CPMakeRect(0, ([_ruleEditor rowHeight] - [popup
frame].size.height)/2, 100, CONTROL_HEIGHT)];
+ var rect = CPMakeRect(0, ([_ruleEditor rowHeight] - CONTROL_HEIGHT)/2,
size.width +30, CONTROL_HEIGHT);
+
+ var popup = [[CPRuleEditorPopupButton alloc] initWithFrame:rect];
+ [popup setBezelStyle:CPRoundRectBezelStyle];
+ var menu = [[CPMenu alloc] initWithTitle:@""];
for (var i=0;i<[itemsArray count];i++)
[menu addItem:[itemsArray objectAtIndex:i]];
-
[popup setMenu:menu];
[popup selectItemAtIndex:index];
-// [popup sizeToFit]; UNIMPLEMENTED ?
return popup;
}
@@ -155,7 +159,6 @@
- (void)_ruleOptionPopupChangedAction:(CPMenuItem )popup
{
-CPLogConsole(sender);
// HACK BUG
var sender = [popup selectedItem];
var layoutdict = [sender representedObject];
@@ -168,6 +171,7 @@
if (newItem != oldItem)
{
[_correspondingRuleItems replaceObjectAtIndex:indexInCriteria
withObject:newItem];
+ CPLogConsole(_cmd);
[_ruleEditor _changedItem:oldItem toItem:newItem inRow:[self rowIndex]
atCriteriaIndex:indexInCriteria];
}
}
Modified: branches/CPRuleEditor/RuleDelegate.j
==============================================================================
--- branches/CPRuleEditor/RuleDelegate.j (original)
+++ branches/CPRuleEditor/RuleDelegate.j Sun Feb 1 01:39:03 2009
@@ -4,41 +4,6 @@
var CPRuleEditorPredicateKeys = new
Array(CPRuleEditorPredicateLeftExpression,CPRuleEditorPredicateRightExpression,CPRuleEditorPredicateComparisonModifier,CPRuleEditorPredicateOptions,CPRuleEditorPredicateOperatorType,CPRuleEditorPredicateCustomSelector,CPRuleEditorPredicateCompoundType);
-@implementation CPDictionary (ReadFile)
-
-+(id)dictionaryWithContentsOfURL:(CPURL)url
-{
-
- var request = [CPURLRequest requestWithURL:url];
- var data = [CPURLConnection sendSynchronousRequest:request
returningResponse:NULL error:NULL];
- if (data)
- {
- var dict = [CPPropertyListSerialization propertyListFromData:data
format:CPPropertyListXMLFormat_v1_0 errorDescription:NULL];
- return dict;
- }
-
- return nil;
-}
-
-@end
-
-@implementation CPArray (ReadFile)
-
-+(id)arrayWithContentsOfURL:(CPURL)url
-{
-
- var request = [CPURLRequest requestWithURL:url];
- var data = [CPURLConnection sendSynchronousRequest:request
returningResponse:NULL error:NULL];
- if (data)
- {
- var array = [CPPropertyListSerialization propertyListFromData:data
format:CPPropertyListXMLFormat_v1_0 errorDescription:NULL];
- return array;
- }
-
- return nil;
-}
-
-@end
@implementation RuleDelegate : CPObject
{
@@ -102,8 +67,10 @@
if (view == nil)
{
var custom_class = CPClassFromString(custom_control_class);
- view = [[custom_class alloc] initWithFrame:CGRectMakeZero()];
-
+ view = [[custom_class alloc] initWithFrame:CGRectMake(0,0,100,18)];
+ [view setBackgroundColor:[CPColor whiteColor]];
+ [view setEditable:YES];
+ [view setObjectValue:"truc"];
[criterion setObject:view forKey:viewkey];
}
return view;
@@ -115,7 +82,6 @@
- (CPDictionary)ruleEditor:(RuleEditor)editor
predicatePartsForCriterion:(id)criterion withDisplayValue:(id)value
inRow:(int)row
{
-CPLogConsole(_cmd);
var predicatePartsForCriterion = [CPDictionary dictionary];
if ([editor rowTypeForRow:row] == CPRuleEditorRowTypeCompound)
@@ -124,13 +90,13 @@
if (compound_type)[predicatePartsForCriterion setObject:compound_type
forKey:CPRuleEditorPredicateCompoundType];
return predicatePartsForCriterion;
}
-
+
var i;
for (i = 0 ;i< 7;i++)
{
var key = CPRuleEditorPredicateKeys[i];
var predicatePart = nil ;
-
+
if ([key isEqualToString:CPRuleEditorPredicateLeftExpression])
{
var str = [criterion objectForKey:key];
@@ -143,7 +109,7 @@
transformedValue = ([value isKindOfClass:[CPView class]]) ? [value
objectValue]:value;
else
transformedValue = [criterion objectForKey:key];
- predicatePart = [CPExpression
expressionForCoCPtantValue:transformedValue];
+ predicatePart = [CPExpression
expressionForConstantValue:transformedValue];
}
else if ([key isEqualToString:CPRuleEditorPredicateOperatorType])
{
@@ -170,7 +136,7 @@
- (void)ruleEditorRowsDidChange:(CPNotification)notification
{
- // CPLog(@"ruleEditorRowsDidChange:%@",[notification description]);
+ CPLogConsole(_cmd);
}
@end
Modified: branches/CPRuleEditor/RuleEditor.steam
==============================================================================
--- branches/CPRuleEditor/RuleEditor.steam (original)
+++ branches/CPRuleEditor/RuleEditor.steam Sun Feb 1 01:39:03 2009
@@ -3,12 +3,12 @@
<plist version="1.0">
<dict>
<key>Name</key>
- <string>CPRuleEditorTest</string>
+ <string>RuleEditor</string>
<key>Targets</key>
<array>
<dict>
<key>Name</key>
- <string>CPRuleEditorTest</string>
+ <string>RuleEditor</string>
</dict>
</array>
<key>Configurations</key>
Modified: branches/CPRuleEditor/_CPRuleEditorViewSliceHolder.j
==============================================================================
--- branches/CPRuleEditor/_CPRuleEditorViewSliceHolder.j (original)
+++ branches/CPRuleEditor/_CPRuleEditorViewSliceHolder.j Sun Feb 1
01:39:03 2009
@@ -14,7 +14,6 @@
self = [super initWithFrame:frame];
if (self != nil)
{
- [self setBackgroundColor:[CPColor lightGrayColor]];
}
return self;
@@ -22,6 +21,7 @@
- (void)addSubview:(CPView)subview
{
+ [self setNeedsDisplay:YES];
[super addSubview:subview];
}
@@ -30,9 +30,12 @@
return YES;
}
--(void)drawRect:(CPRect)rect
+
+- (void)drawRect:(CPRect)rect
{
-[[self superview] drawRect:rect];
+ CPLogConsole(_cmd+" In "+[self className]);
+
+ [[self superview] drawRect:rect];
}
@end
Modified: branches/CPRuleEditor/criteria.plist
==============================================================================
--- branches/CPRuleEditor/criteria.plist (original)
+++ branches/CPRuleEditor/criteria.plist Sun Feb 1 01:39:03 2009
@@ -7,8 +7,8 @@
<key>subrows</key>
<array>
<dict>
- <key>NSRuleEditorPredicateCompoundType</key>
- <integer>1</integer>
+ <key>CPRuleEditorPredicateCompoundType</key>
+ <integer>2</integer>
<key>criteria</key>
<array>
<dict>
@@ -17,11 +17,11 @@
</dict>
</array>
<key>valeur</key>
- <string>All</string>
+ <string>Any</string>
</dict>
<dict>
- <key>NSRuleEditorPredicateCompoundType</key>
- <integer>2</integer>
+ <key>CPRuleEditorPredicateCompoundType</key>
+ <integer>1</integer>
<key>criteria</key>
<array>
<dict>
@@ -30,7 +30,7 @@
</dict>
</array>
<key>valeur</key>
- <string>Any</string>
+ <string>All</string>
</dict>
</array>
</dict>
@@ -39,90 +39,141 @@
<key>subrows</key>
<array>
<dict>
- <key>NSRuleEditorPredicateLeftExpression</key>
- <string>name</string>
+ <key>CPRuleEditorPredicateLeftExpression</key>
+ <string>firstName</string>
<key>criteria</key>
<array>
<dict>
- <key>NSRuleEditorPredicateComparisonModifier</key>
+ <key>CPRuleEditorPredicateComparisonModifier</key>
<integer>0</integer>
- <key>NSRuleEditorPredicateOperatorType</key>
- <integer>6</integer>
- <key>NSRuleEditorPredicateOptions</key>
+ <key>CPRuleEditorPredicateOperatorType</key>
+ <integer>8</integer>
+ <key>CPRuleEditorPredicateOptions</key>
<integer>0</integer>
<key>criteria</key>
<array>
<dict>
- <key>CPRuleEditorCustomControlClass</key>
- <string>CPTextField</string>
+ <key>CPRuleEditorPredicateRightExpression</key>
+ <string>k</string>
+ <key>valeur</key>
+ <string>k</string>
</dict>
</array>
<key>valeur</key>
<string>CPBeginsWithPredicateOperatorType</string>
</dict>
<dict>
- <key>NSRuleEditorPredicateComparisonModifier</key>
+ <key>CPRuleEditorPredicateComparisonModifier</key>
<integer>0</integer>
- <key>NSRuleEditorPredicateOperatorType</key>
- <integer>6</integer>
- <key>NSRuleEditorPredicateOptions</key>
+ <key>CPRuleEditorPredicateOperatorType</key>
+ <integer>9</integer>
+ <key>CPRuleEditorPredicateOptions</key>
<integer>0</integer>
<key>criteria</key>
<array>
<dict>
<key>CPRuleEditorCustomControlClass</key>
<string>CPTextField</string>
+ <key>valeur</key>
+ <string>mov</string>
</dict>
</array>
<key>valeur</key>
- <string>CPBeginsWithPredicateOperatorType</string>
+ <string>CPEndsWithPredicateOperatorType</string>
</dict>
</array>
<key>valeur</key>
- <string>name</string>
+ <string>firstName</string>
</dict>
<dict>
- <key>NSRuleEditorPredicateLeftExpression</key>
- <string>age</string>
+ <key>CPRuleEditorPredicateLeftExpression</key>
+ <string>lastName</string>
<key>criteria</key>
<array>
<dict>
- <key>NSRuleEditorPredicateComparisonModifier</key>
+ <key>CPRuleEditorPredicateComparisonModifier</key>
<integer>0</integer>
- <key>NSRuleEditorPredicateOperatorType</key>
+ <key>CPRuleEditorPredicateOperatorType</key>
+ <integer>9</integer>
+ <key>CPRuleEditorPredicateOptions</key>
<integer>0</integer>
- <key>NSRuleEditorPredicateOptions</key>
+ <key>criteria</key>
+ <array>
+ <dict>
+ <key>CPRuleEditorPredicateRightExpression</key>
+ <string>e</string>
+ <key>valeur</key>
+ <string>e</string>
+ </dict>
+ </array>
+ <key>valeur</key>
+ <string>CPEndsWithPredicateOperatorType</string>
+ </dict>
+ <dict>
+ <key>CPRuleEditorPredicateComparisonModifier</key>
+ <integer>0</integer>
+ <key>CPRuleEditorPredicateOperatorType</key>
+ <integer>8</integer>
+ <key>CPRuleEditorPredicateOptions</key>
<integer>0</integer>
<key>criteria</key>
<array>
<dict>
- <key>NSRuleEditorPredicateRightExpression</key>
- <integer>45</integer>
+ <key>CPRuleEditorPredicateRightExpression</key>
+ <string>O</string>
<key>valeur</key>
- <string>45 ans</string>
+ <string>O</string>
</dict>
</array>
<key>valeur</key>
- <string>CPLessThanPredicateOperatorType</string>
+ <string>CPBeginsWithPredicateOperatorType</string>
</dict>
+ </array>
+ <key>valeur</key>
+ <string>lastName</string>
+ </dict>
+ <dict>
+ <key>CPRuleEditorPredicateLeftExpression</key>
+ <string>age</string>
+ <key>criteria</key>
+ <array>
<dict>
- <key>NSRuleEditorPredicateComparisonModifier</key>
+ <key>CPRuleEditorPredicateComparisonModifier</key>
<integer>0</integer>
- <key>NSRuleEditorPredicateOperatorType</key>
- <integer>1</integer>
- <key>NSRuleEditorPredicateOptions</key>
+ <key>CPRuleEditorPredicateOperatorType</key>
+ <integer>3</integer>
+ <key>CPRuleEditorPredicateOptions</key>
<integer>0</integer>
<key>criteria</key>
<array>
<dict>
- <key>NSRuleEditorPredicateRightExpression</key>
+ <key>CPRuleEditorPredicateRightExpression</key>
<integer>50</integer>
<key>valeur</key>
<string>50 ans</string>
</dict>
</array>
<key>valeur</key>
- <string>NSLessThanOrEqualToPredicateOperatorType</string>
+ <string>CPGreaterThanOrEqualToPredicateOperatorType</string>
+ </dict>
+ <dict>
+ <key>CPRuleEditorPredicateComparisonModifier</key>
+ <integer>0</integer>
+ <key>CPRuleEditorPredicateOperatorType</key>
+ <integer>1</integer>
+ <key>CPRuleEditorPredicateOptions</key>
+ <integer>0</integer>
+ <key>criteria</key>
+ <array>
+ <dict>
+ <key>CPRuleEditorPredicateRightExpression</key>
+ <integer>45</integer>
+ <key>valeur</key>
+ <string>45 ans</string>
+ </dict>
+ </array>
+ <key>valeur</key>
+ <string>CPLessThanPredicateOperatorType</string>
</dict>
</array>
<key>valeur</key>