Better message for duplicate / template open

This commit is contained in:
Matthias Neeracher 2015-12-24 04:33:51 +01:00 committed by Matthias Neeracher
parent b27739bb1c
commit 72fb3482a5
2 changed files with 10 additions and 4 deletions

View File

@ -108,9 +108,15 @@ class ASApplication: NSObject, NSApplicationDelegate, NSMenuDelegate {
ASSerialWin.showWindowWithPort(port.title) ASSerialWin.showWindowWithPort(port.title)
} }
func openTemplate(template: NSURL) { func openTemplate(template: NSURL, fromReadOnly: Bool) {
let editable : String
if fromReadOnly {
editable = "editable "
} else {
editable = ""
}
ASApplication.newProjectLocation(nil, ASApplication.newProjectLocation(nil,
message: "Save editable copy of project \(template.lastPathComponent)") message: "Save \(editable)copy of project \(template.lastPathComponent!)")
{ (saveTo) -> Void in { (saveTo) -> Void in
let oldName = template.lastPathComponent! let oldName = template.lastPathComponent!
let newName = saveTo.lastPathComponent! let newName = saveTo.lastPathComponent!
@ -151,7 +157,7 @@ class ASApplication: NSObject, NSApplicationDelegate, NSMenuDelegate {
@IBAction func openExample(item: NSMenuItem) { @IBAction func openExample(item: NSMenuItem) {
let url = NSURL(fileURLWithPath: examples[item.tag]) let url = NSURL(fileURLWithPath: examples[item.tag])
openTemplate(url.URLByDeletingLastPathComponent!) openTemplate(url.URLByDeletingLastPathComponent!, fromReadOnly:true)
} }
@IBAction func createSketch(_: AnyObject) { @IBAction func createSketch(_: AnyObject) {

View File

@ -236,7 +236,7 @@ class ASProjDoc: NSDocument, NSOutlineViewDelegate, NSMenuDelegate, NSOpenSavePa
override func duplicateDocument(sender: AnyObject?) { override func duplicateDocument(sender: AnyObject?) {
let app = NSApplication.sharedApplication().delegate as! ASApplication let app = NSApplication.sharedApplication().delegate as! ASApplication
app.openTemplate(fileURL!.URLByDeletingLastPathComponent!) app.openTemplate(fileURL!.URLByDeletingLastPathComponent!, fromReadOnly:false)
} }
func updateLog(_: AnyObject?) { func updateLog(_: AnyObject?) {