Removed:
branches/CPRuleEditor/CPComparisonPredicate.j
branches/CPRuleEditor/CPCompoundPredicate.j
branches/CPRuleEditor/CPExpression.j
branches/CPRuleEditor/CPExpression_aggregate.j
branches/CPRuleEditor/CPExpression_assignment.j
branches/CPRuleEditor/CPExpression_constant.j
branches/CPRuleEditor/CPExpression_function.j
branches/CPRuleEditor/CPExpression_intersectset.j
branches/CPRuleEditor/CPExpression_keypath.j
branches/CPRuleEditor/CPExpression_minusset.j
branches/CPRuleEditor/CPExpression_operator.j
branches/CPRuleEditor/CPExpression_self.j
branches/CPRuleEditor/CPExpression_unionset.j
branches/CPRuleEditor/CPExpression_variable.j
branches/CPRuleEditor/CPPredicate.j
branches/CPRuleEditor/CPPredicateTest.j
branches/CPRuleEditor/RuleEditor.steam
Modified:
branches/CPRuleEditor/AppController.j
branches/CPRuleEditor/CPRuleEditor.j
branches/CPRuleEditor/CPRuleEditorLocalizer.j
branches/CPRuleEditor/CPRuleEditorTextField.j
branches/CPRuleEditor/CPRuleEditorViewSlice.j
branches/CPRuleEditor/CPRuleEditorViewSliceHolder.j
branches/CPRuleEditor/CPRuleEditorViewSliceRow.j
branches/CPRuleEditor/CPViewAnimation.j
branches/CPRuleEditor/Info.plist
branches/CPRuleEditor/RowObject.j
branches/CPRuleEditor/criteria.plist
branches/CPRuleEditor/format.strings
Log:
improvements
Modified: branches/CPRuleEditor/AppController.j
==============================================================================
--- branches/CPRuleEditor/AppController.j (original)
+++ branches/CPRuleEditor/AppController.j Wed Feb 11 10:15:40 2009
@@ -53,47 +53,140 @@
@end
+@implementation CPUserDefaults : CPObject
+{
+}
+var _database;
+
++(id)standardUserDefaults
+{
+if(_database == nil)
+{
+ try {
+ if (!window.openDatabase)
+ CPLogConsole("not supported");
+ else {
+ var shortName = 'Ma Database';
+ var version = '1.0';
+ var displayName = 'My Important Database';
+ var maxSize = 65536; // in bytes
+ var mydb = openDatabase(shortName, version, displayName, maxSize);
+ _database = mydb;
+ createTables(_database);
+ // You should have a database instance in mydb.
+ }
+} catch(e) {
+ // Error handling code goes here.
+ if (e == "INVALID_STATE_ERR")
+ // Version number mismatch.
+ CPLogConsole("Invalid database version.");
+ else
+ CPLogConsole("Unknown error "+e+".");
+
+ _database = nil;
+ }
+}
+
+return _database;
+}
+
+-(id)setObject:(id)object forKey:(CPString)key
+{
+var name = key;
+var shirt = object;
+
+ _database.transaction(
+ function (transaction) {
+ transaction.executeSql("UPDATE people set shirt=? where name=?;",[
shirt, name ]); // array of values for the ? placeholders
+ }
+);
+
+}
+
+
+function nullDataHandler(transaction, results) { }
+
+var createTables = function createTables(db)
+{
+ db.transaction(
+ function (transaction) {
+ CPLogConsole("createTables");
+ /* The first query causes the transaction to (intentionally)
fail if the table exists. */
+ transaction.executeSql('CREATE TABLE people(id INTEGER NOT
NULL PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL DEFAULT "John Doe",
shirt TEXT NOT NULL DEFAULT "Purple");', [], nullDataHandler, errorHandler);
+ /* These insertions will be skipped if the table already
exists. */
+ transaction.executeSql('insert into people (name, shirt)
VALUES ("Joe", "Green");', [], nullDataHandler, errorHandler);
+ }
+ );
+}
+
+@end
+
@implementation AppController : CPObject
{
-CPTextField textField;
-CPTextField tableField;
-CPArray tableArray;
-CPRuleEditor ruleEditor;
+ CPTextField textField;
+ CPTextField tableField;
+ CPArray tableArray;
+ CPRuleEditor ruleEditor;
+ CPArray rows;
}
-- (void)applicationDidFinishLaunching:(CPNotification)aNotification
+- (id) init
+{
+ self = [super init];
+ if (self != nil) {
+ rows = [[CPArray alloc] init];
+ }
+ return self;
+}
+
+
+- (void)save:(id)sender
{
-
+ alert(_cmd);
+ var rows_data = [CPKeyedArchiver archivedDataWithRootObject:rows];
+
+ var cookie = [[CPCookie alloc] initWithName:@"rows"];
+ [cookie setValue:rows_data expires:nil domain:nil];
+}
+
+- (void)applicationDidFinishLaunching:(CPNotification)aNotification
+{
CPLogRegister(CPLogConsole);
+
+ [[CPNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowWillClose:) name:CPWindowWillCloseNotification
object:nil];
-var next = [["a","b","c"] nextUnusedObjectIn:["a","a","b","c"]];
-CPLogConsole("NEXT ="+next);
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero()
styleMask:CPBorderlessBridgeWindowMask],
contentView = [theWindow contentView];
ruleEditor = [[CPRuleEditor alloc]
initWithFrame:CGRectMake(0,0,600,200)];
- [ruleEditor setAutoresizingMask:CPViewMaxXMargin ];
+ [ruleEditor addObserver:self forKeyPath:"predicate"
options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew
context:"predicate"];
var datasource = [[RuleDelegate alloc] init];
[ruleEditor setDelegate:datasource];
[ruleEditor setNestingMode:CPRuleEditorNestingModeSimple];
- CPLogConsole(_cmd);
+ [ruleEditor setAutoresizingMask:CPViewMaxXMargin ];
[ruleEditor setFormattingStringsFilename:"format.strings"];
- [ruleEditor setCanRemoveAllRows:NO];
-
+ [ruleEditor setCanRemoveAllRows:NO];
+
+ [ruleEditor bind:@"rows" toObject:self withKeyPath:@"rows" options:nil];
[contentView addSubview:ruleEditor];
- [ruleEditor addObserver:self forKeyPath:"predicate"
options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew
context:"predicate"];
[ruleEditor addRow:self];
var button = [[CPButton alloc]
initWithFrame:CGRectMake(610,20,100,20)];
+ [button setTarget:self];
[button setAction:@selector(reloadPredicate:)];
- [button setButtonType:CPPushOnPushOffButton];
- [button setTarget:self];
[button setTitle:"Reload Predicate"];
[contentView addSubview:button];
+/*
+ var button = [[CPButton alloc] initWithFrame:CGRectMake(610,50,100,20)];
+ [button setTarget:self];
+ [button setAction:@selector(save:)];
+ [button setTitle:"Save"];
+ [contentView addSubview:button];
+*/
tableArray = [CPArray arrayWithObjects:[CPDictionary
dictionaryWithObjects:["Jim ","McNulty",46]
forKeys:["firstName","lastName","age"]],
[CPDictionary dictionaryWithObjects:["Kima","Greggs",41]
forKeys:["firstName","lastName","age"]],
@@ -130,13 +223,25 @@
[contentView addSubview:tableView];
*/
[theWindow orderFront:self];
-
- }
+ var head = document.getElementsByTagName("head");
+ var style = document.createElement("style");
+ style.innerText = "@-webkit-keyframes bounce { from {top: 0px;} to
{top: 20px;} }\
+ .animate {\
+ -webkit-animation-name: 'bounce';\
+ -webkit-animation-timing-function: ease-in-out;\
+ -webkit-animation-duration: 2s;\
+ }";
+
+ head[0].appendChild(style);
+
+ CPLogConsole(12 % 5);
+}
-(void)numberOfColumns
{
return [tableArray count];
}
+
-(void)tableView:table objectValueForTableColumn:column row:row
{
return [[tableArray objectAtIndex:row] objectForKey:[column identifier]];
@@ -145,8 +250,17 @@
- (void)reloadPredicate:(id)sender
{
[ruleEditor reloadPredicate];
+/*
+ var ended = function() {
+ sender._DOMElement.className = '';
+ }
+
+ sender._DOMElement.className = "animate";
+ sender._DOMElement.addEventListener('webkitAnimationEnd', ended);
+*/
}
+
-(void)observeValueForKeyPath:keypath ofObject:object change:change
context:context
{
if(context = "predicate")
Modified: branches/CPRuleEditor/CPRuleEditor.j
==============================================================================
--- branches/CPRuleEditor/CPRuleEditor.j (original)
+++ branches/CPRuleEditor/CPRuleEditor.j Wed Feb 11 10:15:40 2009
@@ -3,7 +3,7 @@
* Copyright (c) 2008 Pear, Inc. All rights reserved.
*/
-@import "CPPredicate.j"
+@import <Foundation/CPPredicate.j>
@import "CPRuleEditorCache.j"
@import "CPRuleEditorViewSliceHolder.j"
@import "CPRuleEditorViewUnboundRowHolder.j"
@@ -11,15 +11,14 @@
@import "CPRuleEditorViewSliceRow.j"
@import "RowObject.j"
@import "CPRuleEditorLocalizer.j"
-@import "CPViewAnimation.j"
- CPDragOperationNone = 0;
- CPDragOperationCopy = 1;
- CPDragOperationLink = 2;
- CPDragOperationGeneric = 4;
- CPDragOperationPrivate = 8;
- CPDragOperationMove = 16;
- CPDragOperationDelete = 32;
+CPDragOperationNone = 0;
+CPDragOperationCopy = 1;
+CPDragOperationLink = 2;
+CPDragOperationGeneric = 4;
+CPDragOperationPrivate = 8;
+CPDragOperationMove = 16;
+CPDragOperationDelete = 32;
CPRuleEditorPredicateLeftExpression
= "CPRuleEditorPredicateLeftExpression";
CPRuleEditorPredicateRightExpression
= "CPRuleEditorPredicateRightExpression";
@@ -49,46 +48,6 @@
subrowsContext = "subrows_array";
boundArrayContext = "bound_array";
-@implementation CPArray (Additions)
-
--(int)nextUnusedObjectIn:(CPArray)objects
-{
-
- var found = CPNotFound;
- var count = [self count];
- var current_objects = objects;
-
- while(found == CPNotFound)
- {
- CPLogConsole(@"CURRENT OBJECTS"+current_objects);
- var buffer = [CPMutableArray arrayWithArray:current_objects];
- var i;
- for(i=0;i<count;i++)
- {
- var o = [self objectAtIndex:i];
- if(![current_objects containsObject:o])
- {
- found = i;
- break;
- }
- }
- if(found == CPNotFound)
- {
- var k;
- for(k = 0;k <count;k++){
- var anobject = [self objectAtIndex:k];
- var index = [buffer indexOfObject:anobject];
- if(index != CPNotFound)[buffer removeObjectAtIndex:index];
- }
- current_objects = buffer;
- }
- }
-
- return found;
-}
-
-@end
-
@implementation CPRuleEditor : CPView
{
@@ -137,7 +96,7 @@
id _ruleDelegate;
id _boundArrayOwner;
- CPString _stringsFilename;
+ CPString _stringsFileName;
CPRuleEditorLocalizer _headerLocalizer;
CPRuleEditorLocalizer _standardLocalizer;
@@ -170,27 +129,25 @@
self = [super initWithCoder:coder];
if (self != nil) {
// BOOL int float : we should nil check keys first.
- _alignmentGridWidth = [coder
decodeDoubleForKey:@"CPRuleEditorAlignmentGridWidth"];
- _sliceHeight = [coder decodeDoubleForKey:@"CPRuleEditorSliceHeight"];
-
- editable = [coder decodeBoolForKey:@"CPRuleEditorEditable"];
- allowsEmptyCompoundRows = [coder
decodeBoolForKey:@"CPRuleEditorAllowsEmptyCompoundRows"];
- disallowEmpty = [coder decodeBoolForKey:@"CPRuleEditorDisallowEmpty"];
-
- _nestingMode = [coder decodeIntForKey:@"CPRuleEditorNestingMode"];
-
- _typeKeyPath = [coder decodeObjectForKey:@"CPRuleEditorRowTypeKeyPath"];
- _itemsKeyPath = [coder decodeObjectForKey:@"CPRuleEditorItemsKeyPath"];
- _valuesKeyPath = [coder decodeObjectForKey:@"CPRuleEditorValuesKeyPath"];
- _subrowsArrayKeyPath = [coder
decodeObjectForKey:@"CPRuleEditorSubrowsArrayKeyPath"];
- _boundArrayKeyPath = [coder
decodeObjectForKey:@"CPRuleEditorBoundArrayKeyPath"];
-
- _rowClass = CPClassFromString([coder
decodeObjectForKey:@"CPRuleEditorRowClass"]);
- _boundArrayOwner = [coder
decodeObjectForKey:@"CPRuleEditorBoundArrayOwner"];
-
- _slices = [coder decodeObjectForKey:@"CPRuleEditorSlices"]
- // var dragTypes = [coder decodeObjectForKey:@"CPDragTypes"];
-
+ _alignmentGridWidth = [coder
decodeDoubleForKey:@"NSRuleEditorAlignmentGridWidth"];
+ _sliceHeight = [coder decodeDoubleForKey:@"NSRuleEditorSliceHeight"];
+ _stringsFileName = [coder
decodeObjectForKey:@"NSRuleEditorStringsFileName"];
+ editable = [coder decodeBoolForKey:@"NSRuleEditorEditable"];
+ allowsEmptyCompoundRows = [coder
decodeBoolForKey:@"NSRuleEditorAllowsEmptyCompoundRows"];
+ disallowEmpty = [coder decodeBoolForKey:@"NSRuleEditorDisallowEmpty"];
+ _nestingMode = [coder decodeIntForKey:@"NSRuleEditorNestingMode"];
+ _typeKeyPath = [coder decodeObjectForKey:@"NSRuleEditorRowTypeKeyPath"];
+ _itemsKeyPath = [coder decodeObjectForKey:@"NSRuleEditorItemsKeyPath"];
+ _valuesKeyPath = [coder decodeObjectForKey:@"NSRuleEditorValuesKeyPath"];
+ _subrowsArrayKeyPath = [coder
decodeObjectForKey:@"NSRuleEditorSubrowsArrayKeyPath"];
+ _boundArrayKeyPath = [coder
decodeObjectForKey:@"NSRuleEditorBoundArrayKeyPath"];
+ _rowClass = CPClassFromString([coder
decodeObjectForKey:@"NSRuleEditorRowClass"]);
+
+ _slicesHolder = [coder decodeObjectForKey:@"NSRuleEditorSlicesHolder"];
+ //_boundArrayOwner = [[coder
decodeObjectForKey:@"NSRuleEditorBoundArrayOwner"] retain];
+ _slices = [coder decodeObjectForKey:@"NSRuleEditorSlices"];
+ _ruleDelegate = [coder decodeObjectForKey:@"NSRuleEditorDelegate"];
+
[self _initRuleEditorShared];
}
return self;
@@ -199,68 +156,71 @@
- (void)encodeWithCoder:(id)coder
{
[super encodeWithCoder:coder];
-
- [coder encodeBool:editable forKey:@"CPRuleEditorEditable"];
- [coder encodeBool:allowsEmptyCompoundRows
forKey:@"CPRuleEditorAllowsEmptyCompoundRows"];
- [coder encodeBool:disallowEmpty forKey:@"CPRuleEditorDisallowEmpty"];
-
- [coder encodeObject:_typeKeyPath forKey:@"CPRuleEditorRowTypeKeyPath"];
- [coder encodeObject:_itemsKeyPath forKey:@"CPRuleEditorItemsKeyPath"];
- [coder encodeObject:_valuesKeyPath forKey:@"CPRuleEditorValuesKeyPath"];
- [coder encodeObject:_boundArrayKeyPath
forKey:@"CPRuleEditorBoundArrayKeyPath"];
- [coder encodeObject:_subrowsArrayKeyPath
forKey:@"CPRuleEditorSubrowsArrayKeyPath"];
- [coder encodeObject:CPStringFromClass(_rowClass)
forKey:@"CPRuleEditorRowClass"];
-
- [coder encodeObject:_slices forKey:@"CPRuleEditorSlices"];
- [coder encodeObject:_boundArrayOwner
forKey:@"CPRuleEditorBoundArrayOwner"];
+
+ [coder encodeBool:editable forKey:@"NSRuleEditorEditable"];
+ [coder encodeBool:allowsEmptyCompoundRows
forKey:@"NSRuleEditorAllowsEmptyCompoundRows"];
+ [coder encodeBool:disallowEmpty forKey:@"NSRuleEditorDisallowEmpty"];
+
+ [coder encodeObject:_stringsFileName
forKey:@"NSRuleEditorStringsFilename"];
+ [coder encodeObject:_typeKeyPath forKey:@"NSRuleEditorRowTypeKeyPath"];
+ [coder encodeObject:_itemsKeyPath forKey:@"NSRuleEditorItemsKeyPath"];
+ [coder encodeObject:_valuesKeyPath forKey:@"NSRuleEditorValuesKeyPath"];
+ [coder encodeObject:_boundArrayKeyPath
forKey:@"NSRuleEditorBoundArrayKeyPath"];
+ [coder encodeObject:_subrowsArrayKeyPath
forKey:@"NSRuleEditorSubrowsArrayKeyPath"];
+ [coder encodeObject:CPStringFromClass(_rowClass)
forKey:@"NSRuleEditorRowClass"];
+
+ [coder encodeObject:_slicesHolder forKey:@"NSRuleEditorSlicesHolder"];
+ [coder encodeObject:_slices forKey:@"NSRuleEditorSlices"];
+ [coder encodeObject:_boundArrayOwner
forKey:@"NSRuleEditorBoundArrayOwner"];
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self != nil){
- [self _initRuleEditorShared];
+ _rowCache = [[CPMutableArray alloc] init];
+ _slices = [[CPMutableArray alloc] init];
+
+ _nestingMode = CPRuleEditorNestingModeSimple; // 10.5 default =
NSRuleEditorNestingModeCompound
+ _subviewIndexOfDropLine = CPNotFound;
+ _lastRow = 0;
+ editable = 1;
+ delegateWantsValidation = 1;
+ allowsEmptyCompoundRows = 0;
+ disallowEmpty = 0;
+ _sliceHeight = 26;
+
+ [self setRowClass:[RowObject class]];
+ [self setCriteriaKeyPath:@"criteria"];
+ [self setSubrowsKeyPath:@"subrows"];
+ [self setRowTypeKeyPath:@"rowType"];
+ [self setDisplayValuesKeyPath:@"displayValues"];
+ [self setBoundArrayKeyPath:@"boundArray"];
+
+
+ _dropLineView = [self _createSliceDropSeparator];
+ _slicesHolder = [[CPRuleEditorViewSliceHolder alloc] initWithFrame:[self
bounds]];
+ [_slicesHolder setAutoresizingMask:64];
+ [_slicesHolder addSubview:_dropLineView];
+ [self addSubview:_slicesHolder];
+
+ _boundArrayOwner = [[CPRuleEditorViewUnboundRowHolder alloc] init];
+ [_boundArrayOwner addObserver:self forKeyPath:_boundArrayKeyPath
options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew
context:boundArrayContext];
+
+ [self _initRuleEditorShared];
+
}
return self;
}
- (void)_initRuleEditorShared
{
- _currentAnimation = [[CPViewAnimation alloc] initWithDuration:0.5
animationCurve:CPAnimationEaseInOut];
- // [_currentAnimation setAnimationBlockingMode:CPAnimationNonblocking];
-
- _rowCache = [[CPMutableArray alloc] init];
- _slices = [[CPMutableArray alloc] init];
-
- _nestingMode = CPRuleEditorNestingModeSimple; // 10.5 default =
CPRuleEditorNestingModeCompound
- _subviewIndexOfDropLine = -1;
- _lastRow = 0;
- editable = 1;
- delegateWantsValidation = 1;
- allowsEmptyCompoundRows = 0;
- disallowEmpty = 0;
-
- _rowClass = [RowObject class];
- _itemsKeyPath = @"criteria";
- _subrowsArrayKeyPath = @"subrows";
- _typeKeyPath = @"rowType";
- _valuesKeyPath = @"displayValues";
- _boundArrayKeyPath = @"boundArray";
-
- _sliceHeight = 26;
-
- _dropLineView = [self _createSliceDropSeparator];
-
- _slicesHolder = [[CPRuleEditorViewSliceHolder alloc] initWithFrame:[self
bounds]];
- [_slicesHolder setAutoresizingMask:CPViewHeightSizable |
CPViewWidthSizable];
- [_slicesHolder addSubview:_dropLineView];
- [self addSubview:_slicesHolder];
-
- _boundArrayOwner = [[CPRuleEditorViewUnboundRowHolder alloc] init];
- [_boundArrayOwner addObserver:self forKeyPath:_boundArrayKeyPath
options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew
context:boundArrayContext];
-
+ _currentAnimation = [[CPViewAnimation alloc] initWithDuration:0.
animationCurve:CPAnimationEaseInOut];
+ //[_currentAnimation setAnimationBlockingMode:NSAnimationNonblocking];
+ [_currentAnimation setDuration:0.5];
+
[self registerForDraggedTypes:[CPArray
arrayWithObjects:CPRuleEditorItemPBoardType,nil]];
-
+
var center = [CPNotificationCenter defaultCenter];
[center addObserver:self selector:@selector(windowWillClose:)
name:CPWindowWillCloseNotification object:nil];
[center addObserver:self selector:@selector(reloadPredicate)
name:CPRuleEditorRulesDidChangeNotification object:nil];
@@ -270,6 +230,8 @@
{
var view = [[CPRuleEditorViewSliceDropSeparator alloc]
initWithFrame:CGRectMake(0,-10, [self frame].size.width, 2)];
[view setAutoresizingMask:CPViewWidthSizable];
+ view._DOMElement.style.webkitTransition = "opacity 300ms ease-in";
+
return view;
}
@@ -655,21 +617,23 @@
- (void)_setBoundDataSource:(id)datasource withKeyPath:(CPString)keyPath
options:(CPDictionary)options
{
- if (_boundArrayOwner)
+
+ if (_boundArrayOwner != nil)
[_boundArrayOwner removeObserver:self forKeyPath:_boundArrayKeyPath];
[self setBoundArrayKeyPath:keyPath];
-
var boundRows = [CPArray arrayWithArray:[datasource valueForKey:keyPath]];
-
+
[[datasource valueForKey:keyPath] removeAllObjects];
+
_boundArrayOwner = datasource;
[_boundArrayOwner addObserver:self forKeyPath:_boundArrayKeyPath
options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew
context:boundArrayContext];
if ([boundRows count]>0)
[[self _subrowObjectsOfObject:_boundArrayOwner] insertObjects:boundRows
atIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [boundRows
count])]];
-
+
+CPLogConsole(_cmd);
}
-(int)nextUnusedCriterionOfType:(CPRuleEditorRowType)type
@@ -821,6 +785,7 @@
CPLogConsole(_cmd);
// why parentRowIndex is not used here ?
var row = [[[self rowClass] alloc] init];
+
[row setValue:[CPMutableArray array] forKey:_itemsKeyPath];
[row setValue:[CPMutableArray array] forKey:_valuesKeyPath];
[row setValue:[CPNumber numberWithInt:rowtype] forKey:_typeKeyPath];
@@ -831,13 +796,14 @@
#pragma mark Key value observing
-- (void)_startObservingRowObjectsRecursively:(id)rowObjects
+- (void)_startObservingRowObjectsRecursively:(CPArray)rowObjects
{
CPLogConsole(_cmd);
var i;
for (i =0;i <[rowObjects count];i++)
{
var rowObject = rowObjects[i];
+
[rowObject addObserver:self forKeyPath:_itemsKeyPath
options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew
context:itemsContext];
[rowObject addObserver:self forKeyPath:_valuesKeyPath
options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew
context:valuesContext];
[rowObject addObserver:self forKeyPath:_subrowsArrayKeyPath
options:CPKeyValueObservingOptionOld|CPKeyValueObservingOptionNew
context:subrowsContext];
@@ -850,7 +816,7 @@
- (void)_stopObservingRowObjectsRecursively:(id)rowObjects
{
-CPLogConsole(_cmd);
+CPLogConsole(_cmd+rowObjects);
var i;
for (i =0;i <[rowObjects count];i++)
{
@@ -1041,7 +1007,7 @@
}
var changePoint = n;
- var absDeltaCount = MAX(deltaCount,-deltaCount); // WTF is abs()
function ?
+ var absDeltaCount = ABS(deltaCount);
if (deltaCount>0)
{
@@ -1093,7 +1059,7 @@
- (void)_reconfigureSubviewsAnimate:(BOOL)animate
{
[self _updateSliceRows];
-
+
var viewAnimations = [CPMutableArray array];
var added_slices = [CPMutableArray array];
@@ -1101,12 +1067,11 @@
{
var aslice = [_slices objectAtIndex:i];
var targetRect = [aslice _animationTargetRect];
- if ([aslice frame] != targetRect)
+ if(CPRectEqualToRect([aslice frame],targetRect) == NO)
{
if ([aslice superview] == nil)
{
- var addFrame = CGRectMake(0, [aslice rowIndex]*_sliceHeight, [self
frame].size.width, _sliceHeight);
- if (animate)addFrame.origin.y = ([aslice rowIndex]-1)*_sliceHeight;
+ var addFrame = CGRectMake(0, ([aslice rowIndex] -
animate)*_sliceHeight, [self frame].size.width, _sliceHeight);
[aslice setFrame:addFrame];
[aslice _reconfigureSubviews];
@@ -1122,34 +1087,21 @@
}
}
- for (var j= 0;j< [added_slices count];j++)
- {
- var added_slice = [added_slices objectAtIndex:j];
- [added_slice setNeedsDisplay:YES];
- [_slicesHolder addSubview:added_slice positioned:CPWindowBelow
relativeTo:nil];
-
- CPLogConsole("Added slice"+CPStringFromRect([added_slice frame]));
- }
+ var collec = [added_slices objectEnumerator];
+ var s;
+ while (s = [collec nextObject])
+ [_slicesHolder addSubview:s positioned:CPWindowBelow relativeTo:nil];
if (animate)
{
[_currentAnimation setViewAnimations:viewAnimations];
[_currentAnimation startAnimation];
- }else
- {
- for (var k= 0;k< [viewAnimations count];k++)
- {
- var anim = [viewAnimations objectAtIndex:k];
- var endFrame = [[anim objectForKey:CPViewAnimationEndFrameKey]
rectValue];
- var target = [anim objectForKey:CPViewAnimationTargetKey];
- [target setFrame:endFrame];
- }
}
/*
[[_slices objectAtIndex:_lastRow] setNeedsDisplay:YES];
+*/
_lastRow = [self numberOfRows] -1;
-*/
-CPLogConsole(_cmd);
+ CPLogConsole("LAST ROW IS "+_lastRow);
}
- (void)_updateSliceRows
@@ -1161,7 +1113,7 @@
{
var slice = [_slices objectAtIndex:i];
[slice setRowIndex:i];
- var targetRect = CGRectMake(0., i*_sliceHeight, width, _sliceHeight);
+ var targetRect = CGRectMake(0, i*_sliceHeight, width, _sliceHeight);
[slice _setAnimationTargetRect:targetRect];
}
}
@@ -1398,17 +1350,17 @@
- (CPString)_toolTipForAddCompoundRowButton
{
- return nil;
+ return @"Add Compound row";
}
- (CPString)_toolTipForAddSimpleRowButton
{
- return nil;
+ return @"Add row";
}
- (CPString)_toolTipForDeleteRowButton
{
- return nil;
+ return @"Delete row";
}
- (void)_updateSliceIndentations
@@ -1431,12 +1383,12 @@
- (CPColor)_selectedActiveRowColor
{
- return [CPColor redColor];
+ return [CPColor colorWithCalibratedWhite:0.93 alpha:1]; //
selectedControlColor
}
- (CPColor)_selectedInactiveRowColor
{
- return [CPColor lightGrayColor];
+ return [CPColor colorWithCalibratedWhite:0.83 alpha:1]; //
secondarySelectedControlColor
}
- (CPArray)_selectedSlices
@@ -1466,36 +1418,22 @@
return CPNotFound;
}
-- (void)_deselectAll
-{
- var i;
-
- for (i = 0; i < [_slices count]; i++)
- {
- var slice = _slices[i];
-
- [slice _setSelected:0];
- [slice _setLastSelected:0];
- }
-}
-
- (void)_mouseDownOnSlice:(id)slice withEvent:(CPEvent)event
{
var modifierFlags = [event modifierFlags];
- if (modifierFlags & CPCommandKeyMask && [slice _rowType] ==
CPRuleEditorRowTypeSimple){
+ if (modifierFlags & CPCommandKeyMask && [slice _rowType] ==
CPRuleEditorRowTypeSimple)
+ {
[slice _setSelected:![slice _isSelected]];
- if (![slice _isSelected])[slice _setLastSelected:1];
+ if (![slice _isSelected])[slice _setLastSelected:YES];
[slice setNeedsDisplay:YES];
- }else{
-
+ }else
+ {
[self _deselectAll];
- [slice _setSelected:1];
- [slice _setLastSelected:1];
-
- for(i=0;i<[_slices count];i++)
- [_slices[i] setNeedsDisplay:YES];
- //[_slices makeObjectsPerformSelector:@selector(setNeedsDisplay:)
withObject:YES];
+ [slice _setSelected:YES];
+ [slice _setLastSelected:YES];
+
+ [_slices makeObjectsPerformSelector:@selector(setNeedsDisplay:)
withObject:YES];
}
CPLogConsole(_cmd);
}
@@ -1507,8 +1445,29 @@
- (void)selectAll:(id)sender
{
- [_slices makeObjectsPerformSelector:@selector(_setSelected:)
withObject:1];
- [_slices makeObjectsPerformSelector:@selector(setNeedsDisplay:)
withObject:1];
+ var i,
+ count = [_slices count];
+
+ for(i = 0;i < count;i++)
+ {
+ var slice = [_slices objectAtIndex:i];
+ [slice _setSelected:YES];
+ [slice setNeedsDisplay:YES];
+ }
+}
+
+
+- (void)_deselectAll
+{
+ var i,
+ count = [_slices count];
+
+ for (i = 0; i < count; i++)
+ {
+ var slice = [_slices objectAtIndex:i];
+ [slice _setSelected:NO];
+ [slice _setLastSelected:NO];
+ }
}
- (CPIndexSet)selectedRowIndexes
@@ -1544,9 +1503,7 @@
- (void)drawRect:(CPRect)rect
{
-CPLogConsole(_cmd+" In "+[self className]);
-
-var context = [CPGraphicsContext currentContext];
+ var context = [CPGraphicsContext currentContext];
CGContextSetFillColor(context,[CPColor redColor]);
// CGContextFillRect(context,[self bounds]);
@@ -1581,6 +1538,14 @@
- (void)bind:(CPString)binding toObject:(id)observableController
withKeyPath:(CPString)keyPath options:(CPDictionary)options
{
+
+
+if(keyPath == nil || [observableController valueForKey:keyPath] == nil)
+{
+ [CPException raise:CPInvalidArgumentException reason:"Keypath or bound
object cannot be nil"];
+ return;
+}
+
if([observableController respondsToSelector:@selector(objectClass)])
_rowClass = [observableController objectClass];
@@ -1636,14 +1601,14 @@
- (CPString)formattingStringsFilename
{
- return _stringsFilename;
+ return _stringsFileName;
}
- (void)setFormattingStringsFilename:(CPString)value
{
- if (_stringsFilename != value)
+ if (_stringsFileName != value)
{
- _stringsFilename = value;
+ _stringsFileName = value;
var strings = [CPString stringWithContentsOfURL:value];
_standardLocalizer = [[CPRuleEditorLocalizer alloc]
initWithStrings:strings];
}
@@ -1666,39 +1631,31 @@
- (BOOL)_performDragForSlice:(id)slice withEvent:(CPEvent)event
{
-CPLogConsole("START"+_cmd);
var size;
var dragPoint, pt;
var mainRowIndex = [slice rowIndex];
var draggingRows = [CPMutableIndexSet indexSetWithIndex:mainRowIndex];
var selected_indices = [self _selectedSliceIndices];
- if ([selected_indices containsIndex:mainRowIndex])[draggingRows
addIndexes:selected_indices];
+ 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];
+ [pasteboard declareTypes:[CPArray arrayWithObjects:
CPRuleEditorItemPBoardType, nil] owner: self];
dragPoint = CPMakePoint(0, ([_draggingRows lastIndex]) * _sliceHeight);
var date = [CPDate date];
// var dragview = [CPKeyedUnarchiver
unarchiveObjectWithData:[CPKeyedArchiver archivedDataWithRootObject:slice]];
-
-
+ var html = slice._DOMElement.innerHTML;
var dragview = [[CPView alloc] initWithFrame:[slice frame]];
- var subviews = [slice subviews];
- for(var i=0;i < [subviews count];i++)
- {
- var s = [subviews objectAtIndex:i];
- CPLogConsole("Subview "+i+" = "+[s className] + CPStringFromRect([s
frame]));
- var sc = [[[s class] alloc] initWithFrame:CGRectMakeZero()];
- [sc setFrame:[s frame]];
- [dragview addSubview:sc];
- }
-
- CPLogConsole([CPDate date] - date);
+ dragview._DOMElement.innerHTML = [html copy];
+
+ CPLogConsole("DRAG VIEW CREATION TAKES"+([CPDate date] - date)+"ms");
[dragview setBackgroundColor:[slice backgroundColor]];
[dragview setAlphaValue:0.7];
+
[self dragView: dragview
at: dragPoint
offset: CPMakeSize(0,_sliceHeight)
@@ -1706,7 +1663,6 @@
pasteboard: pasteboard
source: self
slideBack: YES];
-CPLogConsole("END"+_cmd);
return YES;
}
@@ -1715,7 +1671,8 @@
- (CPDragOperation)draggingEntered:(id < CPDraggingInfo >)sender
{
CPLogConsole(_cmd);
- if ([sender draggingSource] == self){
+ if ([sender draggingSource] == self)
+ {
[self _clearDropLine];
return CPDragOperationMove;
}
@@ -1734,9 +1691,13 @@
- (void)_clearDropLine
{
CPLogConsole(_cmd);
- var dropLineRect = [_dropLineView frame];
- dropLineRect.origin.y = -5;
- [_dropLineView setFrame:dropLineRect];
+if(_subviewIndexOfDropLine != CPNotFound)
+{
+ var previousBelowSlice = [_slices objectAtIndex:_subviewIndexOfDropLine];
+ [previousBelowSlice setFrameOrigin:CPMakePoint(0,[previousBelowSlice
rowIndex] * _sliceHeight)];
+ _subviewIndexOfDropLine = CPNotFound;
+}
+ [_dropLineView setAlphaValue:0];
}
- (CPDragOperation)draggingUpdated:(id <CPDraggingInfo>)sender
@@ -1744,13 +1705,13 @@
CPLogConsole(_cmd);
var point = [self convertPoint:[sender draggingLocation] fromView:nil];
var y = point.y + _sliceHeight /2;
- var indexOfDropLine = Math.floor(y / _sliceHeight);
-
+ var indexOfDropLine = FLOOR(y / _sliceHeight);
+
if (indexOfDropLine < 0 || indexOfDropLine > [self numberOfRows])
return CPDragOperationNone;
var current_index = [_draggingRows firstIndex];
- CPLogConsole(_cmd+indexOfDropLine);
+
while (current_index != CPNotFound) {
if (indexOfDropLine == 0 || indexOfDropLine == current_index ||
indexOfDropLine == current_index + 1)
@@ -1760,11 +1721,23 @@
}
current_index = [_draggingRows indexGreaterThanIndex:current_index];
}
-
- var dropLineRect = [_dropLineView frame];
- dropLineRect.origin.y = indexOfDropLine * _sliceHeight;
- [_dropLineView setFrame:dropLineRect];
-
+
+ if(_subviewIndexOfDropLine != indexOfDropLine)
+{
+ var previousBelowSlice = [_slices objectAtIndex:_subviewIndexOfDropLine];
+ [previousBelowSlice setFrameOrigin:CPMakePoint(0,[previousBelowSlice
rowIndex] * _sliceHeight)];
+
+ if(indexOfDropLine <= _lastRow)
+ {
+ var belowSlice = [_slices objectAtIndex:indexOfDropLine];
+ [belowSlice setFrameOrigin:CPMakePoint(0,[belowSlice rowIndex] *
_sliceHeight + 2)];
+ }
+
+ [_dropLineView setAlphaValue:1];
+ [_dropLineView setFrameOrigin:CPMakePoint([_dropLineView frame].origin.x,
indexOfDropLine * _sliceHeight)];
+
+ _subviewIndexOfDropLine = indexOfDropLine;
+}
return CPDragOperationMove;
}
@@ -1782,18 +1755,10 @@
- (BOOL)prepareForDragOperation:(id < CPDraggingInfo >)sender
{
-CPLogConsole(_cmd);
-var insertIndex = Math.floor([_dropLineView frame].origin.y /
_sliceHeight);
-if (insertIndex < 0)
- {
- _draggingRows = nil;
- return NO;
- }
-return YES;
+ CPLogConsole(_cmd);
+ return (_subviewIndexOfDropLine != CPNotFound);
}
-
-}
- (BOOL)performDragOperation:(id < CPDraggingInfo >)info
{
CPLogConsole(_cmd+[info draggingSource]);
@@ -1807,7 +1772,7 @@
var parentRowIndex = [self parentRowForRow:index]; // first index of
draggingrows
var parentRowObject = (parentRowIndex == -1) ? _boundArrayOwner : [[self
_rowCacheForIndex:parentRowIndex] rowObject];
- var insertIndex = Math.floor([_dropLineView frame].origin.y /
_sliceHeight);
+ var insertIndex = _subviewIndexOfDropLine;
CPLogConsole("insertIndex "+insertIndex+" sourceindex "+index);
@@ -1840,10 +1805,7 @@
return [CPIndexSet indexSetWithIndex:CPDragOperationMove];
}
-- (int)_dragOperationFromInfo:(id)info
-{
-}
-
+/*
- (CPDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal
{
if (isLocal)
@@ -1851,16 +1813,20 @@
return CPDragOperationNone;
}
+*/
-
+/*
- (int)_updateDragging:(id)fp8
{
- CPLogConsole(_cmd);
- return CPDragOperationMove;
}
+- (int)_dragOperationFromInfo:(id)info
+{
+}
+*/
- (void)draggedView:(CPView)dragView endedAt:(CPPoint)aPoint
operation:(CPDragOperation)operation
{
+_draggingRows = nil;
CPLogConsole(_cmd+operation);
}
Modified: branches/CPRuleEditor/CPRuleEditorLocalizer.j
==============================================================================
--- branches/CPRuleEditor/CPRuleEditorLocalizer.j (original)
+++ branches/CPRuleEditor/CPRuleEditorLocalizer.j Wed Feb 11 10:15:40 2009
@@ -1,8 +1,10 @@
-@import <Foundation/Foundation.j>
+@import <Foundation/CPObject.j>
+@import <Foundation/CPDictionary.j>
+@import <Foundation/CPString.j>
@implementation CPRuleEditorLocalizer : CPObject
{
-CPDictionary _dictionary;
+ CPDictionary _dictionary;
}
-(id)initWithStrings:(CPString)strings
Modified: branches/CPRuleEditor/CPRuleEditorTextField.j
==============================================================================
--- branches/CPRuleEditor/CPRuleEditorTextField.j (original)
+++ branches/CPRuleEditor/CPRuleEditorTextField.j Wed Feb 11 10:15:40 2009
@@ -22,13 +22,13 @@
return self;
}
-/*
+
- (id)hitTest:(CPPoint)point
{
- if (!CPPointInRect(point, [self frame]))
+ if (CPRectContainsPoint([self frame],point) == NO)
return nil;
return [self superview];
}
-*/
+
@end
Modified: branches/CPRuleEditor/CPRuleEditorViewSlice.j
==============================================================================
--- branches/CPRuleEditor/CPRuleEditorViewSlice.j (original)
+++ branches/CPRuleEditor/CPRuleEditorViewSlice.j Wed Feb 11 10:15:40 2009
@@ -3,20 +3,18 @@
* Copyright (c) 2008 Pear, Inc. All rights reserved.
*/
-
@implementation CPRuleEditorViewSlice : CPView
{
CPRuleEditor _ruleEditor;
+
CPColor backgroundColor;
int _indentation;
+ int _rowIndex;
CPRect _animationTargetRect;
BOOL selected;
BOOL lastSelected;
- unsigned int hideNonPartDrawing;
- unsigned int reserved;
-
- int _rowIndex;
+ int hideNonPartDrawing;
}
-(void)removeFromSuperview
@@ -51,7 +49,7 @@
_ruleEditor = editor;
selected = NO;
lastSelected = NO;
- [self setBackgroundColor:[CPColor colorWithCalibratedWhite:0.91
alpha:1]];
+ [self setBackgroundColor:[CPColor colorWithCalibratedWhite:0.91
alpha:1]]; // controlColor
}
return self;
}
@@ -123,17 +121,14 @@
}
--(void)drawRect:(CPRect)rect{
+-(void)drawRect:(CPRect)rect
+{
var context = [[CPGraphicsContext currentContext] graphicsPort];
-//- (void)drawLayer:(CALayer)aLayer inContext:(CGContext)context{
-// var rect = [self bounds];
var bgColor;
if ([self _isSelected])
- {
- var isKey = [[self window] isKeyWindow];
- bgColor = [(isKey) ? [_ruleEditor
_selectedActiveRowColor]:[_ruleEditor _selectedInactiveRowColor]];
- }else
+ bgColor = ([[self window] isKeyWindow]) ? [_ruleEditor
_selectedActiveRowColor]:[_ruleEditor _selectedInactiveRowColor];
+ else
bgColor = [self backgroundColor];
CGContextSetFillColor(context,bgColor);
@@ -152,11 +147,12 @@
CGContextSetFillColor(context,[_ruleEditor _sliceBottomBorderColor]);
CGContextFillRect(context,drawrect);
+
}
- (void)mouseDown:(CPEvent)theEvent
{
- // [_ruleEditor _mouseDownOnSlice:self withEvent:theEvent];
+ [_ruleEditor _mouseDownOnSlice:self withEvent:theEvent];
}
/*
- (void)rightMouseDown:(CPEvent)theEvent
Modified: branches/CPRuleEditor/CPRuleEditorViewSliceHolder.j
==============================================================================
--- branches/CPRuleEditor/CPRuleEditorViewSliceHolder.j (original)
+++ branches/CPRuleEditor/CPRuleEditorViewSliceHolder.j Wed Feb 11 10:15:40
2009
@@ -9,34 +9,18 @@
}
-- (id)initWithFrame:(CGRect)frame
-{
- self = [super initWithFrame:frame];
- if (self != nil)
- {
-
- }
- return self;
-}
-
- (void)addSubview:(CPView)subview
{
[self setNeedsDisplay:YES];
[super addSubview:subview];
}
-- (BOOL)isFlipped
-{
- return YES;
-}
-
-
- (void)drawRect:(CPRect)rect
{
CPLogConsole(_cmd+" In "+[self className]);
- [[self superview] drawRect:rect];
+ //[[self superview] drawRect:rect];
+
}
-
@end
Modified: branches/CPRuleEditor/CPRuleEditorViewSliceRow.j
==============================================================================
--- branches/CPRuleEditor/CPRuleEditorViewSliceRow.j (original)
+++ branches/CPRuleEditor/CPRuleEditorViewSliceRow.j Wed Feb 11 10:15:40
2009
@@ -48,8 +48,8 @@
_addButton = [self _createAddRowButton];
_subtractButton = [self _createDeleteRowButton];
-// [_addButton setToolTip:[_ruleEditor _toolTipForAddSimpleRowButton]];
-// [_subtractButton setToolTip:[_ruleEditor _toolTipForDeleteRowButton]];
+ [_addButton setToolTip:[_ruleEditor _toolTipForAddSimpleRowButton]];
+ [_subtractButton setToolTip:[_ruleEditor _toolTipForDeleteRowButton]];
var sliceFrame = [self frame];
@@ -132,8 +132,8 @@
- (CPRuleEditorTextField)_createStaticTextFieldWithStringValue:(CPString
)text
{
var textField = [[CPRuleEditorTextField alloc]
initWithFrame:CPMakeRect(0, 0, 0, CONTROL_HEIGHT)];
- // var loc_text = CPLocalizedStringFromTable(text,[_ruleEditor
formattingStringsFilename],nil);
- [textField setStringValue:text];
+ var loc_text = [[_ruleEditor standardLocalizer]
localizedStringForString:text];
+ [textField setStringValue:loc_text];
[textField sizeToFit];
return textField;
@@ -154,15 +154,12 @@
- (void)_ruleOptionPopupChangedAction:(CPMenuItem )popup
{
-// HACK BUG
+// sender should be se menu item not popup
var sender = [popup selectedItem];
var layoutdict = [sender representedObject];
-CPLogConsole(_cmd);
var newItem = [layoutdict objectForKey:@"item"];
var indexInCriteria = [[layoutdict objectForKey:@"indexInCriteria"]
intValue];
-CPLogConsole(_cmd);
var oldItem = [_correspondingRuleItems objectAtIndex:indexInCriteria];
-CPLogConsole(_cmd);
if (newItem != oldItem)
{
[_correspondingRuleItems replaceObjectAtIndex:indexInCriteria
withObject:newItem];
@@ -284,7 +281,7 @@
[_ruleOptionViews addObject:optionView];
- var rectValue = [CPValue valueWithJSObject:[optionView frame]];
+ var rectValue = [CPValue valueWithRect:[optionView frame]];
CPLogConsole([optionView className]+" = "+CPStringFromRect([optionView
frame]));
if (rectValue)
[_ruleOptionInitialViewFrames addObject:rectValue];
@@ -323,7 +320,6 @@
{
var optionFrame = [_ruleOptionView frame];
optionFrame.origin = CPMakePoint(optionViewOriginX, ([_ruleEditor
rowHeight] - optionFrame.size.height)/2);
- CPLogConsole([_ruleEditor rowHeight]+" - "+optionFrame.size.height);
var optionFrameEnd = MIN(optionFrame.origin.x +
optionFrame.size.width,[_subtractButton frame].origin.x - [self
_rowButtonsLeftHorizontalPadding]);
optionFrame.size.width = optionFrameEnd - optionFrame.origin.x;
@@ -334,7 +330,7 @@
if (shouldAddView)[self addSubview:_ruleOptionView];
- [_ruleOptionFrames addObject:[CPValue valueWithJSObject:optionFrame]];
+ [_ruleOptionFrames addObject:[CPValue valueWithRect:optionFrame]];
optionViewOriginX += optionFrame.size.width + [self
_interviewHorizontalPadding];
}
@@ -388,8 +384,8 @@
- (void)setEditable:(BOOL)value
{
editable = value;
-// [RuleEditorViewSliceRow _updateEnabledStateForSubviews];
-// [RuleEditorViewSliceRow _updateButtonVisibilities];
+// [self _updateEnabledStateForSubviews];
+// [self _updateButtonVisibilities];
}
Modified: branches/CPRuleEditor/CPViewAnimation.j
==============================================================================
--- branches/CPRuleEditor/CPViewAnimation.j (original)
+++ branches/CPRuleEditor/CPViewAnimation.j Wed Feb 11 10:15:40 2009
@@ -49,7 +49,8 @@
{
_viewAnimations = animations;
- if(!CPBrowserIsEngine(CPWebKitBrowserEngine)) return;
+ if(CPBrowserIsEngine(CPWebKitBrowserEngine))
+ {
count = [_viewAnimations count];
@@ -62,20 +63,13 @@
switch([self animationCurve])
{
- case CPAnimationEaseInOut:
- timingFunction = "ease-in-out";
- break;
- case CPAnimationEaseIn:
- timingFunction = "ease-in";
+ case CPAnimationEaseInOut: timingFunction = "ease-in-out";
break;
- case CPAnimationEaseOut:
- timingFunction = "ease-out";
+ case CPAnimationEaseIn: timingFunction = "ease-in";
break;
- case CPAnimationLinear:
- timingFunction = "linear";
+ case CPAnimationEaseOut: timingFunction = "ease-out";
break;
- case "CPAnimationCool":
- timingFunction = "cubic-bezier(0.1, 0.25, 0.1, 1.0)";
+ case CPAnimationLinear:timingFunction = "linear";
break;
default:
timingFunction = "ease-in-out";
@@ -85,10 +79,11 @@
if ([animation objectForKey:CPViewAnimationEffectKey] != nil)
properties += ", opacity";
- style.webkitTransitionProperty = properties;
+ style.webkitTransitionProperty = properties; // should rather go in a
private dict and be set when startAnimation
style.webkitTransitionDuration = [self duration] + "s";
style.webkitTransitionTimingFunction = timingFunction;
}
+}
CPLogConsole(_cmd);
}
@@ -100,7 +95,7 @@
var i;
count = [_viewAnimations count],
- t = [self currentValue],
+ d = [self currentValue],
_needsDisplay = NO;
for(var i = 0; i < count; i++)
@@ -117,10 +112,10 @@
var bsize = endFrame.size;
var asize = startFrame.size;
- var frame = CPMakeRect(borig.x*t + aorig.x *(1-t),
- borig.y*t + aorig.y *(1-t),
- bsize.width*t + asize.width *(1-t),
- bsize.height*t + asize.height *(1-t));
+ var frame = CPMakeRect(borig.x*d + aorig.x *(1-d),
+ borig.y*d + aorig.y *(1-d),
+ bsize.width*d + asize.width *(1-d),
+ bsize.height*d + asize.height *(1-d));
[target setFrame:frame];
@@ -129,51 +124,45 @@
var effect = [animation objectForKey:CPViewAnimationEffectKey];
if (effect == CPViewAnimationFadeInEffect)
- [target setAlphaValue:t];
+ [target setAlphaValue:d];
else if (effect == CPViewAnimationFadeOutEffect)
- [target setAlphaValue:1-t];
+ [target setAlphaValue:1-d];
}
CPLogConsole(_cmd+progress);
}
--(float)currentValue
-{
- return _progress;
-}
- (void)startAnimation
{
-
-if(!CPBrowserIsEngine(CPWebKitBrowserEngine))
-{
[super startAnimation];
- return;
-}
- var count = [_viewAnimations count];
-
- for(var i = 0; i < count; i++)
+ if(CPBrowserIsEngine(CPWebKitBrowserEngine))
{
- var animation = [_viewAnimations objectAtIndex:i];
- var target = [animation objectForKey:CPViewAnimationTargetKey];
- var endFrame = [[animation objectForKey:CPViewAnimationEndFrameKey]
rectValue];
-
- var effect = [animation objectForKey:CPViewAnimationEffectKey];
- if(effect)
+ var count = [_viewAnimations count];
+
+ for(var i = 0; i < count; i++)
{
- var opacity;
- switch(effect)
+ var animation = [_viewAnimations objectAtIndex:i];
+ var target = [animation objectForKey:CPViewAnimationTargetKey];
+ var endFrame = [[animation objectForKey:CPViewAnimationEndFrameKey]
rectValue];
+
+ var effect = [animation objectForKey:CPViewAnimationEffectKey];
+ if(effect)
{
- case CPViewAnimationFadeInEffect: opacity = 1;
- break;
- case CPViewAnimationFadeOutEffect: opacity = 0;
- break;
- default : opacity = 1;
+ var opacity;
+ switch(effect)
+ {
+ case CPViewAnimationFadeInEffect: opacity = 1;
+ break;
+ case CPViewAnimationFadeOutEffect: opacity = 0;
+ break;
+ default : opacity = 1;
+ }
+ [target setAlphaValue:opacity];
}
- [target setAlphaValue:opacity];
+ [target setFrame:endFrame];
}
- [target setFrame:endFrame];
}
- CPLogConsole(_cmd);
+
}
- (void)_stopAnimation:(int)value
Modified: branches/CPRuleEditor/Info.plist
==============================================================================
--- branches/CPRuleEditor/Info.plist (original)
+++ branches/CPRuleEditor/Info.plist Wed Feb 11 10:15:40 2009
@@ -1,12 +1 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST
1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CPApplicationDelegateClass</key>
- <string>AppController</string>
- <key>CPBundleName</key>
- <string>CPRuleEditor</string>
- <key>CPPrincipalClass</key>
- <string>CPApplication</string>
-</dict>
-</plist>
+<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple
Computer//DTD PLIST
1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version
= "1.0"><dict><key>CPApplicationDelegateClass</key><string>AppController</string><key>CPBundleName</key><string>CPRuleEditor</string><key>CPPrincipalClass</key><string>CPApplication</string></dict></plist>
\ No newline at end of file
Modified: branches/CPRuleEditor/RowObject.j
==============================================================================
--- branches/CPRuleEditor/RowObject.j (original)
+++ branches/CPRuleEditor/RowObject.j Wed Feb 11 10:15:40 2009
@@ -4,4 +4,21 @@
CPArray criteria;
CPArray displayValues;
int rowType;
-}
\ No newline at end of file
+}
+
+- (id)initWithCoder:(id)coder
+{
+ self = [super init];
+ subrows = [coder decodeObjectForKey:"subrows"];
+ criteria = [coder decodeObjectForKey:"criteria"];
+ displayValues = [coder decodeObjectForKey:"displayValues"];
+ rowType = [coder decodeintForKey:"rowType"];
+}
+
+- (void)encodeWithCoder:(id)coder
+{
+ [coder encodeObject:subrows forKey:"subrows"];
+ [coder encodeObject:criteria forKey:"criteria"];
+ [coder encodeObject:displayValues forKey:"displayValues"];
+ [coder encodeInt:rowType forKey:"rowType"];
+}
Modified: branches/CPRuleEditor/criteria.plist
==============================================================================
--- branches/CPRuleEditor/criteria.plist (original)
+++ branches/CPRuleEditor/criteria.plist Wed Feb 11 10:15:40 2009
@@ -64,7 +64,7 @@
<key>CPRuleEditorPredicateComparisonModifier</key>
<integer>0</integer>
<key>CPRuleEditorPredicateOperatorType</key>
- <integer>99</integer>
+ <integer>7</integer>
<key>CPRuleEditorPredicateOptions</key>
<integer>1</integer>
<key>criteria</key>
@@ -75,7 +75,7 @@
</dict>
</array>
<key>valeur</key>
- <string>CPContainsPredicateOperatorType</string>
+ <string>CPLikePredicateOperatorType</string>
</dict>
<dict>
<key>CPRuleEditorPredicateComparisonModifier</key>
@@ -150,37 +150,37 @@
<key>CPRuleEditorPredicateComparisonModifier</key>
<integer>0</integer>
<key>CPRuleEditorPredicateOperatorType</key>
- <integer>3</integer>
+ <integer>0</integer>
<key>CPRuleEditorPredicateOptions</key>
<integer>0</integer>
<key>criteria</key>
<array>
<dict>
- <key>CPRuleEditorPredicateRightExpression</key>
- <integer>50</integer>
- <key>valeur</key>
- <string>50 ans</string>
+ <key>CPRuleEditorCustomControlClass</key>
+ <string>Slider</string>
</dict>
</array>
<key>valeur</key>
- <string>CPGreaterThanOrEqualToPredicateOperatorType</string>
+ <string>CPLessThanPredicateOperatorType</string>
</dict>
<dict>
<key>CPRuleEditorPredicateComparisonModifier</key>
<integer>0</integer>
<key>CPRuleEditorPredicateOperatorType</key>
- <integer>0</integer>
+ <integer>3</integer>
<key>CPRuleEditorPredicateOptions</key>
<integer>0</integer>
<key>criteria</key>
<array>
<dict>
- <key>CPRuleEditorCustomControlClass</key>
- <string>Slider</string>
+ <key>CPRuleEditorPredicateRightExpression</key>
+ <integer>50</integer>
+ <key>valeur</key>
+ <string>50 ans</string>
</dict>
</array>
<key>valeur</key>
- <string>CPLessThanPredicateOperatorType</string>
+ <string>CPGreaterThanOrEqualToPredicateOperatorType</string>
</dict>
</array>
<key>valeur</key>
Modified: branches/CPRuleEditor/format.strings
==============================================================================
--- branches/CPRuleEditor/format.strings (original)
+++ branches/CPRuleEditor/format.strings Wed Feb 11 10:15:40 2009
@@ -10,8 +10,8 @@
"CPEndsWithPredicateOperatorType" = "ends with"; //9
"CPInPredicateOperatorType" = "is in"; //10
"CPCustomSelectorPredicateOperatorType" = "function"; //11
-"CPContainsPredicateOperatorType" = "contains"; //12
-"CPBetweenPredicateOperatorType" = "is between"; //13
+"CPContainsPredicateOperatorType" = "contains"; //99
+"CPBetweenPredicateOperatorType" = "is between"; //100
"firstName" = "First Name";
"lastName" = "Last Name";
"age" = "Age";