1.1 --- a/Core/Source/DisplayPluginNameWithDefaultTransformer.m Tue Apr 07 11:34:52 2009 -0700
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,62 +0,0 @@
1.4 -//
1.5 -// DisplayPluginNameWithDefaultTransformer.m
1.6 -// Growl
1.7 -//
1.8 -// Created by Evan Schoenberg on 8/18/07.
1.9 -//
1.10 -
1.11 -#import "DisplayPluginNameWithDefaultTransformer.h"
1.12 -
1.13 -#define DEFAULT_STRING NSLocalizedStringFromTableInBundle(@"Default", nil, [NSBundle bundleForClass:[self class]], @"")
1.14 -
1.15 -@implementation DisplayPluginNameWithDefaultTransformer
1.16 -+ (void)load
1.17 -{
1.18 - if (self == [DisplayPluginNameWithDefaultTransformer class]) {
1.19 - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1.20 - [self setValueTransformer:[[[DisplayPluginNameWithDefaultTransformer alloc] init] autorelease]
1.21 - forName:@"DisplayPluginNameWithDefaultTransformer"];
1.22 - [pool release];
1.23 - }
1.24 -}
1.25 -
1.26 -+ (Class)transformedValueClass
1.27 -{
1.28 - return [NSArray class];
1.29 -}
1.30 -
1.31 -+ (BOOL)allowsReverseTransformation
1.32 -{
1.33 - return YES;
1.34 -}
1.35 -
1.36 -- (id)transformedValue:(id)value
1.37 -{
1.38 - if ([value isKindOfClass:[NSArray class]]) {
1.39 - NSMutableArray *transformedArray = [[value mutableCopy] autorelease];
1.40 - [transformedArray replaceObjectAtIndex:[transformedArray indexOfObject:[NSNull null]]
1.41 - withObject:DEFAULT_STRING];
1.42 -
1.43 - return transformedArray;
1.44 -
1.45 - } else if (!value ||
1.46 - [value isKindOfClass:[NSNull class]]) {
1.47 - //A nil or NSNull value is the default itself
1.48 - return DEFAULT_STRING;
1.49 -
1.50 - } else {
1.51 - return value;
1.52 - }
1.53 -}
1.54 -
1.55 -- (id)reverseTransformedValue:(id)value
1.56 -{
1.57 - if ([value isKindOfClass:[NSString class]]) {
1.58 - return ([value isEqualToString:DEFAULT_STRING] ? nil : value);
1.59 - } else {
1.60 - //We don't need to reverse transform the array
1.61 - return value;
1.62 - }
1.63 -}
1.64 -
1.65 -@end