Focus tree view after creating a directory

This commit is contained in:
Kevin Sawicki
2012-10-03 08:20:06 -07:00
parent 282802ac6c
commit 58515b2097
3 changed files with 8 additions and 6 deletions

View File

@@ -12,7 +12,7 @@ class Dialog extends View
initialize: ({path, @onConfirm, select} = {}) ->
@miniEditor.focus()
@on 'tree-view:confirm', => @confirm()
@on 'tree-view:confirm', => @onConfirm(@miniEditor.getText())
@on 'tree-view:cancel', => @cancel()
@miniEditor.on 'focusout', => @remove()
@@ -24,8 +24,7 @@ class Dialog extends View
range = [[0, path.length - baseName.length], [0, path.length - extension.length]]
@miniEditor.setSelectedBufferRange(range)
confirm: ->
return if @onConfirm(@miniEditor.getText()) is false
close: ->
@remove()
$('#root-view').focus()

View File

@@ -206,9 +206,9 @@ class TreeView extends View
try
fs.makeTree(directoryPath) unless fs.exists(directoryPath)
fs.move(oldPath, newPath)
dialog.close()
catch e
dialog.showError("Error: " + e.message + " Try a different path:")
return false
@rootView.append(dialog)
@@ -242,15 +242,15 @@ class TreeView extends View
if fs.exists(path)
pathType = if fs.isFile(path) then "file" else "directory"
dialog.showError("Error: A #{pathType} already exists at path '#{path}'. Try a different path:")
false
else if endsWithDirectorySeperator
fs.makeTree(path)
dialog.cancel()
else
fs.write(path, "")
@rootView.open(path)
dialog.close()
catch e
dialog.showError("Error: " + e.message + " Try a different path:")
return false
@rootView.append(dialog)