OSDN Git Service

HMJSONViewWindowControllerをSwiftに変換した
authormasakih <masakih@users.sourceforge.jp>
Thu, 5 Jan 2017 12:10:51 +0000 (21:10 +0900)
committermasakih <masakih@users.sourceforge.jp>
Thu, 5 Jan 2017 12:10:51 +0000 (21:10 +0900)
KCD.xcodeproj/project.pbxproj
KCD/HMAppDelegate.h
KCD/HMJSONViewCommand.m
KCD/HMJSONViewWindowController.h [deleted file]
KCD/HMJSONViewWindowController.m [deleted file]
KCD/HMJSONViewWindowController.swift [new file with mode: 0644]

index 394b1bd..0356fc9 100644 (file)
@@ -82,7 +82,6 @@
                F471784A1B6F9B5600F5E59D /* ResourceHistory.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = F47178481B6F9B5600F5E59D /* ResourceHistory.xcdatamodeld */; };
                F471784D1B6FA18800F5E59D /* HMKCResource.m in Sources */ = {isa = PBXBuildFile; fileRef = F471784C1B6FA18800F5E59D /* HMKCResource.m */; };
                F47178501B6FA1B300F5E59D /* HMResourceHistoryDataStore.m in Sources */ = {isa = PBXBuildFile; fileRef = F471784F1B6FA1B300F5E59D /* HMResourceHistoryDataStore.m */; };
-               F47B78B218A7B42B0011386E /* HMJSONViewWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = F47B78B018A7B42B0011386E /* HMJSONViewWindowController.m */; };
                F48A704D1DE326F0005DFC0B /* HMAirBaseCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F48A704C1DE326F0005DFC0B /* HMAirBaseCommand.m */; };
                F48A70501DE32847005DFC0B /* HMMapInfoCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F48A704F1DE32847005DFC0B /* HMMapInfoCommand.m */; };
                F48A705C1DE58A38005DFC0B /* HMKCAirBase+CoreDataClass.m in Sources */ = {isa = PBXBuildFile; fileRef = F48A70551DE58A38005DFC0B /* HMKCAirBase+CoreDataClass.m */; };
                F4AA594C1E1E497C001667AF /* HMEquipmentWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4AA594B1E1E497C001667AF /* HMEquipmentWindowController.swift */; };
                F4AA594E1E1E4A7C001667AF /* HMUITestWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4AA594D1E1E4A7C001667AF /* HMUITestWindowController.swift */; };
                F4AA59501E1E4D18001667AF /* HMShipWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4AA594F1E1E4D18001667AF /* HMShipWindowController.swift */; };
+               F4AA59521E1E607F001667AF /* HMJSONViewWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4AA59511E1E607F001667AF /* HMJSONViewWindowController.swift */; };
                F4AC136D1E0802C000851147 /* HMPreferencePanelController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4AC136C1E0802C000851147 /* HMPreferencePanelController.swift */; };
                F4AC136F1E0963DB00851147 /* HMProgressPanel.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4AC136E1E0963DB00851147 /* HMProgressPanel.swift */; };
                F4AC13711E096A7B00851147 /* HMHistoryWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4AC13701E096A7B00851147 /* HMHistoryWindowController.swift */; };
                F471784C1B6FA18800F5E59D /* HMKCResource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMKCResource.m; sourceTree = "<group>"; };
                F471784E1B6FA1B300F5E59D /* HMResourceHistoryDataStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMResourceHistoryDataStore.h; sourceTree = "<group>"; };
                F471784F1B6FA1B300F5E59D /* HMResourceHistoryDataStore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMResourceHistoryDataStore.m; sourceTree = "<group>"; };
-               F47B78AF18A7B42B0011386E /* HMJSONViewWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMJSONViewWindowController.h; sourceTree = "<group>"; };
-               F47B78B018A7B42B0011386E /* HMJSONViewWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMJSONViewWindowController.m; sourceTree = "<group>"; };
                F48A704B1DE326F0005DFC0B /* HMAirBaseCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMAirBaseCommand.h; sourceTree = "<group>"; };
                F48A704C1DE326F0005DFC0B /* HMAirBaseCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMAirBaseCommand.m; sourceTree = "<group>"; };
                F48A704E1DE32847005DFC0B /* HMMapInfoCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMMapInfoCommand.h; sourceTree = "<group>"; };
                F4AA594B1E1E497C001667AF /* HMEquipmentWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMEquipmentWindowController.swift; sourceTree = "<group>"; };
                F4AA594D1E1E4A7C001667AF /* HMUITestWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMUITestWindowController.swift; sourceTree = "<group>"; };
                F4AA594F1E1E4D18001667AF /* HMShipWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMShipWindowController.swift; sourceTree = "<group>"; };
+               F4AA59511E1E607F001667AF /* HMJSONViewWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMJSONViewWindowController.swift; sourceTree = "<group>"; };
                F4AC136C1E0802C000851147 /* HMPreferencePanelController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMPreferencePanelController.swift; sourceTree = "<group>"; };
                F4AC136E1E0963DB00851147 /* HMProgressPanel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMProgressPanel.swift; sourceTree = "<group>"; };
                F4AC13701E096A7B00851147 /* HMHistoryWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMHistoryWindowController.swift; sourceTree = "<group>"; };
                                F4FDF23E1A3D50420033E0AD /* HMShipMasterDetailWindowController.h */,
                                F4FDF23F1A3D50420033E0AD /* HMShipMasterDetailWindowController.m */,
                                F4BEF00D1B11A628004702B8 /* HMShipMasterDetailWindowController.xib */,
-                               F47B78AF18A7B42B0011386E /* HMJSONViewWindowController.h */,
-                               F47B78B018A7B42B0011386E /* HMJSONViewWindowController.m */,
+                               F4AA59511E1E607F001667AF /* HMJSONViewWindowController.swift */,
                                F4B3DC3B18E5C8700011B4FC /* HMJSONViewWindowController.xib */,
                                F4AA594F1E1E4D18001667AF /* HMShipWindowController.swift */,
                                F4B3DC3818E5C8650011B4FC /* HMShipWindowController.xib */,
                                F4666C641B25CA3E001840DB /* HMKCQuest+Extensions.m in Sources */,
                                F4F9F8A91C796C2E00D0EE76 /* HMChangeHenseiNotification.m in Sources */,
                                F43BA4A1197BE22200CFF788 /* HMDestroyShipCommand.m in Sources */,
-                               F47B78B218A7B42B0011386E /* HMJSONViewWindowController.m in Sources */,
                                F4B414EF18B0BF1A00468DAF /* HMMasterMapInfoCommand.m in Sources */,
                                F4B3DC1B18DEAB5E0011B4FC /* HMKaihatuHistory.m in Sources */,
                                F49097871E1A85F70085A45D /* HMImageView.swift in Sources */,
                                F4D05BDF1E0F8B6900688D66 /* HMPowerUpSupportViewController.swift in Sources */,
                                F4F6E82A1B3045970008B66E /* CanonicalRequest.m in Sources */,
                                F4E5FF021E150A850026868C /* HMAncherageRepairTimerViewController.swift in Sources */,
+                               F4AA59521E1E607F001667AF /* HMJSONViewWindowController.swift in Sources */,
                                F4B414F218B1013C00468DAF /* HMMasterSlotItemCommand.m in Sources */,
                                F45FBB6F1E0FDB33000E72B9 /* HMStrengthenListViewController.swift in Sources */,
                                F4AA59281E1CEF8E001667AF /* HMPlanToShowsBoldFontTransformer.swift in Sources */,
index 04d2487..86fad41 100644 (file)
@@ -8,13 +8,15 @@
 
 #import <Cocoa/Cocoa.h>
 
-#import "HMJSONViewWindowController.h"
-
 @class HMFleetManager;
 @class HMExternalBrowserWindowController;
 
 @class HMScreenshotListWindowController;
 
+#if ENABLE_JSON_LOG
+@class HMJSONViewWindowController;
+#endif
+
 @interface HMAppDelegate : NSObject <NSApplicationDelegate>
 
 - (void)logLineReturn:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
index 3397759..d1fe234 100644 (file)
@@ -9,6 +9,8 @@
 #import "HMJSONViewCommand.h"
 #import "HMAppDelegate.h"
 
+#import "KCD-Swift.h"
+
 #if ENABLE_JSON_LOG
 
 
diff --git a/KCD/HMJSONViewWindowController.h b/KCD/HMJSONViewWindowController.h
deleted file mode 100644 (file)
index fc0a7ea..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-//
-//  HMJSONViewWindowController.h
-//  KCD
-//
-//  Created by Hori,Masaki on 2014/02/09.
-//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import <Cocoa/Cocoa.h>
-
-#ifdef DEBUG
-
-@interface HMJSONViewWindowController : NSWindowController
-
-@property (nonatomic, strong, readonly) NSMutableArray *commands;
-
-- (void)setCommand:(NSDictionary *)command;
-
-- (void)setCommandArray:(NSArray *)commands;
-
-
-- (IBAction)clearLog:(id)sender;
-
-
-@end
-
-#endif
diff --git a/KCD/HMJSONViewWindowController.m b/KCD/HMJSONViewWindowController.m
deleted file mode 100644 (file)
index 213a719..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-//
-//  HMJSONViewWindowController.m
-//  KCD
-//
-//  Created by Hori,Masaki on 2014/02/09.
-//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#ifdef DEBUG
-
-#import "HMJSONViewWindowController.h"
-
-@interface HMJSONViewWindowController ()
-@property (nonatomic, weak) IBOutlet NSTableView *argumentsView;
-@property (nonatomic, weak) IBOutlet NSOutlineView *jsonView;
-
-@property (nonatomic, strong) IBOutlet NSArrayController *apis;
-
-@property (nonatomic, strong, readwrite) NSMutableArray *commands;
-
-@property (weak) NSArray *arguments;
-@property (weak, readwrite) id json;
-@end
-
-@implementation HMJSONViewWindowController
-
-- (id)init
-{
-       self = [super initWithWindowNibName:NSStringFromClass([self class])];
-       if(self) {
-               _commands = [NSMutableArray new];
-       }
-       return self;
-}
-
-- (void)awakeFromNib
-{
-       [self.apis addObserver:self
-                               forKeyPath:@"selection"
-                                  options:NSKeyValueObservingOptionNew
-                                  context:NULL];
-}
-
-- (void)setCommand:(NSDictionary *)command
-{
-       [self willChangeValueForKey:@"commands"];
-       [self.commands addObject:command];
-       [self didChangeValueForKey:@"commands"];
-}
-- (void)setCommandArray:(NSArray *)commands
-{
-       [self willChangeValueForKey:@"commands"];
-       [self.commands addObjectsFromArray:commands];
-       [self didChangeValueForKey:@"commands"];
-}
-
-- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
-{
-       if([keyPath isEqualToString:@"selection"]) {
-               [self willChangeValueForKey:@"arguments"];
-               self.arguments = [self.apis valueForKeyPath:@"selection.argument"];
-               [self didChangeValueForKey:@"arguments"];
-               
-               [self willChangeValueForKey:@"json"];
-               self.json = [self.apis valueForKeyPath:@"selection.json"];
-               [self didChangeValueForKey:@"json"];
-                               
-               return;
-       }
-       
-       [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
-}
-
-- (IBAction)clearLog:(id)sender
-{
-       [self willChangeValueForKey:@"commands"];
-       [self.commands removeAllObjects];
-       [self didChangeValueForKey:@"commands"];
-}
-
-@end
-
-#endif
diff --git a/KCD/HMJSONViewWindowController.swift b/KCD/HMJSONViewWindowController.swift
new file mode 100644 (file)
index 0000000..de3f734
--- /dev/null
@@ -0,0 +1,64 @@
+//
+//  HMJSONViewWindowController.swift
+//  KCD
+//
+//  Created by Hori,Masaki on 2017/01/05.
+//  Copyright © 2017年 Hori,Masaki. All rights reserved.
+//
+
+import Cocoa
+
+#if DEBUG
+class HMJSONViewWindowController: NSWindowController {
+    override var windowNibName: String! {
+        return "HMJSONViewWindowController"
+    }
+    override func windowDidLoad() {
+        super.windowDidLoad()
+    
+        apis.addObserver(self, forKeyPath: "selection", context: nil)
+    }
+    
+    var commands: NSMutableArray = []
+    
+    @IBOutlet var argumentsView: NSTableView!
+    @IBOutlet var jsonView: NSOutlineView!
+    @IBOutlet var apis: NSArrayController!
+    
+    var arguments: NSArray?
+    var json: AnyObject?
+    
+    func setCommand(_ command: NSDictionary) {
+        willChangeValue(forKey: "commands")
+        commands.add(command)
+        didChangeValue(forKey: "commands")
+    }
+    func setCommandArray(_ commands: NSArray) {
+        willChangeValue(forKey: "commands")
+        self.commands.addObjects(from: commands as! [Any])
+        didChangeValue(forKey: "commands")
+    }
+    
+    override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
+        if keyPath == "selection" {
+            willChangeValue(forKey: "selection")
+            arguments = apis.value(forKeyPath: "selection.argument") as! NSArray?
+            didChangeValue(forKey: "selection")
+            
+            willChangeValue(forKey: "json")
+            json = apis.value(forKeyPath: "selection.json") as AnyObject?
+            didChangeValue(forKey: "json")
+            
+            return
+        }
+        
+        super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context)
+    }
+    
+    @IBAction func clearLog(_ sender: AnyObject?) {
+        willChangeValue(forKey: "commands")
+        commands.removeAllObjects()
+        didChangeValue(forKey: "commands")
+    }
+}
+#endif