Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Make the tree view a dock item #1056

Merged
merged 31 commits into from May 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
98f08ef
Convert lib/main.coffee to JS
Mar 31, 2017
8caafbf
Extract package singleton class for easier testing
Mar 31, 2017
eebc217
:art:
Mar 31, 2017
9a70d1e
WIP: Start on making tree view a dock item
Mar 31, 2017
ee303b4
Correctly update scroll position after deserializing
Apr 3, 2017
beb468c
Apply .tree-view class to root element to simplify focus handling
Apr 3, 2017
e9e517f
Pass view directly to Workspace.open
Apr 4, 2017
81bc7f9
Get all but one test passing
Apr 4, 2017
f9704d4
Recreate tree-view properly after its pane is closed
maxbrunsfeld Apr 4, 2017
dcb69da
Implement getPreferredWidth on tree view to support resize-to-fit
Apr 5, 2017
74a3404
Prepare 0.217.0-0 release
maxbrunsfeld Apr 5, 2017
96b4940
Fix rendering artifacts
Apr 6, 2017
823033d
Prepare 0.217.0-1 release
Apr 6, 2017
a654ac7
`.tree-view.full-menu` :point_right: `.tree-view .full-menu`
smashwilson Apr 6, 2017
cc834a9
Prepare 0.217.0-2 release
Apr 6, 2017
9523fb5
Update calls to Dock.isOpen to use .isVisible
maxbrunsfeld Apr 7, 2017
a27cfa8
Handle new the workspace's new active pane container behavior
maxbrunsfeld Apr 7, 2017
9e05f14
0.217.0-3
maxbrunsfeld Apr 7, 2017
25f4e10
Show tree view without focusing it when project paths change
maxbrunsfeld Apr 17, 2017
d5b137a
Don't try to destroy TreeView using Pane.close
maxbrunsfeld Apr 17, 2017
c166bb3
Avoid exception when tree-view is deactivated right after project pat…
maxbrunsfeld Apr 17, 2017
8d68369
Prepare 0.217.0-4 release
maxbrunsfeld Apr 17, 2017
c8cb0be
Don't focus the tree-view whenever active pane item changes
maxbrunsfeld Apr 17, 2017
35a2742
Prepare 0.217.0-5 release
maxbrunsfeld Apr 17, 2017
5589861
Make list inherit its container's width
maxbrunsfeld May 4, 2017
210fada
Merge pull request #1089 from atom/mb-full-width-list
May 4, 2017
73acb41
Prepare 0.217.0-6 release
maxbrunsfeld May 4, 2017
755e781
Prepare 0.217.0-7 release
maxbrunsfeld May 4, 2017
cf15382
Make specs pass with mocked Date.now
May 12, 2017
0c133af
Prepare 0.217.0-8 release
May 12, 2017
8b89251
Fix lint error
maxbrunsfeld May 16, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/dialog.coffee
Expand Up @@ -50,13 +50,14 @@ class Dialog
@miniEditor.scrollToCursorPosition()

close: ->
panelToDestroy = @panel
panel = @panel
@panel = null
panelToDestroy?.destroy()
panel?.destroy()
@emitter.dispose()
@disposables.dispose()
@miniEditor.destroy()
atom.workspace.getActivePane().activate()
activePane = atom.workspace.getCenter().getActivePane()
activePane.activate() unless activePane.isDestroyed()

cancel: ->
@close()
Expand Down
64 changes: 0 additions & 64 deletions lib/main.coffee

This file was deleted.

3 changes: 3 additions & 0 deletions lib/main.js
@@ -0,0 +1,3 @@
const TreeViewPackage = require('./tree-view-package')

module.exports = new TreeViewPackage()
101 changes: 101 additions & 0 deletions lib/tree-view-package.js
@@ -0,0 +1,101 @@
const {Disposable, CompositeDisposable} = require('event-kit')
const path = require('path')

const FileIcons = require('./file-icons')
const TreeView = require('./tree-view')

module.exports =
class TreeViewPackage {
activate () {
this.disposables = new CompositeDisposable()
this.disposables.add(atom.commands.add('atom-workspace', {
'tree-view:show': () => this.getTreeViewInstance().show(),
'tree-view:toggle': () => this.getTreeViewInstance().toggle(),
'tree-view:toggle-focus': () => this.getTreeViewInstance().toggleFocus(),
'tree-view:reveal-active-file': () => this.getTreeViewInstance().revealActiveFile(),
'tree-view:add-file': () => this.getTreeViewInstance().add(true),
'tree-view:add-folder': () => this.getTreeViewInstance().add(false),
'tree-view:duplicate': () => this.getTreeViewInstance().copySelectedEntry(),
'tree-view:remove': () => this.getTreeViewInstance().removeSelectedEntries(),
'tree-view:rename': () => this.getTreeViewInstance().moveSelectedEntry(),
'tree-view:show-current-file-in-file-manager': () => this.getTreeViewInstance().showCurrentFileInFileManager()
}))

this.disposables.add(atom.project.onDidChangePaths(this.createOrDestroyTreeViewIfNeeded.bind(this)))

if (this.shouldAttachTreeView()) {
const treeView = this.getTreeViewInstance()
const showOnAttach = !atom.workspace.getActivePaneItem()
this.treeViewOpenPromise = atom.workspace.open(treeView, {
activatePane: showOnAttach,
activateItem: showOnAttach
})
} else {
this.treeViewOpenPromise = Promise.resolve()
}
}

deactivate () {
this.disposables.dispose()
if (this.fileIconsDisposable) this.fileIconsDisposable.dispose()
if (this.treeView) this.treeView.destroy()
this.treeView = null
}

consumeFileIcons (service) {
FileIcons.setService(service)
if (this.treeView) this.treeView.updateRoots()
return new Disposable(() => {
FileIcons.resetService()
if (this.treeView) this.treeView.updateRoots()
}
)
}

getTreeViewInstance (state = {}) {
if (this.treeView == null) {
this.treeView = new TreeView(state)
this.treeView.onDidDestroy(() => this.treeView = null)
}
return this.treeView
}

createOrDestroyTreeViewIfNeeded () {
if (this.shouldAttachTreeView()) {
const treeView = this.getTreeViewInstance()
const paneContainer = atom.workspace.paneContainerForURI(treeView.getURI())
if (paneContainer) {
paneContainer.show()
} else {
atom.workspace.open(treeView, {
activatePane: false,
activateItem: false
}).then(() => {
const paneContainer = atom.workspace.paneContainerForURI(treeView.getURI())
if (paneContainer) paneContainer.show()
})
}
} else {
if (this.treeView) {
const pane = atom.workspace.paneForItem(this.treeView)
if (pane) pane.removeItem(this.treeView)
}
}
}

shouldAttachTreeView () {
if (atom.project.getPaths().length === 0) return false

// Avoid opening the tree view if Atom was opened as the Git editor...
// Only show it if the .git folder was explicitly opened.
if (path.basename(atom.project.getPaths()[0]) === '.git') {
return atom.project.getPaths()[0] === atom.getLoadSettings().pathToOpen
}

return true
}

shouldShowTreeViewAfterAttaching () {
if (atom.workspace.getActivePaneItem()) return false
}
}