Skip to content

Commit

Permalink
Use new CPBinder methods from #1495
Browse files Browse the repository at this point in the history
  • Loading branch information
cacaodev committed Apr 10, 2012
1 parent d649fc2 commit c989c30
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions AppKit/CPImageView.j
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var CPImageViewEmptyPlaceholderImage = nil;

+ (Class)_binderClassForBinding:(CPString)theBinding
{
if (theBinding == CPValueBinding || theBinding == CPValueURLBinding || theBinding == CPValuePathBinding)
if (theBinding === CPValueBinding || theBinding === CPValueURLBinding || theBinding === CPValuePathBinding)
return [CPImageViewValueBinder class];

return [super _binderClassForBinding:theBinding];
Expand Down Expand Up @@ -469,36 +469,17 @@ var CPImageViewEmptyPlaceholderImage = nil;
[self _setPlaceholder:nil forMarker:CPNullMarker isDefault:YES];
}

- (void)setValueFor:(CPString)theBinding
- (void)setPlaceholderValue:(id)aValue withMarker:(CPString)aMarker forBinding:(CPString)aBinding
{
var destination = [_info objectForKey:CPObservedObjectKey],
keyPath = [_info objectForKey:CPObservedKeyPathKey],
options = [_info objectForKey:CPOptionsKey],
newValue = [destination valueForKeyPath:keyPath],
isPlaceholder = CPIsControllerMarker(newValue);

if (newValue == nil)
return;
[_source setImage:nil];
}

if (isPlaceholder)
{
if (newValue === CPNotApplicableMarker && [options objectForKey:CPRaisesForNotApplicableKeysBindingOption])
{
[CPException raise:CPGenericException
reason:@"can't transform non applicable key on: " + _source + " value: " + newValue];
}
- (void)setValue:(id)aValue forBinding:(CPString)aBinding
{
if (aBinding === CPValueURLBinding || aBinding === CPValuePathBinding)
aValue = [[CPImage alloc] initWithContentsOfFile:aValue];

[_source setImage:nil];
}
else
{
newValue = [self transformValue:newValue withOptions:options];

if (theBinding != CPValueBinding)
newValue = [[CPImage alloc] initWithContentsOfFile:newValue];

[_source setImage:newValue];
}
[_source setImage:aValue];
}

@end
Expand Down

0 comments on commit c989c30

Please sign in to comment.