Skip to content

Added documentation and example of using custom view containers into tree-view-sample #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tree-view-sample/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,38 @@ vscode.window.registerTreeDataProvider('nodeDependencies', new DepNodeProvider()
```

See [nodeDependencies.ts](src/nodeDependencies.ts) for the implementation.

# contributes.viewsContainers extension point

As of Visual Studio Code v1.23.0, you can move custom views into your own view container which will show up in the activity bar.

To do such, extension writers can add a `viewContainers` object in the contributes section. each object will require three things:

- `id`: The name of the new view you're creating
- `title`: The name which will show up at the top of the view
- `icon`: an image which will be displayed for the view container in the activity bar

Following, in the views object, you can then add a field with the same string as the `id` in the `viewContainers`.

```json
"contributes": {
"viewContainers": {
"activitybar": [
{
"id": "tree-view",
"title": "Tree View",
"icon": "media/dep.svg"
}
]
},
"views": {
"tree-view": [
{
"id": "nodeDependencies",
"name": "Node Dependencies",
"when": "workspaceHasPackageJSON"
}
]
}
}
```
11 changes: 10 additions & 1 deletion tree-view-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@
"main": "./out/src/extension",
"icon": "media/dep.png",
"contributes": {
"viewsContainers": {
"activitybar": [
{
"id": "package-explorer",
"title": "Package Explorer",
"icon": "media/dep.svg"
}
]
},
"views": {
"explorer": [
"package-explorer": [
{
"id": "nodeDependencies",
"name": "Node Dependencies"
Expand Down