// // LibraryController.swift // DocHub // // Created by Tristan Juricek on 6/23/14. // Copyright (c) 2014 Perforce. All rights reserved. // import AppKit import Foundation class LibrarySourceListController : NSViewController, NSOutlineViewDelegate { @IBOutlet var outlineView:NSOutlineView var docHubLocation:DocHubLocation init(nibName:String!, bundle:NSBundle!, docHubLocation:DocHubLocation) { self.docHubLocation = docHubLocation super.init(nibName: nibName, bundle: bundle) } func outlineViewSelectionDidChange(notification: NSNotification!) { if let selectedItem:AnyObject = outlineView.itemAtRow(outlineView.selectedRow) { if selectedItem is Area { docHubLocation.area = (selectedItem as? Area) } } } func outlineView(outlineView: NSOutlineView!, viewForTableColumn tableColumn: NSTableColumn!, item: AnyObject!) -> NSView! { if item is Library ? true : false { let library:Library = item! as Library let cell = outlineView.makeViewWithIdentifier("HeaderCell", owner: self) as NSTableCellView! cell.textField.stringValue = library.name.uppercaseString return cell } else if item is Area ? true : false { let area:Area = item! as Area let cell = outlineView.makeViewWithIdentifier("DataCell", owner: self) as NSTableCellView! cell.textField.stringValue = area.name return cell } println("illegal state: item is not Area or Library: \(item)") return outlineView.makeViewWithIdentifier("DataCell", owner: self) as NSView } func outlineView(outlineView: NSOutlineView!, isGroupItem item: AnyObject!) -> Bool { return (item is Library ? true : false) } func outlineView(outlineView: NSOutlineView!, shouldSelectItem item: AnyObject!) -> Bool { return (item is Library ? false : true) } func reload() { let ds = (outlineView.dataSource()!) as LibraryDataSource ds.updateLibraries() outlineView.reloadItem(nil, reloadChildren:true) } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 9560 | tjuricek |
Setup parent reference to Library protocol, and handle using a separate model class. Adds a "library" ID to the title bar, which may make sense. |
||
#3 | 9557 | tjuricek | Fix warning | ||
#2 | 9556 | tjuricek | Add an informal "PropertyObserver" class to set up a typed bindings system, which in turn updates the window title at the moment. | ||
#1 | 9555 | tjuricek | Changing how the main splitter is toggled | ||
//guest/tjuricek/DocHub/DocHub/LibraryController.swift | |||||
#2 | 9546 | tjuricek | Apply correct header styling for the source list, and cache the areas with each library call. | ||
#1 | 9545 | tjuricek |
Use the left column to navigate p4 servers as "libraries" with their depots as "areas". I've had to stop using the output of login -p at the moment, since it doesn't quite work with the Objective-C API in lieu of a password. |