Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d48541bb
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,发现更多精彩内容 >>
提交
d48541bb
编写于
5月 06, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cache and dispose composite actions by the creators
上级
bfb9eb67
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
59 addition
and
27 deletion
+59
-27
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
...vs/workbench/browser/parts/activitybar/activitybarPart.ts
+28
-4
src/vs/workbench/browser/parts/compositebar/compositeBar.ts
src/vs/workbench/browser/parts/compositebar/compositeBar.ts
+4
-20
src/vs/workbench/browser/parts/panel/panelPart.ts
src/vs/workbench/browser/parts/panel/panelPart.ts
+27
-3
未找到文件。
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
浏览文件 @
d48541bb
...
...
@@ -48,6 +48,7 @@ export class ActivitybarPart extends Part {
private
globalActivityIdToActions
:
{
[
globalActivityId
:
string
]:
GlobalActivityAction
;
};
private
compositeBar
:
CompositeBar
;
private
compositeActions
:
{
[
compositeId
:
string
]:
{
activityAction
:
ViewletActivityAction
,
pinnedAction
:
ToggleCompositePinnedAction
}
};
constructor
(
id
:
string
,
...
...
@@ -60,14 +61,15 @@ export class ActivitybarPart extends Part {
this
.
globalActivityIdToActions
=
Object
.
create
(
null
);
this
.
compositeActions
=
Object
.
create
(
null
);
this
.
compositeBar
=
this
.
instantiationService
.
createInstance
(
CompositeBar
,
{
icon
:
true
,
storageId
:
ActivitybarPart
.
PINNED_VIEWLETS
,
orientation
:
ActionsOrientation
.
VERTICAL
,
composites
:
this
.
viewletService
.
getViewlets
().
filter
(
v
=>
this
.
canShow
(
v
)),
openComposite
:
(
compositeId
:
string
)
=>
this
.
viewletService
.
openViewlet
(
compositeId
,
true
),
getActivityAction
:
(
compositeId
:
string
)
=>
this
.
instantiationService
.
createInstance
(
ViewletActivityAction
,
this
.
viewletService
.
getViewlet
(
compositeId
))
,
getCompositePinnedAction
:
(
compositeId
:
string
)
=>
new
ToggleCompositePinnedAction
(
this
.
viewletService
.
getViewlet
(
compositeId
),
this
.
compositeBar
)
,
getActivityAction
:
(
compositeId
:
string
)
=>
this
.
getCompositeActions
(
compositeId
).
activityAction
,
getCompositePinnedAction
:
(
compositeId
:
string
)
=>
this
.
getCompositeActions
(
compositeId
).
pinnedAction
,
getOnCompositeClickAction
:
(
compositeId
:
string
)
=>
this
.
instantiationService
.
createInstance
(
ToggleViewletAction
,
this
.
viewletService
.
getViewlet
(
compositeId
)),
getContextMenuActions
:
()
=>
[
this
.
instantiationService
.
createInstance
(
ToggleActivityBarVisibilityAction
,
ToggleActivityBarVisibilityAction
.
ID
,
nls
.
localize
(
'
hideActivitBar
'
,
"
Hide Activity Bar
"
))],
getDefaultCompositeId
:
()
=>
this
.
viewletService
.
getDefaultViewletId
(),
...
...
@@ -96,7 +98,7 @@ export class ActivitybarPart extends Part {
if
(
enabled
)
{
this
.
compositeBar
.
addComposite
(
this
.
viewletService
.
getViewlet
(
id
),
true
);
}
else
{
this
.
compositeBar
.
removeComposite
(
id
);
this
.
removeComposite
(
id
);
}
}));
}
...
...
@@ -177,6 +179,18 @@ export class ActivitybarPart extends Part {
});
}
private
getCompositeActions
(
compositeId
:
string
):
{
activityAction
:
ViewletActivityAction
,
pinnedAction
:
ToggleCompositePinnedAction
}
{
let
compositeActions
=
this
.
compositeActions
[
compositeId
];
if
(
!
compositeActions
)
{
compositeActions
=
{
activityAction
:
this
.
instantiationService
.
createInstance
(
ViewletActivityAction
,
this
.
viewletService
.
getViewlet
(
compositeId
)),
pinnedAction
:
new
ToggleCompositePinnedAction
(
this
.
viewletService
.
getViewlet
(
compositeId
),
this
.
compositeBar
)
};
this
.
compositeActions
[
compositeId
]
=
compositeActions
;
}
return
compositeActions
;
}
private
updateCompositebar
():
void
{
const
viewlets
=
this
.
viewletService
.
getViewlets
();
for
(
const
viewlet
of
viewlets
)
{
...
...
@@ -189,11 +203,21 @@ export class ActivitybarPart extends Part {
this
.
compositeBar
.
activateComposite
(
viewlet
.
id
);
}
}
else
{
this
.
compositeBar
.
removeComposite
(
viewlet
.
id
);
this
.
removeComposite
(
viewlet
.
id
);
}
}
}
private
removeComposite
(
compositeId
:
string
):
void
{
this
.
compositeBar
.
removeComposite
(
compositeId
);
const
compositeActions
=
this
.
compositeActions
[
compositeId
];
if
(
compositeActions
)
{
compositeActions
.
activityAction
.
dispose
();
compositeActions
.
pinnedAction
.
dispose
();
delete
this
.
compositeActions
[
compositeId
];
}
}
private
canShow
(
viewlet
:
ViewletDescriptor
):
boolean
{
const
viewLocation
=
ViewLocation
.
get
(
viewlet
.
id
);
if
(
viewLocation
)
{
...
...
src/vs/workbench/browser/parts/compositebar/compositeBar.ts
浏览文件 @
d48541bb
...
...
@@ -478,7 +478,7 @@ interface ISerializedCompositeBarItem {
order
:
number
;
}
interface
ICompositeBarItem
extends
ISerializedCompositeBarItem
,
IDisposable
{
interface
ICompositeBarItem
extends
ISerializedCompositeBarItem
{
name
:
string
;
activityAction
:
ActivityAction
;
pinnedAction
:
Action
;
...
...
@@ -494,28 +494,13 @@ class CompositeBarModel {
private
createCompositeBarItem
(
id
:
string
,
name
:
string
,
order
:
number
,
pinned
:
boolean
):
ICompositeBarItem
{
const
options
=
this
.
options
;
let
activityAction
,
pinnedAction
;
return
{
id
,
name
,
pinned
,
order
,
activity
:
[],
get
activityAction
()
{
if
(
!
activityAction
)
{
activityAction
=
options
.
getActivityAction
(
id
);
}
return
activityAction
;
return
options
.
getActivityAction
(
id
);
},
get
pinnedAction
()
{
if
(
!
pinnedAction
)
{
pinnedAction
=
options
.
getCompositePinnedAction
(
id
);
}
return
pinnedAction
;
},
dispose
:
()
=>
{
if
(
activityAction
)
{
activityAction
.
dispose
();
}
if
(
pinnedAction
)
{
pinnedAction
.
dispose
();
}
return
options
.
getCompositePinnedAction
(
id
);
}
};
}
...
...
@@ -541,8 +526,7 @@ class CompositeBarModel {
remove
(
id
:
string
):
boolean
{
for
(
let
index
=
0
;
index
<
this
.
items
.
length
;
index
++
)
{
if
(
this
.
items
[
index
].
id
===
id
)
{
const
item
=
this
.
items
.
splice
(
index
,
1
)[
0
];
item
.
dispose
();
this
.
items
.
splice
(
index
,
1
);
return
true
;
}
}
...
...
src/vs/workbench/browser/parts/panel/panelPart.ts
浏览文件 @
d48541bb
...
...
@@ -42,6 +42,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
private
blockOpeningPanel
:
boolean
;
private
compositeBar
:
CompositeBar
;
private
compositeActions
:
{
[
compositeId
:
string
]:
{
activityAction
:
PanelActivityAction
,
pinnedAction
:
ToggleCompositePinnedAction
}
};
private
dimension
:
Dimension
;
constructor
(
...
...
@@ -74,14 +75,15 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
{
hasTitle
:
true
}
);
this
.
compositeActions
=
Object
.
create
(
null
);
this
.
compositeBar
=
this
.
instantiationService
.
createInstance
(
CompositeBar
,
{
icon
:
false
,
storageId
:
PanelPart
.
PINNED_PANELS
,
orientation
:
ActionsOrientation
.
HORIZONTAL
,
composites
:
this
.
getPanels
(),
openComposite
:
(
compositeId
:
string
)
=>
this
.
openPanel
(
compositeId
,
true
),
getActivityAction
:
(
compositeId
:
string
)
=>
this
.
instantiationService
.
createInstance
(
PanelActivityAction
,
this
.
getPanel
(
compositeId
))
,
getCompositePinnedAction
:
(
compositeId
:
string
)
=>
new
ToggleCompositePinnedAction
(
this
.
getPanel
(
compositeId
),
this
.
compositeBar
)
,
getActivityAction
:
(
compositeId
:
string
)
=>
this
.
getCompositeActions
(
compositeId
).
activityAction
,
getCompositePinnedAction
:
(
compositeId
:
string
)
=>
this
.
getCompositeActions
(
compositeId
).
pinnedAction
,
getOnCompositeClickAction
:
(
compositeId
:
string
)
=>
this
.
instantiationService
.
createInstance
(
PanelActivityAction
,
this
.
getPanel
(
compositeId
)),
getContextMenuActions
:
()
=>
[
this
.
instantiationService
.
createInstance
(
TogglePanelAction
,
TogglePanelAction
.
ID
,
localize
(
'
hidePanel
'
,
"
Hide Panel
"
))],
getDefaultCompositeId
:
()
=>
Registry
.
as
<
PanelRegistry
>
(
PanelExtensions
.
Panels
).
getDefaultPanelId
(),
...
...
@@ -178,7 +180,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
this
.
compositeBar
.
activateComposite
(
descriptor
.
id
);
});
}
else
{
this
.
compositeBar
.
removeComposite
(
id
);
this
.
removeComposite
(
id
);
}
}
}
...
...
@@ -253,6 +255,28 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
}
private
getCompositeActions
(
compositeId
:
string
):
{
activityAction
:
PanelActivityAction
,
pinnedAction
:
ToggleCompositePinnedAction
}
{
let
compositeActions
=
this
.
compositeActions
[
compositeId
];
if
(
!
compositeActions
)
{
compositeActions
=
{
activityAction
:
this
.
instantiationService
.
createInstance
(
PanelActivityAction
,
this
.
getPanel
(
compositeId
)),
pinnedAction
:
new
ToggleCompositePinnedAction
(
this
.
getPanel
(
compositeId
),
this
.
compositeBar
)
};
this
.
compositeActions
[
compositeId
]
=
compositeActions
;
}
return
compositeActions
;
}
private
removeComposite
(
compositeId
:
string
):
void
{
this
.
compositeBar
.
removeComposite
(
compositeId
);
const
compositeActions
=
this
.
compositeActions
[
compositeId
];
if
(
compositeActions
)
{
compositeActions
.
activityAction
.
dispose
();
compositeActions
.
pinnedAction
.
dispose
();
delete
this
.
compositeActions
[
compositeId
];
}
}
private
getToolbarWidth
():
number
{
const
activePanel
=
this
.
getActivePanel
();
if
(
!
activePanel
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录