Conditionalize upload button on port and programmer availability
This commit is contained in:
parent
cd9aae2190
commit
feb2f578f2
|
@ -41,7 +41,11 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
|
||||||
var themeObserver : AnyObject?
|
var themeObserver : AnyObject?
|
||||||
var board = "uno"
|
var board = "uno"
|
||||||
var programmer = "arduino"
|
var programmer = "arduino"
|
||||||
var port = ""
|
dynamic var port : String = "" {
|
||||||
|
didSet {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
var recentBoards = [String]()
|
var recentBoards = [String]()
|
||||||
var recentProgrammers = [String]()
|
var recentProgrammers = [String]()
|
||||||
var logModified = NSDate.distantPast() as NSDate
|
var logModified = NSDate.distantPast() as NSDate
|
||||||
|
@ -113,7 +117,6 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateChangeCount(.ChangeCleared)
|
|
||||||
outlineViewSelectionDidChange(NSNotification(name: "", object: nil))
|
outlineViewSelectionDidChange(NSNotification(name: "", object: nil))
|
||||||
menuNeedsUpdate(boardTool.menu!)
|
menuNeedsUpdate(boardTool.menu!)
|
||||||
menuNeedsUpdate(progTool.menu!)
|
menuNeedsUpdate(progTool.menu!)
|
||||||
|
@ -121,6 +124,7 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
|
||||||
portTool.addItemWithTitle("Title")
|
portTool.addItemWithTitle("Title")
|
||||||
portTool.addItemsWithTitles(ASSerial.ports())
|
portTool.addItemsWithTitles(ASSerial.ports())
|
||||||
portTool.setTitle(port)
|
portTool.setTitle(port)
|
||||||
|
updateChangeCount(.ChangeCleared)
|
||||||
}
|
}
|
||||||
|
|
||||||
override class func autosavesInPlace() -> Bool {
|
override class func autosavesInPlace() -> Bool {
|
||||||
|
@ -363,7 +367,7 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
|
||||||
set (newBoard) {
|
set (newBoard) {
|
||||||
for (ident, prop) in ASHardware.instance().boards {
|
for (ident, prop) in ASHardware.instance().boards {
|
||||||
if prop["name"] == newBoard {
|
if prop["name"] == newBoard {
|
||||||
board = ident
|
setValue(ident, forKey: "board")
|
||||||
|
|
||||||
pushToFront(&recentBoards, board)
|
pushToFront(&recentBoards, board)
|
||||||
|
|
||||||
|
@ -393,7 +397,7 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
|
||||||
set (newProg) {
|
set (newProg) {
|
||||||
for (ident, prop) in ASHardware.instance().programmers {
|
for (ident, prop) in ASHardware.instance().programmers {
|
||||||
if prop["name"] == newProg {
|
if prop["name"] == newProg {
|
||||||
programmer = ident
|
setValue(ident, forKey:"programmer")
|
||||||
|
|
||||||
pushToFront(&recentProgrammers, programmer)
|
pushToFront(&recentProgrammers, programmer)
|
||||||
|
|
||||||
|
@ -423,10 +427,26 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate {
|
||||||
|
|
||||||
var hasUploadProtocol : Bool {
|
var hasUploadProtocol : Bool {
|
||||||
get {
|
get {
|
||||||
return ASHardware.instance().boards[board]?["upload.protocol"] != nil
|
if let proto = ASHardware.instance().boards[board]?["upload.protocol"] {
|
||||||
|
return proto != ""
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class func keyPathsForValuesAffectingHasUploadProtocol() -> NSSet {
|
||||||
|
return NSSet(object: "board")
|
||||||
|
}
|
||||||
|
|
||||||
|
var canUpload : Bool {
|
||||||
|
get {
|
||||||
|
return port != "" && (hasUploadProtocol || programmer != "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class func keyPathsForValuesAffectingCanUpload() -> NSSet {
|
||||||
|
return NSSet(objects: "port", "board", "programmer")
|
||||||
|
}
|
||||||
|
|
||||||
@IBAction func uploadProject(AnyObject) {
|
@IBAction func uploadProject(AnyObject) {
|
||||||
selectNode(files.uploadLog)
|
selectNode(files.uploadLog)
|
||||||
builder.uploadProject(board, programmer:programmer, port:port)
|
builder.uploadProject(board, programmer:programmer, port:port)
|
||||||
|
|
|
@ -98,9 +98,10 @@
|
||||||
</view>
|
</view>
|
||||||
<toolbar key="toolbar" implicitIdentifier="625EA1E8-488D-4F0C-8EE0-5F627F033421" autosavesConfiguration="NO" displayMode="iconAndLabel" sizeMode="regular" id="FLS-YK-Gpe">
|
<toolbar key="toolbar" implicitIdentifier="625EA1E8-488D-4F0C-8EE0-5F627F033421" autosavesConfiguration="NO" displayMode="iconAndLabel" sizeMode="regular" id="FLS-YK-Gpe">
|
||||||
<allowedToolbarItems>
|
<allowedToolbarItems>
|
||||||
<toolbarItem implicitItemIdentifier="9276EE94-B438-4F93-AC26-93EC83DAA78E" label="Upload" paletteLabel="Upload" tag="-1" image="UploadIcon" id="2cP-cC-Cr8">
|
<toolbarItem implicitItemIdentifier="9276EE94-B438-4F93-AC26-93EC83DAA78E" label="Upload" paletteLabel="Upload" tag="-1" image="UploadIcon" autovalidates="NO" id="2cP-cC-Cr8">
|
||||||
<connections>
|
<connections>
|
||||||
<action selector="uploadProject:" target="-1" id="p1l-Vg-i2P"/>
|
<action selector="uploadProject:" target="-1" id="p1l-Vg-i2P"/>
|
||||||
|
<binding destination="-2" name="enabled" keyPath="canUpload" id="j3y-Yd-bma"/>
|
||||||
</connections>
|
</connections>
|
||||||
</toolbarItem>
|
</toolbarItem>
|
||||||
<toolbarItem implicitItemIdentifier="69F004B0-A5C2-4130-9306-CBDA9B75A34E" label="Build" paletteLabel="Build" tag="-1" image="BuildIcon" id="69r-aN-6vG">
|
<toolbarItem implicitItemIdentifier="69F004B0-A5C2-4130-9306-CBDA9B75A34E" label="Build" paletteLabel="Build" tag="-1" image="BuildIcon" id="69r-aN-6vG">
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<key>Port</key>
|
<key>Port</key>
|
||||||
<string></string>
|
<string></string>
|
||||||
<key>Programmer</key>
|
<key>Programmer</key>
|
||||||
<string>arduino</string>
|
<string></string>
|
||||||
<key>Board</key>
|
<key>Board</key>
|
||||||
<string>uno</string>
|
<string>uno</string>
|
||||||
<key>Bindings</key>
|
<key>Bindings</key>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user