home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / EODEV.Z / CommentInspector.m < prev    next >
Encoding:
Text File  |  1996-08-23  |  1.4 KB  |  52 lines

  1. /*
  2.         Copyright (c) 1996, NeXT Software, Inc.
  3.         All rights reserved.
  4.  
  5.         You may freely copy, distribute and reuse the code in this example.
  6.         NeXT disclaims any warranty of any kind, expressed or implied,
  7.         as to its fitness for any particular use.
  8. */
  9. #import "CommentInspector.h"
  10.  
  11. @implementation CommentInspector
  12.  
  13. - (float)displayOrder {
  14.     return 10.0; // last
  15. }
  16.  
  17. - (BOOL)canInspectObject:(id)obj {
  18.     return [obj respondsToSelector:@selector(setUserInfo:)];
  19.                 // We apply to all model objects.
  20.                 // if we wanted to do entities only, we would do:
  21.                 // return [obj isKindOfClass:[EOEntity class]];
  22. }
  23.  
  24.  
  25. - (void)refresh
  26. {
  27.     id selectedObject = [self selectedObject];
  28.     NSString *comment = [[selectedObject userInfo] objectForKey:@"commentString"];
  29.     if (!comment) comment = @"";
  30.     [commentTextView setString:comment];
  31. }
  32.  
  33. - (void)refresh:(id)sender {
  34.     [self refresh];
  35. }
  36.  
  37. - (void)saveChanges:(id)sender
  38. {
  39.     id selectedObject = [self selectedObject];
  40.     NSString *commentString = [commentTextView string];
  41.     NSMutableDictionary *userInfo = [[selectedObject userInfo] mutableCopy];
  42.     if (!userInfo) userInfo = [NSMutableDictionary new];
  43.     if ([commentString length] == 0)
  44.         [userInfo removeObjectForKey:@"commentString"];
  45.     else
  46.         [userInfo setObject:commentString forKey:@"commentString"];
  47.     [selectedObject setUserInfo:userInfo];
  48.     [userInfo release];
  49. }
  50.  
  51. @end
  52.