OSDN Git Service

HMHistoryWindowControllerクラスをSwiftで書き換え
authormasakih <masakih@users.sourceforge.jp>
Sun, 21 Dec 2014 08:52:33 +0000 (17:52 +0900)
committermasakih <masakih@users.sourceforge.jp>
Sun, 21 Dec 2014 08:52:33 +0000 (17:52 +0900)
KCD.xcodeproj/project.pbxproj
KCD/HMAppDelegate.m
KCD/HMHistoryWindowController.h [deleted file]
KCD/HMHistoryWindowController.m [deleted file]
KCD/HMHistoryWindowController.swift [new file with mode: 0644]
KCD/KCD-Bridging-Header.h
KCD/ja.lproj/HMHistoryWindowController.xib

index 6fbc139..db21385 100644 (file)
@@ -43,6 +43,7 @@
                F4513EF618B9F29800073552 /* HMMemberShipCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4513EF518B9F29800073552 /* HMMemberShipCommand.m */; };
                F4513EFA18BB699700073552 /* HMShipWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4513EF818BB699700073552 /* HMShipWindowController.m */; };
                F454F7831A261844003042DD /* HMFleetInformation.m in Sources */ = {isa = PBXBuildFile; fileRef = F454F7821A261844003042DD /* HMFleetInformation.m */; };
+               F4551BDC1A46A9D100BB0235 /* HMHistoryWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4551BDB1A46A9D100BB0235 /* HMHistoryWindowController.swift */; };
                F46F103618A7CE310063E503 /* HMJSONViewCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F46F103518A7CE310063E503 /* HMJSONViewCommand.m */; };
                F46F104118A9B85E0063E503 /* HMJSONNode.m in Sources */ = {isa = PBXBuildFile; fileRef = F46F104018A9B85E0063E503 /* HMJSONNode.m */; };
                F46F104518AA50730063E503 /* HMBroserWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = F46F104318AA50730063E503 /* HMBroserWindowController.m */; };
@@ -95,7 +96,6 @@
                F4B3DC2118DECF570011B4FC /* HMTSVSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B3DC2018DECF570011B4FC /* HMTSVSupport.m */; };
                F4B3DC2718DF2F360011B4FC /* HMKenzoMark.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B3DC2618DF2F360011B4FC /* HMKenzoMark.m */; };
                F4B3DC2A18DF31400011B4FC /* HMCreateShipCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B3DC2918DF31400011B4FC /* HMCreateShipCommand.m */; };
-               F4B3DC2E18E07B680011B4FC /* HMHistoryWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = F4B3DC2C18E07B680011B4FC /* HMHistoryWindowController.m */; };
                F4B3DC3018E5C81E0011B4FC /* HMHistoryWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4B3DC3218E5C81E0011B4FC /* HMHistoryWindowController.xib */; };
                F4B3DC3318E5C8520011B4FC /* HMShipViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4B3DC3518E5C8520011B4FC /* HMShipViewController.xib */; };
                F4B3DC3618E5C8650011B4FC /* HMShipWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = F4B3DC3818E5C8650011B4FC /* HMShipWindowController.xib */; };
                F4513EF818BB699700073552 /* HMShipWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMShipWindowController.m; sourceTree = "<group>"; };
                F454F7811A261844003042DD /* HMFleetInformation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMFleetInformation.h; sourceTree = "<group>"; };
                F454F7821A261844003042DD /* HMFleetInformation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMFleetInformation.m; sourceTree = "<group>"; };
+               F4551BDB1A46A9D100BB0235 /* HMHistoryWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HMHistoryWindowController.swift; sourceTree = "<group>"; };
                F46F103418A7CE310063E503 /* HMJSONViewCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMJSONViewCommand.h; sourceTree = "<group>"; };
                F46F103518A7CE310063E503 /* HMJSONViewCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMJSONViewCommand.m; sourceTree = "<group>"; };
                F46F103F18A9B85E0063E503 /* HMJSONNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMJSONNode.h; sourceTree = "<group>"; };
                F4B3DC2618DF2F360011B4FC /* HMKenzoMark.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMKenzoMark.m; sourceTree = "<group>"; };
                F4B3DC2818DF31400011B4FC /* HMCreateShipCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMCreateShipCommand.h; sourceTree = "<group>"; };
                F4B3DC2918DF31400011B4FC /* HMCreateShipCommand.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMCreateShipCommand.m; sourceTree = "<group>"; };
-               F4B3DC2B18E07B680011B4FC /* HMHistoryWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HMHistoryWindowController.h; sourceTree = "<group>"; };
-               F4B3DC2C18E07B680011B4FC /* HMHistoryWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HMHistoryWindowController.m; sourceTree = "<group>"; };
                F4B3DC3118E5C81E0011B4FC /* ja */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ja; path = ja.lproj/HMHistoryWindowController.xib; sourceTree = "<group>"; };
                F4B3DC3418E5C8520011B4FC /* ja */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ja; path = ja.lproj/HMShipViewController.xib; sourceTree = "<group>"; };
                F4B3DC3718E5C8650011B4FC /* ja */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = ja; path = ja.lproj/HMShipWindowController.xib; sourceTree = "<group>"; };
                                F494DC6518C8BA6400AE97E4 /* HMPowerUpSupportViewController.h */,
                                F494DC6618C8BA6400AE97E4 /* HMPowerUpSupportViewController.m */,
                                F494DC6818C8BAB900AE97E4 /* HMPowerUpSupportViewController.xib */,
-                               F4B3DC2B18E07B680011B4FC /* HMHistoryWindowController.h */,
-                               F4B3DC2C18E07B680011B4FC /* HMHistoryWindowController.m */,
+                               F4551BDB1A46A9D100BB0235 /* HMHistoryWindowController.swift */,
                                F4B3DC3218E5C81E0011B4FC /* HMHistoryWindowController.xib */,
                                F4B3DC4F18F150CD0011B4FC /* HMScreenshotWindowController.h */,
                                F4B3DC5018F150CD0011B4FC /* HMScreenshotWindowController.m */,
                                F426802E194D0FFD00B2C27F /* HMMemberShip3Command.m in Sources */,
                                F4B37EF319FBBBED002F371A /* HMRemodelSlotCommand.m in Sources */,
                                F4B414FB18B1FB6C00468DAF /* HMMasterMapCellCommand.m in Sources */,
-                               F4B3DC2E18E07B680011B4FC /* HMHistoryWindowController.m in Sources */,
                                F4C118FA18A67B1C005D5B25 /* CacheStoragePolicy.m in Sources */,
                                F4A3AD9219BDDD8E00FDBF80 /* HMPreferencePanelController.m in Sources */,
                                F4B2A08F1A1F9C2100D2EF12 /* HMExternalBrowserWindowController.m in Sources */,
                                F4B1E30819C73B6A00805879 /* HMSuppliesCell.m in Sources */,
                                F4A3AD8E19BB220000FDBF80 /* HMMaskInfomation.m in Sources */,
                                F4E7802E18DC3AF00011BC4C /* LocalData.xcdatamodeld in Sources */,
+                               F4551BDC1A46A9D100BB0235 /* HMHistoryWindowController.swift in Sources */,
                                F4131ED5190F63D8004F7F9A /* HMUpdateSlotItemCommand.m in Sources */,
                                F4C1190518A71AEA005D5B25 /* HMJSONReciever.m in Sources */,
                                F44AB24119E8252600F217AF /* HMKCSlotItemObject+Extensions.m in Sources */,
index d9257dd..a2908b5 100644 (file)
@@ -10,7 +10,6 @@
 
 #import "HMUserDefaults.h"
 #import "HMBroserWindowController.h"
-#import "HMHistoryWindowController.h"
 #import "HMPreferencePanelController.h"
 #import "HMScreenshotListWindowController.h"
 #import "HMShipMasterDetailWindowController.h"
 - (IBAction)showHideHistory:(id)sender
 {
        if(!self.historyWindowController) {
-               self.historyWindowController = [HMHistoryWindowController new];
+               self.historyWindowController = [HMHistoryWindowController create];
        }
        
        NSWindow *window = self.historyWindowController.window;
diff --git a/KCD/HMHistoryWindowController.h b/KCD/HMHistoryWindowController.h
deleted file mode 100644 (file)
index 0bc5c11..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-//
-//  HMHistoryWindowController.h
-//  KCD
-//
-//  Created by Hori,Masaki on 2014/03/24.
-//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import <Cocoa/Cocoa.h>
-
-@interface HMHistoryWindowController : NSWindowController <NSTabViewDelegate>
-
-@property (weak) IBOutlet NSArrayController *kaihatuHistoryController;
-@property (weak) IBOutlet NSArrayController *kenzoHistoryController;
-
-@property (readonly) NSManagedObjectContext *manageObjectContext;
-
-@property NSInteger selectedTabIndex;
-
-@end
diff --git a/KCD/HMHistoryWindowController.m b/KCD/HMHistoryWindowController.m
deleted file mode 100644 (file)
index 8accd49..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-//
-//  HMHistoryWindowController.m
-//  KCD
-//
-//  Created by Hori,Masaki on 2014/03/24.
-//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
-//
-
-#import "HMHistoryWindowController.h"
-
-#import "HMLocalDataStore.h"
-
-typedef NS_ENUM(NSUInteger, HMHistoryWindowTabIndex) {
-       kKaihatuHistoryIndex = 0,
-       kKenzoHistoryIndex = 1
-};
-
-@interface HMHistoryWindowController ()
-
-@end
-
-@implementation HMHistoryWindowController
-
-- (id)init
-{
-       self = [super initWithWindowNibName:NSStringFromClass([self class])];
-       
-       return self;
-}
-
-- (NSManagedObjectContext *)manageObjectContext
-{
-       return [[HMLocalDataStore defaultManager] managedObjectContext];
-}
-
-- (IBAction)delete:(id)sender
-{
-       NSArrayController *target = nil;
-       switch (self.selectedTabIndex) {
-               case kKaihatuHistoryIndex:
-                       target = self.kaihatuHistoryController;
-                       break;
-               case kKenzoHistoryIndex:
-                       target = self.kenzoHistoryController;
-                       break;
-                       
-       }
-       
-       if(!target) return;
-       
-       NSArray *original = [target selectedObjects];
-       NSMutableArray *objectIds = [NSMutableArray new];
-       for(NSManagedObject *object in original) {
-               [objectIds addObject:object.objectID];
-       }
-       
-       HMLocalDataStore *store = [HMLocalDataStore oneTimeEditor];
-       NSManagedObjectContext *moc = store.managedObjectContext;
-       
-       for(NSManagedObjectID *objectID in objectIds) {
-               NSManagedObject *object = [moc objectWithID:objectID];
-               [moc deleteObject:object];
-       }
-}
-
-@end
diff --git a/KCD/HMHistoryWindowController.swift b/KCD/HMHistoryWindowController.swift
new file mode 100644 (file)
index 0000000..3184276
--- /dev/null
@@ -0,0 +1,74 @@
+//
+//  HMHistoryWindowController.swift
+//  KCD
+//
+//  Created by Hori,Masaki on 2014/12/21.
+//  Copyright (c) 2014年 Hori,Masaki. All rights reserved.
+//
+
+import Cocoa
+
+class HMHistoryWindowController: NSWindowController
+{
+       override init() {
+               super.init()
+       }
+       override init(window: NSWindow?) {
+               super.init(window: window)
+       }
+       required init?(coder: NSCoder) {
+               super.init(coder: coder)
+       }
+       
+       class func create() -> HMHistoryWindowController {
+               return HMHistoryWindowController.init(windowNibName:"HMHistoryWindowController")
+       }
+       
+       var managedObjectContext : NSManagedObjectContext {
+               return HMLocalDataStore.defaultManager().managedObjectContext
+       }
+       
+       @IBOutlet var kaihatuHistoryController : NSArrayController?
+       @IBOutlet var kenzoHistoryController : NSArrayController?
+       
+       var selectedTabIndex : Int = 0
+       
+       enum HMHistoryWindowTabIndex : Int {
+               case kKaihatuHistoryIndex = 0
+               case kKenzoHistoryIndex
+       }
+       
+       @IBAction func delete(aSender: AnyObject?) {
+               var sender = aSender as? NSMenuItem
+               if sender == nil {
+                       return
+               }
+               
+               let tag = HMHistoryWindowTabIndex(rawValue: sender!.tag)!
+               var target : NSArrayController? = nil
+               switch tag {
+               case .kKaihatuHistoryIndex:
+                       target = kaihatuHistoryController
+               case .kKenzoHistoryIndex:
+                       target = kenzoHistoryController
+               }
+               
+               if target == nil {
+                       return
+               }
+               
+               let original = target!.selectedObjects
+               let objectIds = NSMutableArray()
+               for object in original {
+                       objectIds.addObject(object.objectID)
+               }
+               
+               let store = HMLocalDataStore.oneTimeEditor()
+               let moc = store.managedObjectContext
+               
+               for objectID in objectIds {
+                       let object = moc.objectWithID(objectID as NSManagedObjectID)
+                       moc.deleteObject(object)
+               }
+       }
+}
index 226bee0..50601c6 100644 (file)
@@ -8,3 +8,4 @@
 
 
 #import "HMServerDataStore.h"
+#import "HMLocalDataStore.h"
index bfdb5fa..daa93f0 100644 (file)
@@ -5,7 +5,7 @@
         <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="HMHistoryWindowController">
+        <customObject id="-2" userLabel="File's Owner" customClass="HMHistoryWindowController" customModule="KCD" customModuleProvider="target">
             <connections>
                 <outlet property="kaihatuHistoryController" destination="cv5-a8-9nJ" id="2aT-cr-G32"/>
                 <outlet property="kenzoHistoryController" destination="9pH-dt-0h6" id="loK-C7-3pa"/>
         </window>
         <arrayController mode="entity" entityName="KaihatuHistory" editable="NO" automaticallyPreparesContent="YES" automaticallyRearrangesObjects="YES" id="cv5-a8-9nJ" userLabel="KaihatuHistory">
             <connections>
-                <binding destination="-2" name="managedObjectContext" keyPath="manageObjectContext" id="REH-UB-fGs"/>
+                <binding destination="-2" name="managedObjectContext" keyPath="managedObjectContext" id="2wx-7O-UVY"/>
                 <binding destination="-2" name="editable" keyPath="self" id="XNG-Uh-r3e">
                     <dictionary key="options">
                         <string key="NSValueTransformerName">NSIsNil</string>
         </arrayController>
         <arrayController mode="entity" entityName="KenzoHistory" editable="NO" automaticallyPreparesContent="YES" automaticallyRearrangesObjects="YES" id="9pH-dt-0h6" userLabel="KenzoHistory">
             <connections>
-                <binding destination="-2" name="managedObjectContext" keyPath="manageObjectContext" id="Oj9-1u-97D"/>
+                <binding destination="-2" name="managedObjectContext" keyPath="managedObjectContext" id="Zqx-nl-Blc"/>
                 <binding destination="-2" name="editable" keyPath="self" id="fwV-5V-aES">
                     <dictionary key="options">
                         <string key="NSValueTransformerName">NSIsNil</string>