// // P4ServerStatusImageTransformer.m // MBMenuExtra // // Created by Michael Bishop on 12/29/09. // Copyright 2009 Perforce Software. All rights reserved. // #import "P4ServerStatusImageTransformer.h" #import "P4ServerEntry.h" @implementation P4ServerStatusImageTransformer + (Class)transformedValueClass { return [NSImage class]; } + (BOOL)allowsReverseTransformation { return NO; } -(NSImage*)P4m_imageNamed:(NSString*)name { NSBundle *thisBundle = [NSBundle bundleForClass:[self class]]; NSString * imagePath = nil; if (!(imagePath = [thisBundle pathForImageResource:name])) return nil; return [[[NSImage alloc] initByReferencingFile:imagePath] autorelease]; } - (id)transformedValue:(id)value { if (value == nil) return nil; int status = [value intValue]; NSImage * image = nil; if ( status == P4ServerStatusOffline ) image = [self P4m_imageNamed:@"red" ]; else if ( status == P4ServerStatusConnecting ) image = [self P4m_imageNamed:@"yellow" ]; else if ( status == P4ServerStatusError ) image = [self P4m_imageNamed:@"yellow" ]; else if ( status == P4ServerStatusOnline ) image = [self P4m_imageNamed:@"green" ]; return image; } @end @implementation P4ServerStatusMessageTransformer + (Class)transformedValueClass { return [NSImage class]; } + (BOOL)allowsReverseTransformation { return NO; } - (id)transformedValue:(id)value { if (value == nil) return nil; int status = [value intValue]; NSString * message = nil; if ( status == P4ServerStatusOffline ) message = NSLocalizedString( @"Offline", @"Server status message: Offline" ); else if ( status == P4ServerStatusConnecting ) message = NSLocalizedString( @"Connecting...", @"Server status message: Connecting..." ); else if ( status == P4ServerStatusError ) message = NSLocalizedString( @"Connection Error", @"Server status message: Error" ); else if ( status == P4ServerStatusOnline ) message = NSLocalizedString( @"Connected", @"Server status message: Connected" ); return message; } @end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 20722 | jdputsch | initial branch, prep for -Zapp= support | ||
//guest/michael_bishop/MacMenu/src/P4Menu/Source/P4ServerStatusImageTransformer.m | |||||
#1 | 8331 | Matt Attaway |
Adding initial version of MacMenu for Perforce MacMenu is a helpful Perforce client that sits in your toolbar. It allows you to run standard Perforce operations on the document that is open the currently active editor/viewer. |