Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9b40aa3c
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,发现更多精彩内容 >>
提交
9b40aa3c
编写于
3月 07, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#92038 Move tree view away from get*Actions and use menus
上级
14657a93
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
64 addition
and
43 deletion
+64
-43
src/vs/workbench/browser/parts/views/treeView.ts
src/vs/workbench/browser/parts/views/treeView.ts
+64
-40
src/vs/workbench/common/views.ts
src/vs/workbench/common/views.ts
+0
-3
未找到文件。
src/vs/workbench/browser/parts/views/treeView.ts
浏览文件 @
9b40aa3c
...
...
@@ -7,12 +7,12 @@ import 'vs/css!./media/views';
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
,
Disposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IAction
,
ActionRunner
,
Action
}
from
'
vs/base/common/actions
'
;
import
{
IAction
,
ActionRunner
}
from
'
vs/base/common/actions
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IMenuService
,
MenuId
,
MenuItemAction
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IMenuService
,
MenuId
,
MenuItemAction
,
registerAction2
,
Action2
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ContextAwareMenuEntryActionViewItem
,
createAndFillInContextMenuActions
}
from
'
vs/platform/actions/browser/menuEntryActionViewItem
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextKeyService
,
ContextKeyExpr
,
ContextKeyEqualsExpr
,
RawContextKey
,
IContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ITreeView
,
ITreeItem
,
TreeItemCollapsibleState
,
ITreeViewDataProvider
,
TreeViewItemHandleArg
,
ITreeViewDescriptor
,
IViewsRegistry
,
ITreeItemLabel
,
Extensions
,
IViewDescriptorService
,
ViewContainer
,
ViewContainerLocation
}
from
'
vs/workbench/common/views
'
;
import
{
IViewletViewOptions
}
from
'
vs/workbench/browser/parts/views/viewsViewlet
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -92,14 +92,6 @@ export class TreeViewPane extends ViewPane {
this
.
treeView
.
layout
(
height
,
width
);
}
getActions
():
IAction
[]
{
return
[...
super
.
getActions
(),
...
this
.
treeView
.
getPrimaryActions
()];
}
getSecondaryActions
():
IAction
[]
{
return
[...
super
.
getSecondaryActions
(),
...
this
.
treeView
.
getSecondaryActions
()];
}
getOptimalWidth
():
number
{
return
this
.
treeView
.
getOptimalWidth
();
}
...
...
@@ -126,8 +118,11 @@ export class TreeView extends Disposable implements ITreeView {
private
isVisible
:
boolean
=
false
;
private
_hasIconForParentNode
=
false
;
private
_hasIconForLeafNode
=
false
;
private
_showCollapseAllAction
=
false
;
private
_showRefreshAction
=
false
;
private
readonly
collapseAllContextKey
:
RawContextKey
<
boolean
>
;
private
readonly
collapseAllContext
:
IContextKey
<
boolean
>
;
private
readonly
refreshContextKey
:
RawContextKey
<
boolean
>
;
private
readonly
refreshContext
:
IContextKey
<
boolean
>
;
private
focused
:
boolean
=
false
;
private
domNode
!
:
HTMLElement
;
...
...
@@ -175,10 +170,16 @@ export class TreeView extends Disposable implements ITreeView {
@
IContextMenuService
private
readonly
contextMenuService
:
IContextMenuService
,
@
IKeybindingService
private
readonly
keybindingService
:
IKeybindingService
,
@
INotificationService
private
readonly
notificationService
:
INotificationService
,
@
IViewDescriptorService
private
readonly
viewDescriptorService
:
IViewDescriptorService
@
IViewDescriptorService
private
readonly
viewDescriptorService
:
IViewDescriptorService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
super
();
this
.
root
=
new
Root
();
this
.
collapseAllContextKey
=
new
RawContextKey
<
boolean
>
(
`treeView.
${
this
.
id
}
.enableCollapseAll`
,
false
);
this
.
collapseAllContext
=
this
.
collapseAllContextKey
.
bindTo
(
contextKeyService
);
this
.
refreshContextKey
=
new
RawContextKey
<
boolean
>
(
`treeView.
${
this
.
id
}
.enableRefresh`
,
false
);
this
.
refreshContext
=
this
.
refreshContextKey
.
bindTo
(
contextKeyService
);
this
.
_register
(
this
.
themeService
.
onDidFileIconThemeChange
(()
=>
this
.
doRefresh
([
this
.
root
])
/** soft refresh **/
));
this
.
_register
(
this
.
themeService
.
onDidColorThemeChange
(()
=>
this
.
doRefresh
([
this
.
root
])
/** soft refresh **/
));
this
.
_register
(
this
.
configurationService
.
onDidChangeConfiguration
(
e
=>
{
...
...
@@ -191,6 +192,7 @@ export class TreeView extends Disposable implements ITreeView {
this
.
tree
?.
updateOptions
({
overrideStyles
:
{
listBackground
:
this
.
viewLocation
===
ViewContainerLocation
.
Sidebar
?
SIDE_BAR_BACKGROUND
:
PANEL_BACKGROUND
}
});
}
}));
this
.
registerActions
();
this
.
create
();
}
...
...
@@ -275,40 +277,61 @@ export class TreeView extends Disposable implements ITreeView {
}
get
showCollapseAllAction
():
boolean
{
return
this
.
_showCollapseAllAction
;
return
!!
this
.
collapseAllContext
.
get
()
;
}
set
showCollapseAllAction
(
showCollapseAllAction
:
boolean
)
{
if
(
this
.
_showCollapseAllAction
!==
!!
showCollapseAllAction
)
{
this
.
_showCollapseAllAction
=
!!
showCollapseAllAction
;
this
.
_onDidChangeActions
.
fire
();
}
this
.
collapseAllContext
.
set
(
showCollapseAllAction
);
}
get
showRefreshAction
():
boolean
{
return
this
.
_showRefreshAction
;
return
!!
this
.
refreshContext
.
get
()
;
}
set
showRefreshAction
(
showRefreshAction
:
boolean
)
{
if
(
this
.
_showRefreshAction
!==
!!
showRefreshAction
)
{
this
.
_showRefreshAction
=
!!
showRefreshAction
;
this
.
_onDidChangeActions
.
fire
();
this
.
refreshContext
.
set
(
showRefreshAction
);
}
private
registerActions
()
{
const
that
=
this
;
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
id
:
`workbench.actions.treeView.
${
that
.
id
}
.refresh`
,
title
:
localize
(
'
refresh
'
,
"
Refresh
"
),
menu
:
{
id
:
MenuId
.
ViewTitle
,
when
:
ContextKeyExpr
.
and
(
ContextKeyEqualsExpr
.
create
(
'
view
'
,
that
.
id
),
that
.
refreshContextKey
),
group
:
'
navigation
'
,
order
:
Number
.
MAX_SAFE_INTEGER
-
1
,
},
icon
:
{
id
:
'
codicon/refresh
'
}
});
}
async
run
():
Promise
<
void
>
{
return
that
.
refresh
();
}
getPrimaryActions
():
IAction
[]
{
const
actions
:
IAction
[]
=
[];
if
(
this
.
showRefreshAction
)
{
actions
.
push
(
new
Action
(
'
vs.tree.refresh
'
,
localize
(
'
refresh
'
,
"
Refresh
"
),
'
monaco-tree-action codicon-refresh
'
,
true
,
()
=>
this
.
refresh
()));
});
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
id
:
`workbench.actions.treeView.
${
that
.
id
}
.collapseAll`
,
title
:
localize
(
'
collapseAll
'
,
"
Collapse All
"
),
menu
:
{
id
:
MenuId
.
ViewTitle
,
when
:
ContextKeyExpr
.
and
(
ContextKeyEqualsExpr
.
create
(
'
view
'
,
that
.
id
),
that
.
collapseAllContextKey
),
group
:
'
navigation
'
,
order
:
Number
.
MAX_SAFE_INTEGER
,
},
icon
:
{
id
:
'
codicon/collapse-all
'
}
});
}
if
(
this
.
showCollapseAllAction
)
{
actions
.
push
(
new
Action
(
'
vs.tree.collapse
'
,
localize
(
'
collapseAll
'
,
"
Collapse All
"
),
'
monaco-tree-action codicon-collapse-all
'
,
true
,
()
=>
this
.
tree
?
new
CollapseAllAction
<
ITreeItem
,
ITreeItem
,
FuzzyScore
>
(
this
.
tree
,
true
).
run
()
:
Promise
.
resolve
()));
async
run
():
Promise
<
void
>
{
if
(
that
.
tree
)
{
return
new
CollapseAllAction
<
ITreeItem
,
ITreeItem
,
FuzzyScore
>
(
that
.
tree
,
true
).
run
();
}
return
actions
;
}
getSecondaryActions
():
IAction
[]
{
return
[];
});
}
setVisibility
(
isVisible
:
boolean
):
void
{
...
...
@@ -959,9 +982,10 @@ export class CustomTreeView extends TreeView {
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
INotificationService
notificationService
:
INotificationService
,
@
IViewDescriptorService
viewDescriptorService
:
IViewDescriptorService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IExtensionService
private
readonly
extensionService
:
IExtensionService
,
)
{
super
(
id
,
title
,
themeService
,
instantiationService
,
commandService
,
configurationService
,
progressService
,
contextMenuService
,
keybindingService
,
notificationService
,
viewDescriptorService
);
super
(
id
,
title
,
themeService
,
instantiationService
,
commandService
,
configurationService
,
progressService
,
contextMenuService
,
keybindingService
,
notificationService
,
viewDescriptorService
,
contextKeyService
);
}
setVisibility
(
isVisible
:
boolean
):
void
{
...
...
src/vs/workbench/common/views.ts
浏览文件 @
9b40aa3c
...
...
@@ -508,9 +508,6 @@ export interface ITreeView extends IDisposable {
setFocus
(
item
:
ITreeItem
):
void
;
getPrimaryActions
():
IAction
[];
getSecondaryActions
():
IAction
[];
}
export
interface
IRevealOptions
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录