Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
0b77964b
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,发现更多精彩内容 >>
提交
0b77964b
编写于
5月 15, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#49511 Access selected elements
上级
43ac4e24
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
26 addition
and
3 deletion
+26
-3
src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts
src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts
+1
-0
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
+18
-3
src/vs/workbench/browser/parts/views/customView.ts
src/vs/workbench/browser/parts/views/customView.ts
+4
-0
src/vs/workbench/common/views.ts
src/vs/workbench/common/views.ts
+2
-0
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadTreeViews.ts
浏览文件 @
0b77964b
...
...
@@ -58,6 +58,7 @@ 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
)));
this
.
_register
(
treeViewer
.
onDidChangeSelection
(
items
=>
this
.
_proxy
.
$setSelection
(
treeViewId
,
items
.
map
(({
handle
})
=>
handle
))));
}
dispose
():
void
{
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
0b77964b
...
...
@@ -576,6 +576,7 @@ export interface ExtHostDocumentsAndEditorsShape {
export
interface
ExtHostTreeViewsShape
{
$getChildren
(
treeViewId
:
string
,
treeItemHandle
?:
string
):
TPromise
<
ITreeItem
[]
>
;
$setExpanded
(
treeViewId
:
string
,
treeItemHandle
:
string
,
expanded
:
boolean
):
void
;
$setSelection
(
treeViewId
:
string
,
treeItemHandles
:
string
[]):
void
;
}
export
interface
ExtHostWorkspaceShape
{
...
...
src/vs/workbench/api/node/extHostTreeViews.ts
浏览文件 @
0b77964b
...
...
@@ -69,10 +69,18 @@ export class ExtHostTreeViews implements ExtHostTreeViewsShape {
$setExpanded
(
treeViewId
:
string
,
treeItemHandle
:
string
,
expanded
:
boolean
):
void
{
const
treeView
=
this
.
treeViews
.
get
(
treeViewId
);
if
(
treeView
)
{
if
(
!
treeView
)
{
throw
new
Error
(
localize
(
'
treeView.notRegistered
'
,
'
No tree view with id
\'
{0}
\'
registered.
'
,
treeViewId
));
}
treeView
.
setExpanded
(
treeItemHandle
,
expanded
);
}
TPromise
.
wrapError
<
ITreeItem
[]
>
(
new
Error
(
localize
(
'
treeView.notRegistered
'
,
'
No tree view with id
\'
{0}
\'
registered.
'
,
treeViewId
)));
$setSelection
(
treeViewId
:
string
,
treeItemHandles
:
string
[]):
void
{
const
treeView
=
this
.
treeViews
.
get
(
treeViewId
);
if
(
!
treeView
)
{
throw
new
Error
(
localize
(
'
treeView.notRegistered
'
,
'
No tree view with id
\'
{0}
\'
registered.
'
,
treeViewId
));
}
treeView
.
setSelection
(
treeItemHandles
);
}
private
createExtHostTreeViewer
<
T
>
(
id
:
string
,
dataProvider
:
vscode
.
TreeDataProvider
<
T
>
):
ExtHostTreeView
<
T
>
{
...
...
@@ -102,6 +110,9 @@ class ExtHostTreeView<T> extends Disposable {
private
elements
:
Map
<
TreeItemHandle
,
T
>
=
new
Map
<
TreeItemHandle
,
T
>
();
private
nodes
:
Map
<
T
,
TreeNode
>
=
new
Map
<
T
,
TreeNode
>
();
private
_selectedElements
:
T
[]
=
[];
get
selectedElements
():
T
[]
{
return
this
.
_selectedElements
;
}
private
_onDidExpandElement
:
Emitter
<
T
>
=
this
.
_register
(
new
Emitter
<
T
>
());
readonly
onDidExpandElement
:
Event
<
T
>
=
this
.
_onDidExpandElement
.
event
;
...
...
@@ -152,6 +163,10 @@ class ExtHostTreeView<T> extends Disposable {
}
}
setSelection
(
treeItemHandles
:
TreeItemHandle
[]):
void
{
this
.
_selectedElements
=
treeItemHandles
.
map
(
handle
=>
this
.
getExtensionElement
(
handle
)).
filter
(
element
=>
!
isUndefinedOrNull
(
element
));
}
private
resolveUnknownParentChain
(
element
:
T
):
TPromise
<
TreeNode
[]
>
{
return
this
.
resolveParent
(
element
)
.
then
((
parent
)
=>
{
...
...
src/vs/workbench/browser/parts/views/customView.ts
浏览文件 @
0b77964b
...
...
@@ -119,6 +119,9 @@ class CustomTreeViewer extends Disposable implements ITreeViewer {
private
_onDidCollapseItem
:
Emitter
<
ITreeItem
>
=
this
.
_register
(
new
Emitter
<
ITreeItem
>
());
readonly
onDidCollapseItem
:
Event
<
ITreeItem
>
=
this
.
_onDidCollapseItem
.
event
;
private
_onDidChangeSelection
:
Emitter
<
ITreeItem
[]
>
=
this
.
_register
(
new
Emitter
<
ITreeItem
[]
>
());
readonly
onDidChangeSelection
:
Event
<
ITreeItem
[]
>
=
this
.
_onDidChangeSelection
.
event
;
constructor
(
private
id
:
string
,
private
location
:
ViewLocation
,
...
...
@@ -233,6 +236,7 @@ class CustomTreeViewer extends Disposable implements ITreeViewer {
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
.
_register
(
this
.
tree
.
onDidChangeSelection
(
e
=>
this
.
_onDidChangeSelection
.
fire
(
e
.
selection
)));
this
.
tree
.
setInput
(
this
.
root
);
}
...
...
src/vs/workbench/common/views.ts
浏览文件 @
0b77964b
...
...
@@ -165,6 +165,8 @@ export interface ITreeViewer extends IDisposable {
readonly
onDidCollapseItem
:
Event
<
ITreeItem
>
;
readonly
onDidChangeSelection
:
Event
<
ITreeItem
[]
>
;
refresh
(
treeItems
?:
ITreeItem
[]):
TPromise
<
void
>
;
setVisibility
(
visible
:
boolean
):
void
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录