-
Notifications
You must be signed in to change notification settings - Fork 1
/
TWTextTreeDocumentTemplate.m
48 lines (35 loc) · 1.17 KB
/
TWTextTreeDocumentTemplate.m
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
/*
Copyright (C) 2013 Quentin Mathe
Author: Quentin Mathe <[email protected]>
Date: April 2013
License: Modified BSD (see COPYING)
*/
#import "TWTextTreeDocumentTemplate.h"
@implementation TWTextTreeDocumentTemplate
- (BOOL) writeItem: (ETLayoutItem *)anItem
toURL: (NSURL *)aURL
options: (NSDictionary *)options
{
ETAssert([[anItem representedObject] isKindOfClass: [COObject class]]);
[[[anItem representedObject] persistentRoot] commit];
return YES;
}
- (ETLayoutItem *) newItemWithURL: (NSURL *)aURL options: (NSDictionary *)options
{
COEditingContext *editingContext = [COEditingContext currentContext];
NSAssert(editingContext != nil, @"Current editing context must not be nil to create a new item");
ETLayoutItem *item = [super newItemWithURL: aURL options: options];
[editingContext insertNewPersistentRootWithRootObject: [item representedObject]];
return item;
}
- (ETLayoutItem *) contentItem
{
return [(ETLayoutItemGroup *)[super contentItem] itemForIdentifier: @"contentView"];
}
@end
@implementation NSObject (TWOutlinerTextTree)
- (BOOL) isTextGroup
{
return [self conformsToProtocol: @protocol(ETTextGroup)];
}
@end