Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
347df0bf
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,发现更多精彩内容 >>
提交
347df0bf
编写于
9月 22, 2016
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
activitybar: generalize code to talk about composites not viewlets
上级
c9c65c9c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
37 deletion
+40
-37
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
...vs/workbench/browser/parts/activitybar/activitybarPart.ts
+36
-33
src/vs/workbench/services/activity/common/activityService.ts
src/vs/workbench/services/activity/common/activityService.ts
+4
-4
未找到文件。
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
浏览文件 @
347df0bf
...
...
@@ -32,14 +32,15 @@ import {IKeybindingService} from 'vs/platform/keybinding/common/keybinding';
export
class
ActivitybarPart
extends
Part
implements
IActivityService
{
public
_serviceBrand
:
any
;
private
viewlet
SwitcherBar
:
ActionBar
;
private
composite
SwitcherBar
:
ActionBar
;
private
globalToolBar
:
ToolBar
;
private
activityActionItems
:
{
[
actionId
:
string
]:
IActionItem
;
};
private
viewletIdToActions
:
{
[
viewlet
Id
:
string
]:
ActivityAction
;
};
private
compositeIdToActions
:
{
[
composite
Id
:
string
]:
ActivityAction
;
};
constructor
(
id
:
string
,
@
IViewletService
private
viewletService
:
IViewletService
,
@
IPanelService
private
panelService
:
IPanelService
,
@
IMessageService
private
messageService
:
IMessageService
,
@
ITelemetryService
private
telemetryService
:
ITelemetryService
,
@
IContextMenuService
private
contextMenuService
:
IContextMenuService
,
...
...
@@ -49,7 +50,7 @@ export class ActivitybarPart extends Part implements IActivityService {
super
(
id
);
this
.
activityActionItems
=
{};
this
.
viewlet
IdToActions
=
{};
this
.
composite
IdToActions
=
{};
this
.
registerListeners
();
}
...
...
@@ -64,26 +65,26 @@ export class ActivitybarPart extends Part implements IActivityService {
}
private
onActiveViewletChanged
(
viewlet
:
IViewlet
):
void
{
if
(
this
.
viewlet
IdToActions
[
viewlet
.
getId
()])
{
this
.
viewlet
IdToActions
[
viewlet
.
getId
()].
activate
();
if
(
this
.
composite
IdToActions
[
viewlet
.
getId
()])
{
this
.
composite
IdToActions
[
viewlet
.
getId
()].
activate
();
// There can only be one active viewlet action
for
(
let
key
in
this
.
viewlet
IdToActions
)
{
if
(
this
.
viewletIdToActions
.
hasOwnProperty
(
key
)
&&
key
!==
viewlet
.
getId
()
)
{
this
.
viewlet
IdToActions
[
key
].
deactivate
();
for
(
let
key
in
this
.
composite
IdToActions
)
{
if
(
this
.
compositeIdToActions
.
hasOwnProperty
(
key
)
&&
key
!==
viewlet
.
getId
()
&&
this
.
compositeIdToActions
[
key
]
instanceof
ViewletActivityAction
)
{
this
.
composite
IdToActions
[
key
].
deactivate
();
}
}
}
}
private
onViewletClosed
(
viewlet
:
IViewlet
):
void
{
if
(
this
.
viewlet
IdToActions
[
viewlet
.
getId
()])
{
this
.
viewlet
IdToActions
[
viewlet
.
getId
()].
deactivate
();
if
(
this
.
composite
IdToActions
[
viewlet
.
getId
()])
{
this
.
composite
IdToActions
[
viewlet
.
getId
()].
deactivate
();
}
}
public
showActivity
(
viewlet
Id
:
string
,
badge
:
IBadge
,
clazz
?:
string
):
void
{
let
action
=
this
.
viewletIdToActions
[
viewlet
Id
];
public
showActivity
(
composite
Id
:
string
,
badge
:
IBadge
,
clazz
?:
string
):
void
{
const
action
=
this
.
compositeIdToActions
[
composite
Id
];
if
(
action
)
{
action
.
setBadge
(
badge
);
if
(
clazz
)
{
...
...
@@ -92,50 +93,52 @@ export class ActivitybarPart extends Part implements IActivityService {
}
}
public
clearActivity
(
viewlet
Id
:
string
):
void
{
this
.
showActivity
(
viewlet
Id
,
null
);
public
clearActivity
(
composite
Id
:
string
):
void
{
this
.
showActivity
(
composite
Id
,
null
);
}
public
createContentArea
(
parent
:
Builder
):
Builder
{
le
t
$el
=
$
(
parent
);
le
t
$result
=
$
(
'
.content
'
).
appendTo
(
$el
);
cons
t
$el
=
$
(
parent
);
cons
t
$result
=
$
(
'
.content
'
).
appendTo
(
$el
);
// Top Actionbar with action items for each viewlet action
this
.
create
Viewlet
Switcher
(
$result
.
clone
());
this
.
create
Composite
Switcher
(
$result
.
clone
());
return
$result
;
}
private
create
Viewlet
Switcher
(
div
:
Builder
):
void
{
private
create
Composite
Switcher
(
div
:
Builder
):
void
{
//
Viewlet
switcher is on top
this
.
viewlet
SwitcherBar
=
new
ActionBar
(
div
,
{
//
Composite
switcher is on top
this
.
composite
SwitcherBar
=
new
ActionBar
(
div
,
{
actionItemProvider
:
(
action
:
Action
)
=>
this
.
activityActionItems
[
action
.
id
],
orientation
:
ActionsOrientation
.
VERTICAL
,
ariaLabel
:
nls
.
localize
(
'
activityBarAriaLabel
'
,
"
Active View Switcher
"
)
});
this
.
viewlet
SwitcherBar
.
getContainer
().
addClass
(
'
position-top
'
);
this
.
composite
SwitcherBar
.
getContainer
().
addClass
(
'
position-top
'
);
// Build Viewlet Actions in correct order
const
activeViewlet
=
this
.
viewletService
.
getActiveViewlet
();
const
activePanel
=
this
.
panelService
.
getActivePanel
();
const
registry
=
(
<
ViewletRegistry
>
Registry
.
as
(
ViewletExtensions
.
Viewlets
));
const
allViewletActions
=
registry
.
getViewlets
();
const
actionOptions
=
{
label
:
true
,
icon
:
true
};
const
toAction
=
(
viewlet
:
ViewletDescriptor
)
=>
{
let
action
=
this
.
instantiationService
.
createInstance
(
ViewletActivityAction
,
viewlet
.
id
+
'
.activity-bar-action
'
,
viewlet
);
const
toAction
=
(
composite
:
CompositeDescriptor
<
Viewlet
|
Panel
>
)
=>
{
const
action
=
composite
instanceof
ViewletDescriptor
?
this
.
instantiationService
.
createInstance
(
ViewletActivityAction
,
composite
.
id
+
'
.activity-bar-action
'
,
composite
)
:
this
.
instantiationService
.
createInstance
(
PanelActivityAction
,
composite
.
id
+
'
.activity-bar-action
'
,
composite
);
let
keybinding
:
string
=
null
;
let
keys
=
this
.
keybindingService
.
lookupKeybindings
(
viewlet
.
id
).
map
(
k
=>
this
.
keybindingService
.
getLabelFor
(
k
));
const
keys
=
this
.
keybindingService
.
lookupKeybindings
(
composite
.
id
).
map
(
k
=>
this
.
keybindingService
.
getLabelFor
(
k
));
if
(
keys
&&
keys
.
length
)
{
keybinding
=
keys
[
0
];
}
this
.
activityActionItems
[
action
.
id
]
=
new
ActivityActionItem
(
action
,
viewlet
.
name
,
keybinding
);
this
.
viewletIdToActions
[
viewlet
.
id
]
=
action
;
this
.
activityActionItems
[
action
.
id
]
=
new
ActivityActionItem
(
action
,
composite
.
name
,
keybinding
);
this
.
compositeIdToActions
[
composite
.
id
]
=
action
;
// Mark active viewlet action as active
if
(
activeViewlet
&&
activeViewlet
.
getId
()
===
viewlet
.
id
)
{
// Mark active viewlet a
nd panel a
ction as active
if
(
activeViewlet
&&
activeViewlet
.
getId
()
===
composite
.
id
||
activePanel
&&
activePanel
.
getId
()
===
composite
.
id
)
{
action
.
activate
();
}
...
...
@@ -143,7 +146,7 @@ export class ActivitybarPart extends Part implements IActivityService {
};
// Add to viewlet switcher
this
.
viewlet
SwitcherBar
.
push
(
allViewletActions
this
.
composite
SwitcherBar
.
push
(
allViewletActions
.
filter
(
v
=>
!
v
.
isGlobal
)
.
sort
((
v1
,
v2
)
=>
v1
.
order
-
v2
.
order
)
.
map
(
toAction
)
...
...
@@ -151,9 +154,9 @@ export class ActivitybarPart extends Part implements IActivityService {
}
public
dispose
():
void
{
if
(
this
.
viewlet
SwitcherBar
)
{
this
.
viewlet
SwitcherBar
.
dispose
();
this
.
viewlet
SwitcherBar
=
null
;
if
(
this
.
composite
SwitcherBar
)
{
this
.
composite
SwitcherBar
.
dispose
();
this
.
composite
SwitcherBar
=
null
;
}
if
(
this
.
globalToolBar
)
{
...
...
@@ -185,7 +188,7 @@ abstract class CompositeActivityAction<T extends Composite> extends ActivityActi
public
run
():
TPromise
<
any
>
{
// prevent accident trigger on a doubleclick (to help nervous people)
le
t
now
=
Date
.
now
();
cons
t
now
=
Date
.
now
();
if
(
now
-
this
.
lastRun
<
CompositeActivityAction
.
preventDoubleClickDelay
)
{
return
TPromise
.
as
(
true
);
}
...
...
src/vs/workbench/services/activity/common/activityService.ts
浏览文件 @
347df0bf
...
...
@@ -62,12 +62,12 @@ export interface IActivityService {
_serviceBrand
:
any
;
/**
* Show activity in the activitybar for the given viewlet.
* Show activity in the activitybar for the given viewlet
or panel
.
*/
showActivity
(
viewlet
Id
:
string
,
badge
:
IBadge
,
clazz
?:
string
):
void
;
showActivity
(
composite
Id
:
string
,
badge
:
IBadge
,
clazz
?:
string
):
void
;
/**
* Clears activity shown in the activitybar for the given viewlet.
* Clears activity shown in the activitybar for the given viewlet
or panel
.
*/
clearActivity
(
viewlet
Id
:
string
):
void
;
clearActivity
(
composite
Id
:
string
):
void
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录