OSDN Git Service

いろいろ追加
[kcd/KCD.git] / KCD / HMJSONViewWindowController.m
1 //
2 //  HMJSONViewWindowController.m
3 //  KCD
4 //
5 //  Created by Hori,Masaki on 2014/02/09.
6 //  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
7 //
8
9 #import "HMJSONViewWindowController.h"
10
11 @interface HMJSONViewWindowController ()
12 @property (retain, readwrite) NSMutableArray *commands;
13
14 @property (assign, readwrite) id json;
15 @end
16
17 @implementation HMJSONViewWindowController
18
19 - (id)init
20 {
21         self = [super initWithWindowNibName:NSStringFromClass([self class])];
22         if(self) {
23                 _commands = [NSMutableArray new];
24         }
25         return self;
26 }
27
28 - (void)awakeFromNib
29 {
30         [self.apis addObserver:self
31                                 forKeyPath:@"selection"
32                                    options:NSKeyValueObservingOptionNew
33                                    context:NULL];
34 }
35
36 - (void)setCommand:(NSDictionary *)command
37 {
38         [self willChangeValueForKey:@"commands"];
39         [self.commands addObject:command];
40         [self didChangeValueForKey:@"commands"];
41 }
42
43 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
44 {
45         if([keyPath isEqualToString:@"selection"]) {
46                 [self willChangeValueForKey:@"arguments"];
47                 self.arguments = [self.apis valueForKeyPath:@"selection.argument"];
48                 [self didChangeValueForKey:@"arguments"];
49                 
50                 [self willChangeValueForKey:@"json"];
51                 self.json = [self.apis valueForKeyPath:@"selection.json"];
52                 [self didChangeValueForKey:@"json"];
53                 
54 //              [self.argumentsView reloadData];
55                 [self.jsonView reloadData];
56                 
57                 return;
58         }
59         
60         [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
61 }
62
63
64 - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
65 {
66         return 0;
67 }
68 - (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
69 {
70         return nil;
71 }
72 - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
73 {
74         return NO;
75 }
76 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
77 {
78         return nil;
79 }
80
81 @end