Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
91db9a6a
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
91db9a6a
编写于
4月 18, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Hide the contributed viewlet if no views are registered
上级
33108e1b
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
9 deletion
+37
-9
src/vs/workbench/api/browser/activitybarExtensionPoint.ts
src/vs/workbench/api/browser/activitybarExtensionPoint.ts
+1
-1
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
...vs/workbench/browser/parts/activitybar/activitybarPart.ts
+29
-2
src/vs/workbench/common/views.ts
src/vs/workbench/common/views.ts
+7
-6
未找到文件。
src/vs/workbench/api/browser/activitybarExtensionPoint.ts
浏览文件 @
91db9a6a
...
...
@@ -91,7 +91,7 @@ activityGroupExtensionPoint.setHandler((extensions) => {
const
id
=
`workbench.view.extension.
${
descriptor
.
id
}
`
;
const
title
=
descriptor
.
title
;
const
cssClass
=
`extensionViewlet-
${
descriptor
.
id
}
`
;
const
location
:
ViewLocation
=
ViewLocation
.
register
(
id
);
const
location
:
ViewLocation
=
ViewLocation
.
register
(
id
,
true
);
// Generate CSS to show the icon in the activity bar
const
iconClass
=
`.monaco-workbench > .activitybar .monaco-action-bar .action-label.
${
cssClass
}
`
;
...
...
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
浏览文件 @
91db9a6a
...
...
@@ -33,6 +33,8 @@ import { isMacintosh } from 'vs/base/common/platform';
import
{
ILifecycleService
,
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
Dimension
,
scheduleAtNextAnimationFrame
}
from
'
vs/base/browser/dom
'
;
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
ViewLocation
,
ViewsRegistry
}
from
'
vs/workbench/common/views
'
;
import
{
ViewletDescriptor
}
from
'
vs/workbench/browser/viewlet
'
;
export
class
ActivitybarPart
extends
Part
{
...
...
@@ -83,11 +85,14 @@ export class ActivitybarPart extends Part {
});
this
.
registerListeners
();
this
.
updateCompositebar
();
}
private
registerListeners
():
void
{
this
.
toUnbind
.
push
(
this
.
viewletService
.
onDidViewletRegister
(
viewletDescriptor
=>
this
.
compositeBar
.
addComposite
(
viewletDescriptor
,
false
)));
this
.
toUnbind
.
push
(
this
.
viewletService
.
onDidViewletRegister
(()
=>
this
.
updateCompositebar
()));
this
.
toUnbind
.
push
(
ViewsRegistry
.
onViewsRegistered
(()
=>
this
.
updateCompositebar
()));
this
.
toUnbind
.
push
(
ViewsRegistry
.
onViewsDeregistered
(()
=>
this
.
updateCompositebar
()));
// Activate viewlet action on opening of a viewlet
this
.
toUnbind
.
push
(
this
.
viewletService
.
onDidViewletOpen
(
viewlet
=>
this
.
compositeBar
.
activateComposite
(
viewlet
.
getId
())));
...
...
@@ -183,7 +188,9 @@ export class ActivitybarPart extends Part {
private
showContextMenu
(
e
:
MouseEvent
):
void
{
const
event
=
new
StandardMouseEvent
(
e
);
const
actions
:
Action
[]
=
this
.
viewletService
.
getViewlets
().
map
(
viewlet
=>
this
.
instantiationService
.
createInstance
(
ToggleCompositePinnedAction
,
viewlet
,
this
.
compositeBar
));
const
actions
:
Action
[]
=
this
.
viewletService
.
getViewlets
()
.
filter
(
viewlet
=>
this
.
canShow
(
viewlet
))
.
map
(
viewlet
=>
this
.
instantiationService
.
createInstance
(
ToggleCompositePinnedAction
,
viewlet
,
this
.
compositeBar
));
actions
.
push
(
new
Separator
());
actions
.
push
(
this
.
instantiationService
.
createInstance
(
ToggleActivityBarVisibilityAction
,
ToggleActivityBarVisibilityAction
.
ID
,
nls
.
localize
(
'
hideActivitBar
'
,
"
Hide Activity Bar
"
)));
...
...
@@ -215,6 +222,26 @@ export class ActivitybarPart extends Part {
});
}
private
updateCompositebar
():
void
{
const
viewlets
=
this
.
viewletService
.
getViewlets
();
for
(
const
viewlet
of
viewlets
)
{
const
canShow
=
this
.
canShow
(
viewlet
);
if
(
canShow
)
{
this
.
compositeBar
.
addComposite
(
viewlet
,
false
);
}
else
{
this
.
compositeBar
.
removeComposite
(
viewlet
.
id
);
}
}
}
private
canShow
(
viewlet
:
ViewletDescriptor
):
boolean
{
const
viewLocation
=
ViewLocation
.
get
(
viewlet
.
id
);
if
(
viewLocation
&&
viewLocation
.
contributed
)
{
return
ViewsRegistry
.
getViews
(
viewLocation
).
length
>
0
;
}
return
true
;
}
public
getPinned
():
string
[]
{
return
this
.
viewletService
.
getViewlets
().
map
(
v
=>
v
.
id
).
filter
(
id
=>
this
.
compositeBar
.
isPinned
(
id
));
}
...
...
src/vs/workbench/common/views.ts
浏览文件 @
91db9a6a
...
...
@@ -18,8 +18,8 @@ import { ThemeIcon } from 'vs/platform/theme/common/themeService';
export
class
ViewLocation
{
private
static
locations
:
Map
<
string
,
ViewLocation
>
=
new
Map
<
string
,
ViewLocation
>
();
static
register
(
id
:
string
):
ViewLocation
{
const
viewLocation
=
new
ViewLocation
(
id
);
static
register
(
id
:
string
,
contributed
:
boolean
):
ViewLocation
{
const
viewLocation
=
new
ViewLocation
(
id
,
contributed
);
ViewLocation
.
locations
.
set
(
id
,
viewLocation
);
return
viewLocation
;
}
...
...
@@ -27,12 +27,13 @@ export class ViewLocation {
return
ViewLocation
.
locations
.
get
(
value
);
}
static
readonly
Explorer
:
ViewLocation
=
ViewLocation
.
register
(
'
workbench.view.explorer
'
);
static
readonly
Debug
:
ViewLocation
=
ViewLocation
.
register
(
'
workbench.view.debug
'
);
static
readonly
Extensions
:
ViewLocation
=
ViewLocation
.
register
(
'
workbench.view.extensions
'
);
static
readonly
Explorer
:
ViewLocation
=
ViewLocation
.
register
(
'
workbench.view.explorer
'
,
false
);
static
readonly
Debug
:
ViewLocation
=
ViewLocation
.
register
(
'
workbench.view.debug
'
,
false
);
static
readonly
Extensions
:
ViewLocation
=
ViewLocation
.
register
(
'
workbench.view.extensions
'
,
false
);
private
constructor
(
private
_id
:
string
)
{
}
private
constructor
(
private
_id
:
string
,
private
_contributed
:
boolean
)
{
}
get
id
():
string
{
return
this
.
_id
;
}
get
contributed
():
boolean
{
return
this
.
_contributed
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录