home *** CD-ROM | disk | FTP | other *** search
- /*
- Copyright (c) 1996, NeXT Software, Inc.
- All rights reserved.
-
- You may freely copy, distribute and reuse the code in this example.
- NeXT disclaims any warranty of any kind, expressed or implied,
- as to its fitness for any particular use.
- */
- #import "CommentInspector.h"
-
- @implementation CommentInspector
-
- - (float)displayOrder {
- return 10.0; // last
- }
-
- - (BOOL)canInspectObject:(id)obj {
- return [obj respondsToSelector:@selector(setUserInfo:)];
- // We apply to all model objects.
- // if we wanted to do entities only, we would do:
- // return [obj isKindOfClass:[EOEntity class]];
- }
-
-
- - (void)refresh
- {
- id selectedObject = [self selectedObject];
- NSString *comment = [[selectedObject userInfo] objectForKey:@"commentString"];
- if (!comment) comment = @"";
- [commentTextView setString:comment];
- }
-
- - (void)refresh:(id)sender {
- [self refresh];
- }
-
- - (void)saveChanges:(id)sender
- {
- id selectedObject = [self selectedObject];
- NSString *commentString = [commentTextView string];
- NSMutableDictionary *userInfo = [[selectedObject userInfo] mutableCopy];
- if (!userInfo) userInfo = [NSMutableDictionary new];
- if ([commentString length] == 0)
- [userInfo removeObjectForKey:@"commentString"];
- else
- [userInfo setObject:commentString forKey:@"commentString"];
- [selectedObject setUserInfo:userInfo];
- [userInfo release];
- }
-
- @end
-