<commit_before>//
//  TrainCodeDetailViewController.swift
//  12306ForMac
//
//  Created by fancymax on 2016/06/12.
//  Copyright © 2016年 fancy. All rights reserved.
//

import Cocoa

class TrainCodeDetailViewController: NSViewController {
    var service = Service()
    var queryByTrainCodeParam: QueryByTrainCodeParam! {
        didSet{
//            print("\(queryByTrainCodeParam.ToGetParams())")
            if oldValue != nil {
                if oldValue.ToGetParams() == queryByTrainCodeParam.ToGetParams() {
                    return
                }
            }
            
            let successHandler = { (trainDetails:TrainCodeDetails)->()  in
                self.trainCodeDetails = trainDetails
                self.trainCodeDetailTable.reloadData()
                self.trainCodeDetailTable.scrollRowToVisible(0)
//
//                self.stopLoadingTip()
            }
            
            let failureHandler = {(error:NSError)->() in
//                self.stopLoadingTip()
//                self.ticketQueryResult = [QueryLeftNewDTO]()
//                self.leftTicketTable.reloadData()
//                
//                self.tips.show(translate(error), forDuration: 1, withFlash: false)
            }
            
            service.queryTrainNoFlowWith(queryByTrainCodeParam, success: successHandler, failure: failureHandler)
        }
    }
    @IBOutlet weak var trainCodeDetailTable: NSTableView!
    
    var trainCodeDetails: TrainCodeDetails?

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // setup Table Header
        for col in trainCodeDetailTable.tableColumns {
            col.headerCell = TrainCodeDetailHeaderCell(textCell: col.headerCell.stringValue)
            col.headerCell.alignment = .Center
        }
    }
    
}

// MARK: - NSTableViewDataSource 
extension TrainCodeDetailViewController: NSTableViewDataSource{
    func numberOfRowsInTableView(tableView: NSTableView) -> Int {
        if trainCodeDetails == nil {
            return 0
        }
        return trainCodeDetails!.trainNos.count
    }
    
    func tableView(tableView: NSTableView, objectValueForTableColumn tableColumn: NSTableColumn?, row: Int) -> AnyObject? {
        if trainCodeDetails == nil {
            return nil
        }
        return trainCodeDetails!.trainNos[row]
    }
}<commit_msg>improve traincode Detail<commit_after>//
//  TrainCodeDetailViewController.swift
//  12306ForMac
//
//  Created by fancymax on 2016/06/12.
//  Copyright © 2016年 fancy. All rights reserved.
//

import Cocoa

class TrainCodeDetailViewController: NSViewController {
    var service = Service()
    
    var queryByTrainCodeParam: QueryByTrainCodeParam? {
        didSet{
//            print("\(queryByTrainCodeParam.ToGetParams())")
            if oldValue != nil {
                if oldValue!.ToGetParams() == queryByTrainCodeParam!.ToGetParams() {
                    return
                }
            }
            
            if self.trainCodeDetails != nil {
                self.trainCodeDetails!.trainNos!.removeAll()
                self.trainCodeDetailTable.reloadData()
            }
            
            let successHandler = { (trainDetails:TrainCodeDetails)->()  in
                self.trainCodeDetails = trainDetails
                self.trainCodeDetailTable.reloadData()
                self.trainCodeDetailTable.scrollRowToVisible(0)
            }
            
            let failureHandler = {(error:NSError)->() in
            }
            
            service.queryTrainNoFlowWith(queryByTrainCodeParam!, success: successHandler, failure: failureHandler)
        }
    }
    @IBOutlet weak var trainCodeDetailTable: NSTableView!
    
    var trainCodeDetails: TrainCodeDetails?

    override func viewDidLoad() {
        super.viewDidLoad()
        
        // setup Table Header
        for col in trainCodeDetailTable.tableColumns {
            col.headerCell = TrainCodeDetailHeaderCell(textCell: col.headerCell.stringValue)
            col.headerCell.alignment = .Center
        }
        
    }
    
}

// MARK: - NSTableViewDataSource 
extension TrainCodeDetailViewController: NSTableViewDataSource{
    func numberOfRowsInTableView(tableView: NSTableView) -> Int {
        if trainCodeDetails == nil {
            return 0
        }
        return trainCodeDetails!.trainNos.count
    }
    
    func tableView(tableView: NSTableView, objectValueForTableColumn tableColumn: NSTableColumn?, row: Int) -> AnyObject? {
        if trainCodeDetails == nil {
            return nil
        }
        return trainCodeDetails!.trainNos[row]
    }
}
{'fraction_non_alphanumeric': 0.08568961795812649, 'fraction_numerical': 0.008417871789337363, 'mean_word_length': 1.981981981981982, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1219668', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1181, 'n_words': 233}