mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Tree View uses core:close core:confirm core:cancel and adds tool-pane:unfocus
This commit is contained in:
@@ -12,8 +12,8 @@ class Dialog extends View
|
||||
|
||||
initialize: ({path, @onConfirm, select} = {}) ->
|
||||
@miniEditor.focus()
|
||||
@on 'tree-view:confirm', => @onConfirm(@miniEditor.getText())
|
||||
@on 'tree-view:cancel', => @cancel()
|
||||
@on 'core:confirm', => @onConfirm(@miniEditor.getText())
|
||||
@on 'core:cancel', => @cancel()
|
||||
@miniEditor.on 'focusout', => @remove()
|
||||
|
||||
@miniEditor.setText(path)
|
||||
|
||||
@@ -3,8 +3,6 @@ window.keymap.bindKeys '#root-view'
|
||||
'ctrl-meta-1': 'tree-view:reveal-active-file'
|
||||
|
||||
window.keymap.bindKeys '.tree-view'
|
||||
'escape': 'tree-view:unfocus'
|
||||
'meta-w': 'tree-view:toggle'
|
||||
'right': 'tree-view:expand-directory'
|
||||
'left': 'tree-view:collapse-directory'
|
||||
'enter': 'tree-view:open-selected-entry'
|
||||
@@ -14,5 +12,5 @@ window.keymap.bindKeys '.tree-view'
|
||||
'backspace': 'tree-view:remove'
|
||||
|
||||
window.keymap.bindKeys '.tree-view-dialog .mini.editor'
|
||||
'enter': 'tree-view:confirm'
|
||||
'escape': 'tree-view:cancel'
|
||||
'enter': 'core:confirm'
|
||||
'escape': 'core:cancel'
|
||||
@@ -27,7 +27,7 @@ class TreeView extends ScrollView
|
||||
@instance.serialize()
|
||||
|
||||
@content: (rootView) ->
|
||||
@div class: 'tree-view', tabindex: -1, =>
|
||||
@div class: 'tree-view tool-panel', tabindex: -1, =>
|
||||
if rootView.project.getRootDirectory()
|
||||
@subview 'root', new DirectoryView(directory: rootView.project.getRootDirectory(), isExpanded: true)
|
||||
|
||||
@@ -50,18 +50,19 @@ class TreeView extends ScrollView
|
||||
@on 'click', '.entry', (e) => @entryClicked(e)
|
||||
@command 'core:move-up', => @moveUp()
|
||||
@command 'core:move-down', => @moveDown()
|
||||
@command 'core:close', => @detatch()
|
||||
@command 'tree-view:expand-directory', => @expandDirectory()
|
||||
@command 'tree-view:collapse-directory', => @collapseDirectory()
|
||||
@command 'tree-view:open-selected-entry', => @openSelectedEntry(true)
|
||||
@command 'tree-view:move', => @moveSelectedEntry()
|
||||
@command 'tree-view:add', => @add()
|
||||
@command 'tree-view:remove', => @removeSelectedEntry()
|
||||
@command 'tool-panel:unfocus', => @rootView.focus()
|
||||
@command 'tree-view:directory-modified', =>
|
||||
if @hasFocus()
|
||||
@selectEntryForPath(@selectedPath) if @selectedPath
|
||||
else
|
||||
@selectActiveFile()
|
||||
@on 'tree-view:unfocus', => @rootView.focus()
|
||||
@rootView.command 'tree-view:toggle', => @toggle()
|
||||
@rootView.command 'tree-view:reveal-active-file', => @revealActiveFile()
|
||||
@rootView.on 'active-editor-path-change', => @selectActiveFile()
|
||||
@@ -86,17 +87,20 @@ class TreeView extends ScrollView
|
||||
toggle: ->
|
||||
if @hasFocus()
|
||||
@detach()
|
||||
@rootView.focus()
|
||||
else
|
||||
@attach() unless @hasParent()
|
||||
@focus()
|
||||
if @hasParent()
|
||||
@focus()
|
||||
else
|
||||
@attach()
|
||||
|
||||
attach: ->
|
||||
@rootView.horizontal.prepend(this)
|
||||
@focus()
|
||||
|
||||
detach: ->
|
||||
@scrollTopAfterAttach = @scrollTop()
|
||||
super
|
||||
@rootView.focus()
|
||||
|
||||
hasFocus: ->
|
||||
@is(':focus')
|
||||
|
||||
Reference in New Issue
Block a user