Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
43ac4e24
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
43ac4e24
编写于
5月 15, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#30535 expand and collapse events
上级
005666c4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
47 addition
and
2 deletion
+47
-2
src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts
src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts
+7
-1
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+1
-0
src/vs/workbench/api/node/extHostTreeViews.ts
src/vs/workbench/api/node/extHostTreeViews.ts
+26
-1
src/vs/workbench/browser/parts/views/customView.ts
src/vs/workbench/browser/parts/views/customView.ts
+9
-0
src/vs/workbench/common/views.ts
src/vs/workbench/common/views.ts
+4
-0
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts
浏览文件 @
43ac4e24
...
@@ -8,7 +8,7 @@ import { Event, Emitter } from 'vs/base/common/event';
...
@@ -8,7 +8,7 @@ import { Event, Emitter } from 'vs/base/common/event';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ExtHostContext
,
MainThreadTreeViewsShape
,
ExtHostTreeViewsShape
,
MainContext
,
IExtHostContext
}
from
'
../node/extHost.protocol
'
;
import
{
ExtHostContext
,
MainThreadTreeViewsShape
,
ExtHostTreeViewsShape
,
MainContext
,
IExtHostContext
}
from
'
../node/extHost.protocol
'
;
import
{
ITreeViewDataProvider
,
ITreeItem
,
IViewsService
}
from
'
vs/workbench/common/views
'
;
import
{
ITreeViewDataProvider
,
ITreeItem
,
IViewsService
,
ITreeViewer
}
from
'
vs/workbench/common/views
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
import
{
distinct
}
from
'
vs/base/common/arrays
'
;
import
{
distinct
}
from
'
vs/base/common/arrays
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
...
@@ -34,6 +34,7 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
...
@@ -34,6 +34,7 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
const
treeViewer
=
this
.
viewsService
.
getTreeViewer
(
treeViewId
);
const
treeViewer
=
this
.
viewsService
.
getTreeViewer
(
treeViewId
);
if
(
treeViewer
)
{
if
(
treeViewer
)
{
treeViewer
.
dataProvider
=
dataProvider
;
treeViewer
.
dataProvider
=
dataProvider
;
this
.
registerListeners
(
treeViewId
,
treeViewer
);
}
else
{
}
else
{
this
.
notificationService
.
error
(
'
No view is registered with id:
'
+
treeViewId
);
this
.
notificationService
.
error
(
'
No view is registered with id:
'
+
treeViewId
);
}
}
...
@@ -54,6 +55,11 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
...
@@ -54,6 +55,11 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
}
}
}
}
private
registerListeners
(
treeViewId
:
string
,
treeViewer
:
ITreeViewer
):
void
{
this
.
_register
(
treeViewer
.
onDidExpandItem
(
item
=>
this
.
_proxy
.
$setExpanded
(
treeViewId
,
item
.
handle
,
true
)));
this
.
_register
(
treeViewer
.
onDidCollapseItem
(
item
=>
this
.
_proxy
.
$setExpanded
(
treeViewId
,
item
.
handle
,
false
)));
}
dispose
():
void
{
dispose
():
void
{
this
.
_dataProviders
.
clear
();
this
.
_dataProviders
.
clear
();
super
.
dispose
();
super
.
dispose
();
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
43ac4e24
...
@@ -575,6 +575,7 @@ export interface ExtHostDocumentsAndEditorsShape {
...
@@ -575,6 +575,7 @@ export interface ExtHostDocumentsAndEditorsShape {
export
interface
ExtHostTreeViewsShape
{
export
interface
ExtHostTreeViewsShape
{
$getChildren
(
treeViewId
:
string
,
treeItemHandle
?:
string
):
TPromise
<
ITreeItem
[]
>
;
$getChildren
(
treeViewId
:
string
,
treeItemHandle
?:
string
):
TPromise
<
ITreeItem
[]
>
;
$setExpanded
(
treeViewId
:
string
,
treeItemHandle
:
string
,
expanded
:
boolean
):
void
;
}
}
export
interface
ExtHostWorkspaceShape
{
export
interface
ExtHostWorkspaceShape
{
...
...
src/vs/workbench/api/node/extHostTreeViews.ts
浏览文件 @
43ac4e24
...
@@ -8,7 +8,7 @@ import { localize } from 'vs/nls';
...
@@ -8,7 +8,7 @@ import { localize } from 'vs/nls';
import
*
as
vscode
from
'
vscode
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
basename
}
from
'
vs/base/common/paths
'
;
import
{
basename
}
from
'
vs/base/common/paths
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
debounceEvent
}
from
'
vs/base/common/event
'
;
import
{
debounceEvent
,
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ExtHostTreeViewsShape
,
MainThreadTreeViewsShape
}
from
'
./extHost.protocol
'
;
import
{
ExtHostTreeViewsShape
,
MainThreadTreeViewsShape
}
from
'
./extHost.protocol
'
;
...
@@ -67,6 +67,14 @@ export class ExtHostTreeViews implements ExtHostTreeViewsShape {
...
@@ -67,6 +67,14 @@ export class ExtHostTreeViews implements ExtHostTreeViewsShape {
return
treeView
.
getChildren
(
treeItemHandle
);
return
treeView
.
getChildren
(
treeItemHandle
);
}
}
$setExpanded
(
treeViewId
:
string
,
treeItemHandle
:
string
,
expanded
:
boolean
):
void
{
const
treeView
=
this
.
treeViews
.
get
(
treeViewId
);
if
(
treeView
)
{
treeView
.
setExpanded
(
treeItemHandle
,
expanded
);
}
TPromise
.
wrapError
<
ITreeItem
[]
>
(
new
Error
(
localize
(
'
treeView.notRegistered
'
,
'
No tree view with id
\'
{0}
\'
registered.
'
,
treeViewId
)));
}
private
createExtHostTreeViewer
<
T
>
(
id
:
string
,
dataProvider
:
vscode
.
TreeDataProvider
<
T
>
):
ExtHostTreeView
<
T
>
{
private
createExtHostTreeViewer
<
T
>
(
id
:
string
,
dataProvider
:
vscode
.
TreeDataProvider
<
T
>
):
ExtHostTreeView
<
T
>
{
const
treeView
=
new
ExtHostTreeView
<
T
>
(
id
,
dataProvider
,
this
.
_proxy
,
this
.
commands
.
converter
);
const
treeView
=
new
ExtHostTreeView
<
T
>
(
id
,
dataProvider
,
this
.
_proxy
,
this
.
commands
.
converter
);
this
.
treeViews
.
set
(
id
,
treeView
);
this
.
treeViews
.
set
(
id
,
treeView
);
...
@@ -94,6 +102,12 @@ class ExtHostTreeView<T> extends Disposable {
...
@@ -94,6 +102,12 @@ class ExtHostTreeView<T> extends Disposable {
private
elements
:
Map
<
TreeItemHandle
,
T
>
=
new
Map
<
TreeItemHandle
,
T
>
();
private
elements
:
Map
<
TreeItemHandle
,
T
>
=
new
Map
<
TreeItemHandle
,
T
>
();
private
nodes
:
Map
<
T
,
TreeNode
>
=
new
Map
<
T
,
TreeNode
>
();
private
nodes
:
Map
<
T
,
TreeNode
>
=
new
Map
<
T
,
TreeNode
>
();
private
_onDidExpandElement
:
Emitter
<
T
>
=
this
.
_register
(
new
Emitter
<
T
>
());
readonly
onDidExpandElement
:
Event
<
T
>
=
this
.
_onDidExpandElement
.
event
;
private
_onDidCollapseElement
:
Emitter
<
T
>
=
this
.
_register
(
new
Emitter
<
T
>
());
readonly
onDidCollapseElement
:
Event
<
T
>
=
this
.
_onDidCollapseElement
.
event
;
constructor
(
private
viewId
:
string
,
private
dataProvider
:
vscode
.
TreeDataProvider
<
T
>
,
private
proxy
:
MainThreadTreeViewsShape
,
private
commands
:
CommandsConverter
)
{
constructor
(
private
viewId
:
string
,
private
dataProvider
:
vscode
.
TreeDataProvider
<
T
>
,
private
proxy
:
MainThreadTreeViewsShape
,
private
commands
:
CommandsConverter
)
{
super
();
super
();
this
.
proxy
.
$registerTreeViewDataProvider
(
viewId
);
this
.
proxy
.
$registerTreeViewDataProvider
(
viewId
);
...
@@ -127,6 +141,17 @@ class ExtHostTreeView<T> extends Disposable {
...
@@ -127,6 +141,17 @@ class ExtHostTreeView<T> extends Disposable {
.
then
(
treeNode
=>
this
.
proxy
.
$reveal
(
this
.
viewId
,
treeNode
.
item
,
parentChain
.
map
(
p
=>
p
.
item
),
options
)));
.
then
(
treeNode
=>
this
.
proxy
.
$reveal
(
this
.
viewId
,
treeNode
.
item
,
parentChain
.
map
(
p
=>
p
.
item
),
options
)));
}
}
setExpanded
(
treeItemHandle
:
TreeItemHandle
,
expanded
:
boolean
):
void
{
const
element
=
this
.
getExtensionElement
(
treeItemHandle
);
if
(
element
)
{
if
(
expanded
)
{
this
.
_onDidExpandElement
.
fire
(
element
);
}
else
{
this
.
_onDidCollapseElement
.
fire
(
element
);
}
}
}
private
resolveUnknownParentChain
(
element
:
T
):
TPromise
<
TreeNode
[]
>
{
private
resolveUnknownParentChain
(
element
:
T
):
TPromise
<
TreeNode
[]
>
{
return
this
.
resolveParent
(
element
)
return
this
.
resolveParent
(
element
)
.
then
((
parent
)
=>
{
.
then
((
parent
)
=>
{
...
...
src/vs/workbench/browser/parts/views/customView.ts
浏览文件 @
43ac4e24
...
@@ -32,6 +32,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
...
@@ -32,6 +32,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import
{
FileIconThemableWorkbenchTree
}
from
'
vs/workbench/browser/parts/views/viewsViewlet
'
;
import
{
FileIconThemableWorkbenchTree
}
from
'
vs/workbench/browser/parts/views/viewsViewlet
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/browser/viewlet
'
;
import
{
isUndefinedOrNull
}
from
'
vs/base/common/types
'
;
import
{
isUndefinedOrNull
}
from
'
vs/base/common/types
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
export
class
CustomViewsService
extends
Disposable
implements
IViewsService
{
export
class
CustomViewsService
extends
Disposable
implements
IViewsService
{
...
@@ -112,6 +113,12 @@ class CustomTreeViewer extends Disposable implements ITreeViewer {
...
@@ -112,6 +113,12 @@ class CustomTreeViewer extends Disposable implements ITreeViewer {
private
_dataProvider
:
ITreeViewDataProvider
;
private
_dataProvider
:
ITreeViewDataProvider
;
private
dataProviderDisposables
:
IDisposable
[]
=
[];
private
dataProviderDisposables
:
IDisposable
[]
=
[];
private
_onDidExpandItem
:
Emitter
<
ITreeItem
>
=
this
.
_register
(
new
Emitter
<
ITreeItem
>
());
readonly
onDidExpandItem
:
Event
<
ITreeItem
>
=
this
.
_onDidExpandItem
.
event
;
private
_onDidCollapseItem
:
Emitter
<
ITreeItem
>
=
this
.
_register
(
new
Emitter
<
ITreeItem
>
());
readonly
onDidCollapseItem
:
Event
<
ITreeItem
>
=
this
.
_onDidCollapseItem
.
event
;
constructor
(
constructor
(
private
id
:
string
,
private
id
:
string
,
private
location
:
ViewLocation
,
private
location
:
ViewLocation
,
...
@@ -224,6 +231,8 @@ class CustomTreeViewer extends Disposable implements ITreeViewer {
...
@@ -224,6 +231,8 @@ class CustomTreeViewer extends Disposable implements ITreeViewer {
this
.
tree
.
contextKeyService
.
createKey
<
boolean
>
(
this
.
id
,
true
);
this
.
tree
.
contextKeyService
.
createKey
<
boolean
>
(
this
.
id
,
true
);
this
.
_register
(
this
.
tree
);
this
.
_register
(
this
.
tree
);
this
.
_register
(
this
.
tree
.
onDidChangeSelection
(
e
=>
this
.
onSelection
(
e
)));
this
.
_register
(
this
.
tree
.
onDidChangeSelection
(
e
=>
this
.
onSelection
(
e
)));
this
.
_register
(
this
.
tree
.
onDidExpandItem
(
e
=>
this
.
_onDidExpandItem
.
fire
(
e
.
item
.
getElement
())));
this
.
_register
(
this
.
tree
.
onDidCollapseItem
(
e
=>
this
.
_onDidCollapseItem
.
fire
(
e
.
item
.
getElement
())));
this
.
tree
.
setInput
(
this
.
root
);
this
.
tree
.
setInput
(
this
.
root
);
}
}
...
...
src/vs/workbench/common/views.ts
浏览文件 @
43ac4e24
...
@@ -161,6 +161,10 @@ export interface ITreeViewer extends IDisposable {
...
@@ -161,6 +161,10 @@ export interface ITreeViewer extends IDisposable {
dataProvider
:
ITreeViewDataProvider
;
dataProvider
:
ITreeViewDataProvider
;
readonly
onDidExpandItem
:
Event
<
ITreeItem
>
;
readonly
onDidCollapseItem
:
Event
<
ITreeItem
>
;
refresh
(
treeItems
?:
ITreeItem
[]):
TPromise
<
void
>
;
refresh
(
treeItems
?:
ITreeItem
[]):
TPromise
<
void
>
;
setVisibility
(
visible
:
boolean
):
void
;
setVisibility
(
visible
:
boolean
):
void
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录