Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
16c03c2c
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,发现更多精彩内容 >>
提交
16c03c2c
编写于
9月 23, 2016
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
activity bar: no need for code reuse between panel and viewlet activity action
上级
cc954945
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
21 addition
and
38 deletion
+21
-38
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
...vs/workbench/browser/parts/activitybar/activitybarPart.ts
+21
-38
未找到文件。
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
浏览文件 @
16c03c2c
...
...
@@ -16,8 +16,8 @@ import {Registry} from 'vs/platform/platform';
import
{
IComposite
}
from
'
vs/workbench/common/composite
'
;
import
{
IPanel
}
from
'
vs/workbench/common/panel
'
;
import
{
ViewletDescriptor
,
ViewletRegistry
,
Extensions
as
ViewletExtensions
,
Viewlet
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
CompositeDescriptor
,
Composite
}
from
'
vs/workbench/browser/composite
'
;
import
{
Panel
,
PanelRegistry
,
Extensions
as
PanelExtensions
}
from
'
vs/workbench/browser/panel
'
;
import
{
CompositeDescriptor
}
from
'
vs/workbench/browser/composite
'
;
import
{
Panel
,
PanelRegistry
,
Extensions
as
PanelExtensions
,
PanelDescriptor
}
from
'
vs/workbench/browser/panel
'
;
import
{
Part
}
from
'
vs/workbench/browser/part
'
;
import
{
ActivityAction
,
ActivityActionItem
}
from
'
vs/workbench/browser/parts/activitybar/activityAction
'
;
import
{
TogglePanelAction
}
from
'
vs/workbench/browser/parts/panel/panelPart
'
;
...
...
@@ -208,69 +208,52 @@ export class ActivitybarPart extends Part implements IActivityService {
}
}
abstract
class
CompositeActivityAction
<
T
extends
Composite
>
extends
ActivityAction
{
class
ViewletActivityAction
extends
ActivityAction
{
private
static
preventDoubleClickDelay
=
300
;
private
lastRun
:
number
=
0
;
protected
composite
:
CompositeDescriptor
<
T
>
;
constructor
(
id
:
string
,
composite
:
CompositeDescriptor
<
T
>
,
@
IViewletService
protected
viewletService
:
IViewletService
,
@
IPanelService
protected
panelService
:
IPanelService
,
@
IPartService
protected
partService
:
IPartService
id
:
string
,
private
viewlet
:
ViewletDescriptor
,
@
IViewletService
private
viewletService
:
IViewletService
,
@
IPartService
private
partService
:
IPartService
)
{
super
(
id
,
composite
.
name
,
composite
.
cssClass
);
this
.
composite
=
composite
;
super
(
id
,
viewlet
.
name
,
viewlet
.
cssClass
);
}
public
run
():
TPromise
<
any
>
{
// prevent accident trigger on a doubleclick (to help nervous people)
const
now
=
Date
.
now
();
if
(
now
-
this
.
lastRun
<
Composite
ActivityAction
.
preventDoubleClickDelay
)
{
if
(
now
-
this
.
lastRun
<
Viewlet
ActivityAction
.
preventDoubleClickDelay
)
{
return
TPromise
.
as
(
true
);
}
this
.
lastRun
=
now
;
this
.
toggleComposite
();
return
TPromise
.
as
(
true
);
}
protected
abstract
toggleComposite
():
void
;
}
class
ViewletActivityAction
extends
CompositeActivityAction
<
Viewlet
>
{
protected
toggleComposite
():
void
{
const
sideBarHidden
=
this
.
partService
.
isSideBarHidden
();
const
activeViewlet
=
this
.
viewletService
.
getActiveViewlet
();
// Hide sidebar if selected viewlet already visible
if
(
!
sideBarHidden
&&
activeViewlet
&&
activeViewlet
.
getId
()
===
this
.
composite
.
id
)
{
if
(
!
sideBarHidden
&&
activeViewlet
&&
activeViewlet
.
getId
()
===
this
.
viewlet
.
id
)
{
this
.
partService
.
setSideBarHidden
(
true
);
}
else
{
this
.
viewletService
.
openViewlet
(
this
.
composite
.
id
,
true
).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
viewletService
.
openViewlet
(
this
.
viewlet
.
id
,
true
).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
activate
();
}
return
TPromise
.
as
(
true
);
}
}
class
PanelActivityAction
extends
CompositeActivityAction
<
Panel
>
{
protected
toggleComposite
():
void
{
class
PanelActivityAction
extends
ActivityAction
{
const
panelHidden
=
this
.
partService
.
isPanelHidden
();
const
activePanel
=
this
.
panelService
.
getActivePanel
();
constructor
(
id
:
string
,
private
panel
:
PanelDescriptor
,
@
IPanelService
private
panelService
:
IPanelService
)
{
super
(
id
,
panel
.
name
,
panel
.
cssClass
);
}
// Hide panel if selected panel already visible
if
(
!
panelHidden
&&
activePanel
&&
activePanel
.
getId
()
===
this
.
composite
.
id
)
{
this
.
partService
.
setPanelHidden
(
true
);
}
else
{
this
.
panelService
.
openPanel
(
this
.
composite
.
id
,
true
).
done
(
null
,
errors
.
onUnexpectedError
);
this
.
activate
();
}
public
run
():
TPromise
<
any
>
{
return
this
.
panelService
.
openPanel
(
this
.
panel
.
id
,
true
).
then
(()
=>
this
.
activate
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录