capplinted CPRuleEditor/*.j

This commit is contained in:
cacaodev committed 2012-04-26 20:34:09 +02:00
1 parent edb86ebeeb
commit 92cdda1d22
6 files changed
+64 -67

No files matched your search

+3 -4
View File
@@ -193,12 +193,11 @@
if ([[mergednode title] isEqualToString:[anode title]])
{
var children1 = [mergednode children],
children2 = [anode children];
children2 = [anode children],
children12 = [children1 arrayByAddingObjectsFromArray:children2],
mergedChildren = [self _mergeTree:children12];
var children12 = [children1 arrayByAddingObjectsFromArray:children2];
var mergedChildren = [self _mergeTree:children12];
[mergednode setChildren:mergedChildren];
merged = YES;
}
}
@@ -280,7 +280,7 @@ CPTransformableAttributeType = 1800;
*/
- (CPArray)leftExpressions
{
if (_templateType ==1 && !_leftIsWildcard)
if (_templateType == 1 && !_leftIsWildcard)
{
var view = [_views objectAtIndex:0];
return [[view itemArray] valueForKey:@"representedObject"];
+19 -22
View File
@@ -50,9 +50,8 @@ CPRuleEditorNestingModeSimple = 3; // One compound row at the top with
CPRuleEditorRowTypeSimple = 0;
CPRuleEditorRowTypeCompound = 1;
var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType";
var itemsContext = "items",
var CPRuleEditorItemPBoardType = @"CPRuleEditorItemPBoardType",
itemsContext = "items",
valuesContext = "values",
subrowsContext = "subrows_array",
boundArrayContext = "bound_array";
@@ -807,7 +806,7 @@ TODO: implement
for (i = 0; i < count; i++)
{
var item = [items objectAtIndex:i],
//var displayValue = [self _queryValueForItem:item inRow:aRow]; A voir. On peut aussi prendre la valeur affichée dans le row cache.
//var displayValue = [self _queryValueForItem:item inRow:aRow]; Ask the delegate or get cached value ?.
displayValue = [[self displayValuesForRow:aRow] objectAtIndex:i],
predpart = [_ruleDelegate ruleEditor:self predicatePartsForCriterion:item withDisplayValue:displayValue inRow:aRow];
@@ -1410,18 +1409,16 @@ TODO: implement
var rowIndexEvent = [slice rowIndex],
rowTypeEvent = [self rowTypeForRow:rowIndexEvent],
insertIndex = rowIndexEvent + 1;
var parentRowIndex = (rowTypeEvent === CPRuleEditorRowTypeCompound) ? rowIndexEvent:[self parentRowForRow:rowIndexEvent];
insertIndex = rowIndexEvent + 1,
parentRowIndex = (rowTypeEvent === CPRuleEditorRowTypeCompound) ? rowIndexEvent:[self parentRowForRow:rowIndexEvent];
[self insertRowAtIndex:insertIndex withType:type asSubrowOfRow:parentRowIndex animate:YES];
}
- (id)_insertNewRowAtIndex:(int)insertIndex ofType:(CPRuleEditorRowType)rowtype withParentRow:(int)parentRowIndex
{
var row = [[[self rowClass] alloc] init];
var itemsandvalues = [self _getItemsAndValuesToAddForRow:insertIndex ofType:rowtype],
var row = [[[self rowClass] alloc] init],
itemsandvalues = [self _getItemsAndValuesToAddForRow:insertIndex ofType:rowtype],
newitems = [itemsandvalues valueForKey:@"item"],
newvalues = [itemsandvalues valueForKey:@"value"];
@@ -1538,10 +1535,9 @@ TODO: implement
var criteria = [self criteriaForRow:aRow],
displayValues = [self displayValuesForRow:aRow],
rowType = [self rowTypeForRow:aRow],
anItem = toItem;
//fromItemIndex = [criteria indexOfObjectIdenticalTo:fromItem];
anItem = toItem,
var items = [criteria subarrayWithRange:CPMakeRange(0, fromItemIndex)],
items = [criteria subarrayWithRange:CPMakeRange(0, fromItemIndex)],
values = [displayValues subarrayWithRange:CPMakeRange(0, fromItemIndex)];
_lastRow = aRow;
@@ -1601,9 +1597,9 @@ TODO: implement
{
var newCacheGlobalIndex = (parentCacheIndex + 1) + newRowCacheIndex,
obj = [newRows objectAtIndex:newRowCacheIndex],
newRowType = [obj valueForKey:_typeKeyPath];
newRowType = [obj valueForKey:_typeKeyPath],
cache = [[_CPRuleEditorCache alloc] init];
var cache = [[_CPRuleEditorCache alloc] init];
[cache setRowObject:obj];
[cache setRowIndex:newCacheGlobalIndex];
[cache setIndentation:parentCacheIndentation + 1];
@@ -1689,8 +1685,9 @@ TODO: implement
[_rowCache removeAllObjects];
[_slices removeAllObjects];
var newRows = [CPArray array];
var oldRows = [self _rootRowsArray];
var newRows = [CPArray array],
oldRows = [self _rootRowsArray];
[self _changedRowArray:newRows withOldRowArray:oldRows forParent:_boundArrayOwner];
}
else
@@ -1775,7 +1772,7 @@ TODO: implement
count = [_slices count];
[self _updateSliceRows];
if ([[self superview] isKindOfClass:[CPClipView class]])
[self setFrameSize:CGSizeMake(CGRectGetWidth([self frame]), count * _sliceHeight)];
@@ -2313,9 +2310,9 @@ TODO: implement
if ([self rowTypeForRow:globalChildIndex] === CPRuleEditorRowTypeCompound)
{
var rowObject = [[self _rowCacheForIndex:current_index] rowObject],
subrows = [self _subrowObjectsOfObject:rowObject];
subrows = [self _subrowObjectsOfObject:rowObject],
subIndexes = [self _globalIndexesForSubrowIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0,[subrows count])] ofParentObject:rowObject];
var subIndexes = [self _globalIndexesForSubrowIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0,[subrows count])] ofParentObject:rowObject];
numberOfChildrenOfPreviousBrother = [subIndexes count];
}
@@ -2370,8 +2367,8 @@ TODO: implement
for (var i = 0; i < numOfChildren; ++i)
{
var aChild = [self _queryChild:i ofItem:parentItem withRowType:type];
var availChild = aChild,
var aChild = [self _queryChild:i ofItem:parentItem withRowType:type],
availChild = aChild,
availValue = value;
if (criterion !== aChild)
@@ -21,14 +21,14 @@
{
var views,
copiedContainer;
var uuid = [[aTree template] UID],
cachedNode = templateTable[uuid],
node = [[_CPPredicateEditorRowNode alloc] init];
[node setTree:aTree];
if (cachedNode == nil)
if (!cachedNode)
{
views = [CPMutableArray array];
copiedContainer = [CPMutableArray array];
+11 -12
View File
@@ -10,7 +10,7 @@ var GRADIENT_START_COLOR = "#fcfcfc",
var GRADIENT_NORMAL,
GRADIENT_HIGHLIGHTED,
GRADIENT_PROPERTY;
if (CPBrowserIsEngine(CPWebKitBrowserEngine))
{
GRADIENT_NORMAL = "-webkit-gradient(linear, left top, left bottom, from(" + GRADIENT_START_COLOR + "), to(" + GRADIENT_END_COLOR + "))",
@@ -46,7 +46,7 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
var style = _DOMElement.style;
style.border = "1px solid " + BORDER_COLOR;
style[GRADIENT_PROPERTY] = GRADIENT_NORMAL;
style[GRADIENT_PROPERTY] = GRADIENT_NORMAL;
}
- (id)initWithFrame:(CGRect)aFrame
@@ -61,7 +61,7 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
{
self = [super initWithCoder:aCoder];
[self _sharedInit];
return self;
}
@@ -98,7 +98,7 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
- (void)layoutSubviews
{
radius = FLOOR(CGRectGetHeight([self bounds])/2);
radius = FLOOR(CGRectGetHeight([self bounds]) / 2);
var style = _DOMElement.style,
radiusCSS = radius + "px";
@@ -109,20 +109,19 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
- (void)drawRect:(CGRect)aRect
{
var bounds = [self bounds],
context = [[CPGraphicsContext currentContext] graphicsPort];
var arrow_width = FLOOR(CGRectGetHeight(bounds)/3.5);
var context = [[CPGraphicsContext currentContext] graphicsPort],
bounds = [self bounds],
arrow_width = FLOOR(CGRectGetHeight(bounds) / 3.5);
CGContextTranslateCTM(context, CGRectGetWidth(bounds) - radius - arrow_width, CGRectGetHeight(bounds) / 2);
var arrowsPath = [CPBezierPath bezierPath];
[arrowsPath moveToPoint:CGPointMake(0, 1)];
[arrowsPath lineToPoint:CGPointMake(arrow_width, 1)];
[arrowsPath lineToPoint:CGPointMake(arrow_width/2, arrow_width + 1)];
[arrowsPath lineToPoint:CGPointMake(arrow_width / 2, arrow_width + 1)];
[arrowsPath closePath];
CGContextSetFillColor(context, [CPColor colorWithWhite:101/255 alpha:1]);
CGContextSetFillColor(context, [CPColor colorWithWhite:101 / 255 alpha:1]);
[arrowsPath fill];
CGContextScaleCTM(context, 1 , -1);
@@ -157,13 +156,13 @@ else if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
{
self = [super initWithCoder:aCoder];
[self _sharedInit];
return self;
}
- (void)layoutSubviews
{
radius = FLOOR(CGRectGetHeight([self bounds])/2);
radius = FLOOR(CGRectGetHeight([self bounds]) / 2);
var style = _DOMElement.style,
radiusCSS = radius + "px";
+27 -25
View File
@@ -58,18 +58,18 @@ var CONTROL_HEIGHT = 16.,
{
var button = [[_CPRuleEditorButton alloc] initWithFrame:CGRectMakeZero()];
[button setFont:[CPFont boldFontWithName:@"Apple Symbol" size:12.0]];
[button setTextColor:[CPColor colorWithWhite:150/255 alpha:1]];
[button setTextColor:[CPColor colorWithWhite:150 / 255 alpha:1]];
[button setAlignment:CPCenterTextAlignment];
[button setAutoresizingMask:CPViewMinXMargin];
[button setImagePosition:CPImageOnly];
return button;
}
- (CPButton)_createAddRowButton
{
var button = [self _createRowButton];
[button setImage:[_ruleEditor _addImage]];
[button setAction:@selector(_addOption:)];
[button setTarget:self];
@@ -97,12 +97,13 @@ var CONTROL_HEIGHT = 16.,
- (CPPopUpButton)_createPopUpButtonWithItems:(CPArray)itemsArray selectedItemIndex:(int)index
{
var title = [[itemsArray objectAtIndex:index] title];
var font = [_ruleEditor font],
var title = [[itemsArray objectAtIndex:index] title],
font = [_ruleEditor font],
width = [title sizeWithFont:font].width + 20,
rect = CGRectMake(0, 0, (width - width % 40) + 80, CONTROL_HEIGHT);
rect = CGRectMake(0, 0, (width - width % 40) + 80, CONTROL_HEIGHT),
popup = [[_CPRuleEditorPopUpButton alloc] initWithFrame:rect];
var popup = [[_CPRuleEditorPopUpButton alloc] initWithFrame:rect];
[popup setTextColor:[CPColor colorWithWhite:101 / 255 alpha:1]];
[popup setValue:font forThemeAttribute:@"font"];
@@ -122,13 +123,14 @@ var CONTROL_HEIGHT = 16.,
- (_CPRuleEditorTextField)_createStaticTextFieldWithStringValue:(CPString )text
{
text = [[_ruleEditor standardLocalizer] localizedStringForString:text];
var textField = [[_CPRuleEditorTextField alloc] initWithFrame:CPMakeRect(0, 0, 200, CONTROL_HEIGHT)],
refont = [_ruleEditor font],
font = [CPFont fontWithName:[refont familyName] size:[refont size] + 2],
localizedText = [[_ruleEditor standardLocalizer] localizedStringForString:text];
var textField = [[_CPRuleEditorTextField alloc] initWithFrame:CPMakeRect(0, 0, 200, CONTROL_HEIGHT)];
var font = [_ruleEditor font];
font = [CPFont fontWithName:font._name size:font._size + 2];
[textField setValue:font forThemeAttribute:@"font"];
[textField setStringValue:text];
[textField setStringValue:localizedText];
[textField sizeToFit];
return textField;
@@ -193,9 +195,10 @@ var CONTROL_HEIGHT = 16.,
parent,
numberOfCriteria,
numberOfChildren,
firstResponderIndex;
firstResponderIndex,
var ruleItems = [CPMutableArray array];
ruleItems = [CPMutableArray array],
responder = [[self window] firstResponder];
[self _emptyRulePartSubviews];
@@ -203,7 +206,6 @@ var CONTROL_HEIGHT = 16.,
numberOfCriteria = [criteria count];
firstResponderIndex = numberOfCriteria - 1;
var responder = [[self window] firstResponder];
if (responder)
firstResponderIndex = [_ruleOptionViews indexOfObjectIdenticalTo:responder];
@@ -224,16 +226,16 @@ var CONTROL_HEIGHT = 16.,
numberOfChildren = [childItems count];
if (numberOfChildren > 1)
{
var menuItems = [CPMutableArray arrayWithCapacity:numberOfChildren];
var menuItems = [CPMutableArray arrayWithCapacity:numberOfChildren],
selectedIndex = [childItems indexOfObject:criterion];
var selectedIndex = [childItems indexOfObject:criterion];
if (selectedIndex == CPNotFound)
break;
for (var j = 0; j < numberOfChildren; ++j)
{
var childItem = [childItems objectAtIndex:j];
var childValue = [childValues objectAtIndex:j];
var childItem = [childItems objectAtIndex:j],
childValue = [childValues objectAtIndex:j];
if ([childValue isKindOfClass:[CPMenuItem class]])
{
@@ -261,8 +263,8 @@ var CONTROL_HEIGHT = 16.,
}
else
{
var value = [childValues objectAtIndex:0];
var type = [value valueType];
var value = [childValues objectAtIndex:0],
type = [value valueType];
if (type === 0)
ruleView = [self _createStaticTextFieldWithStringValue:value];
@@ -329,11 +331,11 @@ var CONTROL_HEIGHT = 16.,
leftButtonMinX,
rowHeight = [_ruleEditor rowHeight],
count = [_ruleOptionViews count],
sliceFrame = [self frame];
sliceFrame = [self frame],
buttonFrame = CGRectMake(CGRectGetWidth(sliceFrame) - BUTTON_HEIGHT - [self _rowButtonsRightHorizontalPadding], ([_ruleEditor rowHeight] - BUTTON_HEIGHT) / 2 - 2, BUTTON_HEIGHT, BUTTON_HEIGHT);
var buttonFrame = CGRectMake(CGRectGetWidth(sliceFrame) - BUTTON_HEIGHT - [self _rowButtonsRightHorizontalPadding], ([_ruleEditor rowHeight] - BUTTON_HEIGHT)/2 - 2, BUTTON_HEIGHT, BUTTON_HEIGHT);
[_addButton setFrame:buttonFrame];
buttonFrame.origin.x -= BUTTON_HEIGHT + [self _rowButtonsInterviewHorizontalPadding];
[_subtractButton setFrame:buttonFrame];
@@ -349,7 +351,7 @@ var CONTROL_HEIGHT = 16.,
var ruleOptionView = _ruleOptionViews[i],
optionFrame = _ruleOptionFrames[i];
optionFrame.origin.y = (rowHeight - CGRectGetHeight(optionFrame))/2 - 2;
optionFrame.origin.y = (rowHeight - CGRectGetHeight(optionFrame)) / 2 - 2;
if (widthChanged)
{
optionFrame.origin.x = optionViewOriginX;