/ConnectionWindowTitleTransformer.m

http://github.com/bububa/MongoHub-Mac · Objective C · 34 lines · 22 code · 5 blank · 7 comment · 3 complexity · 4dc83985c598c1f5d293c3f99e9e2e09 MD5 · raw file

  1. //
  2. // ConnectionWindowTitleTransformer.m
  3. // MongoHub
  4. //
  5. // Created by Syd on 10-4-25.
  6. // Copyright 2010 MusicPeace.ORG. All rights reserved.
  7. //
  8. #import "ConnectionWindowTitleTransformer.h"
  9. #import "Connection.h"
  10. @implementation ConnectionWindowTitleTransformer
  11. + (Class)transformedValueClass {
  12. return [NSString class];
  13. }
  14. + (BOOL)allowsReverseTransformation {
  15. return NO;
  16. }
  17. - (id)transformedValue:(id)value
  18. {
  19. if (value)
  20. {
  21. if ([[value userepl] intValue] == 1) {
  22. return [NSString stringWithFormat:@"%@ [%@]", [value alias], [value repl_name] ];
  23. }else {
  24. return [NSString stringWithFormat:@"%@ [%@:%@]", [value alias], [value host], [value hostport] ];
  25. }
  26. }
  27. return nil;
  28. }
  29. @end