Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
894c3cf4
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,发现更多精彩内容 >>
提交
894c3cf4
编写于
11月 01, 2016
作者:
P
Pine Wu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor and consistent naming
上级
d153d96c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
35 addition
and
42 deletion
+35
-42
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
...vs/workbench/browser/parts/activitybar/activitybarPart.ts
+25
-28
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+2
-2
src/vs/workbench/parts/explorers/browser/treeExplorerActions.contribution.ts
...rts/explorers/browser/treeExplorerActions.contribution.ts
+4
-4
src/vs/workbench/parts/explorers/browser/treeExplorerViewlet.ts
.../workbench/parts/explorers/browser/treeExplorerViewlet.ts
+1
-1
src/vs/workbench/services/activity/common/activityService.ts
src/vs/workbench/services/activity/common/activityService.ts
+3
-7
未找到文件。
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
浏览文件 @
894c3cf4
...
...
@@ -34,9 +34,16 @@ export class ActivitybarPart extends Part implements IActivityService {
private
compositeIdToActions
:
{
[
compositeId
:
string
]:
ActivityAction
;
};
private
enabledExternalViewlets
:
string
[];
private
registered
Viewlets
:
{
[
viewletId
:
string
]:
ViewletDescriptor
;
};
private
external
Viewlets
:
{
[
viewletId
:
string
]:
ViewletDescriptor
;
};
private
externalViewletIdToOpen
:
string
;
// Serves two purposes:
// 1. Expose the viewletId that will be assigned to an external Viewlet,
// which wouldn't know its viewletId until construction time.
// 2. When workbench restores sidebar, if the last-opened Viewlet is external,
// it'll set this value and defer restoration until all extensions are loaded.
private
_externalViewletIdToOpen
:
string
;
public
get
externalViewletIdToOpen
()
{
return
this
.
_externalViewletIdToOpen
;
};
public
set
externalViewletIdToOpen
(
viewletId
:
string
)
{
this
.
_externalViewletIdToOpen
=
viewletId
;
};
private
static
ENABLED_EXTERNAL_VIEWLETS
=
'
workbench.activityBar.enabledExternalViewlets
'
;
...
...
@@ -56,7 +63,7 @@ export class ActivitybarPart extends Part implements IActivityService {
const
enabledExternalViewletsJson
=
this
.
storageService
.
get
(
ActivitybarPart
.
ENABLED_EXTERNAL_VIEWLETS
);
this
.
enabledExternalViewlets
=
enabledExternalViewletsJson
?
JSON
.
parse
(
enabledExternalViewletsJson
)
:
[];
this
.
registered
Viewlets
=
{};
this
.
external
Viewlets
=
{};
this
.
registerListeners
();
}
...
...
@@ -72,18 +79,20 @@ export class ActivitybarPart extends Part implements IActivityService {
// Update activity bar on registering external viewlets
this
.
extensionService
.
onReady
().
then
(()
=>
{
const
viewlets
=
(
<
ViewletRegistry
>
Registry
.
as
(
ViewletExtensions
.
Viewlets
)).
getViewlets
();
this
.
on
DidRegisterExternalViewlets
(
viewlets
);
this
.
on
ExtensionServiceReady
(
viewlets
);
});
}
private
on
DidRegisterExternalViewlets
(
viewlets
:
ViewletDescriptor
[]):
void
{
private
on
ExtensionServiceReady
(
viewlets
:
ViewletDescriptor
[]):
void
{
viewlets
.
forEach
(
v
=>
{
this
.
registeredViewlets
[
v
.
id
]
=
v
;
if
(
v
.
isExternal
)
{
this
.
externalViewlets
[
v
.
id
]
=
v
;
}
});
this
.
viewletSwitcherBar
.
push
(
this
.
getAllEnabledExternalViewlets
().
map
(
d
=>
this
.
toAction
(
d
)),
{
label
:
true
,
icon
:
true
});
if
(
this
.
externalViewletIdToOpen
)
{
this
.
compositeIdToActions
[
this
.
externalViewletIdToOpen
].
run
().
done
();
if
(
this
.
_
externalViewletIdToOpen
)
{
this
.
compositeIdToActions
[
this
.
_
externalViewletIdToOpen
].
run
().
done
();
}
}
...
...
@@ -99,23 +108,23 @@ export class ActivitybarPart extends Part implements IActivityService {
}
}
public
getInfoFor
Registered
Viewlets
():
{
public
getInfoFor
External
Viewlets
():
{
[
viewletId
:
string
]:
{
isEnabled
:
boolean
;
treeLabel
:
string
;
}
}
{
const
result
=
{};
for
(
let
viewletId
in
this
.
registered
Viewlets
)
{
for
(
let
viewletId
in
this
.
external
Viewlets
)
{
result
[
viewletId
]
=
{
isEnabled
:
(
this
.
enabledExternalViewlets
.
indexOf
(
viewletId
)
!==
-
1
),
treeLabel
:
this
.
registered
Viewlets
[
viewletId
].
name
treeLabel
:
this
.
external
Viewlets
[
viewletId
].
name
};
}
return
result
;
}
public
toggleViewlet
(
viewletId
:
string
):
void
{
public
toggle
External
Viewlet
(
viewletId
:
string
):
void
{
const
index
=
this
.
enabledExternalViewlets
.
indexOf
(
viewletId
);
if
(
index
===
-
1
)
{
this
.
enabledExternalViewlets
.
push
(
viewletId
);
...
...
@@ -189,13 +198,9 @@ export class ActivitybarPart extends Part implements IActivityService {
// Get a list of all enabled external viewlets, ordered by the enabling sequence
private
getAllEnabledExternalViewlets
():
ViewletDescriptor
[]
{
const
externalViewletsToShow
:
ViewletDescriptor
[]
=
[];
this
.
enabledExternalViewlets
.
forEach
(
viewletId
=>
{
if
(
this
.
registeredViewlets
[
viewletId
])
{
externalViewletsToShow
.
push
(
this
.
registeredViewlets
[
viewletId
]);
}
});
return
externalViewletsToShow
;
return
this
.
enabledExternalViewlets
.
filter
(
viewletId
=>
this
.
externalViewlets
[
viewletId
])
.
map
(
viewletId
=>
this
.
externalViewlets
[
viewletId
]);
}
private
toAction
(
composite
:
ViewletDescriptor
):
ActivityAction
{
...
...
@@ -204,7 +209,7 @@ export class ActivitybarPart extends Part implements IActivityService {
// Later retrieved by TreeExplorerViewlet, which wouldn't know its id until
// its construction at runtime.
action
.
onOpenExternalViewlet
((
viewletId
)
=>
{
this
.
externalViewletIdToOpen
=
viewletId
;
this
.
_
externalViewletIdToOpen
=
viewletId
;
});
this
.
activityActionItems
[
action
.
id
]
=
new
ActivityActionItem
(
action
,
composite
.
name
,
this
.
getKeybindingLabel
(
composite
.
id
));
...
...
@@ -213,14 +218,6 @@ export class ActivitybarPart extends Part implements IActivityService {
return
action
;
};
setExternalViewletIdToOpen
(
viewletId
:
string
):
void
{
this
.
externalViewletIdToOpen
=
viewletId
;
}
getExternalViewletIdToOpen
():
string
{
return
this
.
externalViewletIdToOpen
;
}
private
getKeybindingLabel
(
id
:
string
):
string
{
const
keys
=
this
.
keybindingService
.
lookupKeybindings
(
id
).
map
(
k
=>
this
.
keybindingService
.
getLabelFor
(
k
));
if
(
keys
&&
keys
.
length
)
{
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
894c3cf4
...
...
@@ -228,9 +228,9 @@ export class Workbench implements IPartService {
viewletId
=
this
.
storageService
.
get
(
SidebarPart
.
activeViewletSettingsKey
,
StorageScope
.
WORKSPACE
,
viewletId
);
// help developers and restore last view
}
// If external viewlet is the last active viewlet, defer its construction until
extensions get register
ed
// If external viewlet is the last active viewlet, defer its construction until
all extensions are load
ed
if
(
!
viewletRegistry
.
getViewlet
(
viewletId
))
{
this
.
activitybarPart
.
setExternalViewletIdToOpen
(
viewletId
)
;
this
.
activitybarPart
.
externalViewletIdToOpen
=
viewletId
;
}
else
{
if
(
!
this
.
sideBarHidden
&&
!!
viewletId
)
{
const
viewletTimerEvent
=
timer
.
start
(
timer
.
Topic
.
STARTUP
,
strings
.
format
(
'
Opening Viewlet: {0}
'
,
viewletId
));
...
...
src/vs/workbench/parts/explorers/browser/treeExplorerActions.contribution.ts
浏览文件 @
894c3cf4
...
...
@@ -29,11 +29,11 @@ export class ToggleExternalViewletAction extends Action {
}
run
():
TPromise
<
any
>
{
const
infoFor
RegisteredViewlets
=
this
.
activityService
.
getInfoForRegistered
Viewlets
();
const
infoFor
ExternalViewlets
=
this
.
activityService
.
getInfoForExternal
Viewlets
();
const
picks
:
IPickOpenEntry
[]
=
[];
for
(
let
viewletId
in
infoFor
Registered
Viewlets
)
{
const
{
isEnabled
,
treeLabel
}
=
infoFor
Registered
Viewlets
[
viewletId
];
for
(
let
viewletId
in
infoFor
External
Viewlets
)
{
const
{
isEnabled
,
treeLabel
}
=
infoFor
External
Viewlets
[
viewletId
];
picks
.
push
({
id
:
viewletId
,
label
:
(
isEnabled
?
'
Disable
'
:
'
Enable
'
)
+
treeLabel
...
...
@@ -43,7 +43,7 @@ export class ToggleExternalViewletAction extends Action {
return
TPromise
.
timeout
(
50
/* quick open is sensitive to being opened so soon after another */
).
then
(()
=>
{
this
.
quickOpenService
.
pick
(
picks
,
{
placeHolder
:
'
Select Viewlet to toggle
'
,
autoFocus
:
2
}).
then
(
pick
=>
{
if
(
pick
)
{
this
.
activityService
.
toggleViewlet
(
pick
.
id
);
this
.
activityService
.
toggle
External
Viewlet
(
pick
.
id
);
}
});
});
...
...
src/vs/workbench/parts/explorers/browser/treeExplorerViewlet.ts
浏览文件 @
894c3cf4
...
...
@@ -36,7 +36,7 @@ export class TreeExplorerViewlet extends Viewlet {
this
.
viewletState
=
new
TreeExplorerViewletState
();
this
.
externalViewletId
=
this
.
activityService
.
getExternalViewletIdToOpen
()
;
this
.
externalViewletId
=
this
.
activityService
.
externalViewletIdToOpen
;
this
.
treeNodeProviderId
=
this
.
getTreeProviderName
(
this
.
externalViewletId
);
TreeExplorerViewlet
.
_idCounter
++
;
...
...
src/vs/workbench/services/activity/common/activityService.ts
浏览文件 @
894c3cf4
...
...
@@ -60,6 +60,7 @@ export const IActivityService = createDecorator<IActivityService>('activityServi
export
interface
IActivityService
{
_serviceBrand
:
any
;
externalViewletIdToOpen
:
string
;
/**
* Show activity in the activitybar for the given viewlet or panel.
...
...
@@ -74,7 +75,7 @@ export interface IActivityService {
/**
* Get registered external viewlets' info for populating 'Toggle Custom Explorer' command picks.
*/
getInfoFor
Registered
Viewlets
():
{
getInfoFor
External
Viewlets
():
{
[
viewletId
:
string
]:
{
isEnabled
:
boolean
;
treeLabel
:
string
;
...
...
@@ -84,10 +85,5 @@ export interface IActivityService {
/**
* Enable/disable an external viewlet.
*/
toggleViewlet
(
viewletId
:
string
):
void
;
/**
* Get the external viewlet id that is about to open.
*/
getExternalViewletIdToOpen
():
string
;
toggleExternalViewlet
(
viewletId
:
string
):
void
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录