OSDN Git Service

UAをVersion/10.0.3 Safari/602.4.8に変更
[kcd/KCD.git] / KCD / JSONViewWindowController.swift
1 //
2 //  JSONViewWindowController.swift
3 //  KCD
4 //
5 //  Created by Hori,Masaki on 2017/01/05.
6 //  Copyright © 2017年 Hori,Masaki. All rights reserved.
7 //
8
9 import Cocoa
10
11 class JSONViewWindowController: NSWindowController {
12     deinit {
13         unbind("arguments")
14         unbind("json")
15     }
16     
17     @IBOutlet var argumentsView: NSTableView!
18     @IBOutlet var jsonView: NSOutlineView!
19     @IBOutlet var apis: NSArrayController!
20     
21     override var windowNibName: String! {
22         return "JSONViewWindowController"
23     }
24     
25     var arguments: NSArray?
26     var json: AnyObject?
27     var commands: [[String: Any]] = []
28     
29     override func windowDidLoad() {
30         super.windowDidLoad()
31         
32         bind("arguments", to: apis, withKeyPath: "selection.argument")
33         bind("json", to: apis, withKeyPath: "selection.json")
34     }
35     
36     func setCommand(_ command: [String: Any]) {
37         willChangeValue(forKey: "commands")
38         commands += [command]
39         didChangeValue(forKey: "commands")
40     }
41 //    func setCommandArray(_ commands: NSArray) {
42 //        willChangeValue(forKey: "commands")
43 //        self.commands.addObjects(from: commands as! [Any])
44 //        didChangeValue(forKey: "commands")
45 //    }
46     
47     @IBAction func clearLog(_ sender: AnyObject?) {
48         willChangeValue(forKey: "commands")
49         commands = []
50         didChangeValue(forKey: "commands")
51     }
52 }