//
//  RemoteFileTableCell.swift
//  Skugga
//
//  Created by Arnaud Barisain-Monrose on 10/02/2015.
//
//

import Foundation
import Cocoa

private struct LocalConsts
{
    static let defaultFileType = "html";
}

class RemoteFileTableCell: NSTableCellView
{
    @IBOutlet weak var filename: NSTextField!
    
    @IBOutlet weak var uploadDate: NSTextField!
    
    @IBOutlet weak var icon: NSImageView!
    
    func updateWithRemoteFile(file: RemoteFile)
    {
        var fileType = file.filename.pathExtension;
        if (fileType.isEmpty)
        {
            fileType = LocalConsts.defaultFileType;
        }
        var fileIcon = NSWorkspace.sharedWorkspace().iconForFileType(fileType);
        fileIcon.size = NSSize(width: 40, height: 40);
        icon.image = fileIcon;
        filename.stringValue = file.filename;
        uploadDate.stringValue = file.uploadDate.description;
    }
}
//
//  RemoteFileTableCell.swift
//  Skugga
//
//  Created by Arnaud Barisain-Monrose on 10/02/2015.
//
//

import Foundation
import Cocoa

class RemoteFileTableCell: NSTableCellView
{
    @IBOutlet weak var filename: NSTextField!
    
    @IBOutlet weak var uploadDate: NSTextField!
    
    @IBOutlet weak var icon: NSImageView!
    
    func updateWithRemoteFile(file: RemoteFile)
    {
        var fileIcon = NSWorkspace.sharedWorkspace().iconForFileType("html");
        fileIcon.size = NSSize(width: 40, height: 40);
        icon.image = fileIcon;
        filename.stringValue = file.filename;
        uploadDate.stringValue = file.uploadDate.description;
    }
}
--- 
+++ 
@@ -9,6 +9,11 @@
 import Foundation
 import Cocoa
 
+private struct LocalConsts
+{
+    static let defaultFileType = "html";
+}
+
 class RemoteFileTableCell: NSTableCellView
 {
     @IBOutlet weak var filename: NSTextField!
@@ -19,7 +24,12 @@
     
     func updateWithRemoteFile(file: RemoteFile)
     {
-        var fileIcon = NSWorkspace.sharedWorkspace().iconForFileType("html");
+        var fileType = file.filename.pathExtension;
+        if (fileType.isEmpty)
+        {
+            fileType = LocalConsts.defaultFileType;
+        }
+        var fileIcon = NSWorkspace.sharedWorkspace().iconForFileType(fileType);
         fileIcon.size = NSSize(width: 40, height: 40);
         icon.image = fileIcon;
         filename.stringValue = file.filename;
Add right icons for files
