This repository was archived by the owner on Jul 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCOEditSetMetadata.m
More file actions
63 lines (50 loc) · 1.77 KB
/
COEditSetMetadata.m
File metadata and controls
63 lines (50 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#import "COEditSetMetadata.h"
#import <EtoileFoundation/Macros.h>
@implementation COEditSetMetadata : COEdit
static NSString *kCOOldMetadata = @"COOldMetadata";
static NSString *kCONewMetadata = @"CONewMetadata";
- (id) initWithOldMetadata: (NSDictionary *)oldMeta
newMetadata: (NSDictionary *)newMeta
UUID: (ETUUID*)aUUID
date: (NSDate*)aDate
displayName: (NSString*)aName
{
NILARG_EXCEPTION_TEST(newMeta);
self = [super initWithUUID: aUUID date: aDate displayName: aName];
ASSIGN(old_, [NSDictionary dictionaryWithDictionary: oldMeta]);
ASSIGN(new_, [NSDictionary dictionaryWithDictionary: newMeta]);
return self;
}
- (id) initWithPlist: (id)plist
{
self = [super initWithPlist: plist];
ASSIGN(old_, [plist objectForKey: kCOOldMetadata]);
ASSIGN(new_, [plist objectForKey: kCONewMetadata]);
return self;
}
- (id)plist
{
NSMutableDictionary *result = [NSMutableDictionary dictionary];
[result addEntriesFromDictionary: [super plist]];
[result setObject: old_ forKey: kCOOldMetadata];
[result setObject: new_ forKey: kCONewMetadata];
[result setObject: kCOEditSetMetadata forKey: kCOUndoAction];
return result;
}
- (COEdit *) inverseForApplicationTo: (COPersistentRootInfo *)aProot
{
return [[[[self class] alloc] initWithOldMetadata: new_
newMetadata: old_
UUID: uuid_
date: date_
displayName: displayName_] autorelease];
}
- (void) applyToPersistentRoot: (COPersistentRootInfo *)aProot
{
[aProot setMetadata: new_];
}
+ (BOOL) isUndoable
{
return YES;
}
@end