Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
02464b72
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,发现更多精彩内容 >>
提交
02464b72
编写于
12月 19, 2018
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #65274
上级
01636257
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
46 addition
and
42 deletion
+46
-42
src/vs/workbench/parts/extensions/electron-browser/extensionsList.ts
...bench/parts/extensions/electron-browser/extensionsList.ts
+17
-12
src/vs/workbench/parts/extensions/electron-browser/extensionsViews.ts
...ench/parts/extensions/electron-browser/extensionsViews.ts
+29
-30
未找到文件。
src/vs/workbench/parts/extensions/electron-browser/extensionsList.ts
浏览文件 @
02464b72
...
...
@@ -11,7 +11,7 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IListVirtualDelegate
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
IPagedRenderer
}
from
'
vs/base/browser/ui/list/listPaging
'
;
import
{
E
mitter
,
E
vent
}
from
'
vs/base/common/event
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
domEvent
}
from
'
vs/base/browser/event
'
;
import
{
IExtension
,
IExtensionsWorkbenchService
}
from
'
vs/workbench/parts/extensions/common/extensions
'
;
import
{
InstallAction
,
UpdateAction
,
ManageExtensionAction
,
ReloadAction
,
extensionButtonProminentBackground
,
extensionButtonProminentForeground
,
MaliciousStatusLabelAction
,
ExtensionActionItem
}
from
'
vs/workbench/parts/extensions/electron-browser/extensionsActions
'
;
...
...
@@ -22,9 +22,9 @@ import { IExtensionTipsService, IExtensionManagementServerService } from 'vs/pla
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
export
interface
IExtension
WithFocus
extends
IExtension
{
on
DidFocusChange
?:
Event
<
boolea
n
>
;
on
FocusChangeEventEmitter
?:
Emitter
<
boolea
n
>
;
export
interface
IExtension
sViewState
{
on
Focus
:
Event
<
IExtensio
n
>
;
on
Blur
:
Event
<
IExtensio
n
>
;
}
export
interface
ITemplateData
{
...
...
@@ -52,6 +52,7 @@ const actionOptions = { icon: true, label: true, tabOnlyOnFocus: true };
export
class
Renderer
implements
IPagedRenderer
<
IExtension
,
ITemplateData
>
{
constructor
(
private
extensionViewState
:
IExtensionsViewState
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
INotificationService
private
notificationService
:
INotificationService
,
@
IExtensionsWorkbenchService
private
extensionsWorkbenchService
:
IExtensionsWorkbenchService
,
...
...
@@ -141,7 +142,7 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
data
.
extension
=
null
;
}
renderElement
(
extension
:
IExtension
WithFocus
,
index
:
number
,
data
:
ITemplateData
):
void
{
renderElement
(
extension
:
IExtension
,
index
:
number
,
data
:
ITemplateData
):
void
{
removeClass
(
data
.
element
,
'
loading
'
);
data
.
extensionDisposables
=
dispose
(
data
.
extensionDisposables
);
...
...
@@ -195,13 +196,17 @@ export class Renderer implements IPagedRenderer<IExtension, ITemplateData> {
data
.
description
.
textContent
=
extension
.
gallery
.
properties
.
localizedLanguages
.
map
(
name
=>
name
[
0
].
toLocaleUpperCase
()
+
name
.
slice
(
1
)).
join
(
'
,
'
);
}
if
(
extension
.
onDidFocusChange
)
{
data
.
extensionDisposables
.
push
(
extension
.
onDidFocusChange
(
hasFocus
=>
{
data
.
actionbar
.
items
.
forEach
(
item
=>
{
(
<
ExtensionActionItem
>
item
).
setFocus
(
hasFocus
);
});
}));
this
.
extensionViewState
.
onFocus
(
e
=>
{
if
(
areSameExtensions
(
extension
,
e
))
{
data
.
actionbar
.
items
.
forEach
(
item
=>
(
<
ExtensionActionItem
>
item
).
setFocus
(
true
));
}
},
this
,
data
.
extensionDisposables
);
this
.
extensionViewState
.
onBlur
(
e
=>
{
if
(
areSameExtensions
(
extension
,
e
))
{
data
.
actionbar
.
items
.
forEach
(
item
=>
(
<
ExtensionActionItem
>
item
).
setFocus
(
false
));
}
},
this
,
data
.
extensionDisposables
);
}
private
updateRecommendationStatus
(
extension
:
IExtension
,
data
:
ITemplateData
)
{
...
...
src/vs/workbench/parts/extensions/electron-browser/extensionsViews.ts
浏览文件 @
02464b72
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
localize
}
from
'
vs/nls
'
;
import
{
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
isPromiseCanceledError
}
from
'
vs/base/common/errors
'
;
...
...
@@ -15,8 +15,8 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
append
,
$
,
toggleClass
}
from
'
vs/base/browser/dom
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
Delegate
,
Renderer
,
IExtension
WithFocus
as
IExtension
}
from
'
vs/workbench/parts/extensions/electron-browser/extensionsList
'
;
import
{
IExtension
as
IExtensionBase
,
IExtensionsWorkbenchService
}
from
'
../common/extensions
'
;
import
{
Delegate
,
Renderer
,
IExtension
sViewState
}
from
'
vs/workbench/parts/extensions/electron-browser/extensionsList
'
;
import
{
IExtension
,
IExtensionsWorkbenchService
}
from
'
../common/extensions
'
;
import
{
Query
}
from
'
../common/extensionQuery
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
...
...
@@ -37,12 +37,29 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import
{
distinct
}
from
'
vs/base/common/arrays
'
;
import
{
IExperimentService
,
IExperiment
,
ExperimentActionType
}
from
'
vs/workbench/parts/experiments/node/experimentService
'
;
import
{
alert
}
from
'
vs/base/browser/ui/aria/aria
'
;
import
{
IListContextMenuEvent
,
IListEvent
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
IListContextMenuEvent
}
from
'
vs/base/browser/ui/list/list
'
;
import
{
createErrorWithActions
}
from
'
vs/base/common/errorsWithActions
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
getKeywordsForExtension
}
from
'
vs/workbench/parts/extensions/electron-browser/extensionsUtils
'
;
import
{
IAction
}
from
'
vs/base/common/actions
'
;
class
ExtensionsViewState
extends
Disposable
implements
IExtensionsViewState
{
private
readonly
_onFocus
:
Emitter
<
IExtension
>
=
this
.
_register
(
new
Emitter
<
IExtension
>
());
readonly
onFocus
:
Event
<
IExtension
>
=
this
.
_onFocus
.
event
;
private
readonly
_onBlur
:
Emitter
<
IExtension
>
=
this
.
_register
(
new
Emitter
<
IExtension
>
());
readonly
onBlur
:
Event
<
IExtension
>
=
this
.
_onBlur
.
event
;
private
currentlyFocusedItems
:
IExtension
[]
=
[];
onFocusChange
(
extensions
:
IExtension
[]):
void
{
this
.
currentlyFocusedItems
.
forEach
(
extension
=>
this
.
_onBlur
.
fire
(
extension
));
this
.
currentlyFocusedItems
=
extensions
;
this
.
currentlyFocusedItems
.
forEach
(
extension
=>
this
.
_onFocus
.
fire
(
extension
));
}
}
export
class
ExtensionsListView
extends
ViewletPanel
{
private
messageBox
:
HTMLElement
;
...
...
@@ -87,15 +104,17 @@ export class ExtensionsListView extends ViewletPanel {
this
.
extensionsList
=
append
(
container
,
$
(
'
.extensions-list
'
));
this
.
messageBox
=
append
(
container
,
$
(
'
.message
'
));
const
delegate
=
new
Delegate
();
const
renderer
=
this
.
instantiationService
.
createInstance
(
Renderer
);
const
extensionsViewState
=
new
ExtensionsViewState
();
const
renderer
=
this
.
instantiationService
.
createInstance
(
Renderer
,
extensionsViewState
);
this
.
list
=
this
.
instantiationService
.
createInstance
(
WorkbenchPagedList
,
this
.
extensionsList
,
delegate
,
[
renderer
],
{
ariaLabel
:
localize
(
'
extensions
'
,
"
Extensions
"
),
multipleSelectionSupport
:
false
,
setRowLineHeight
:
false
})
as
WorkbenchPagedList
<
IExtension
>
;
this
.
list
.
onContextMenu
(
e
=>
this
.
onContextMenu
(
e
),
this
,
this
.
disposables
);
this
.
list
.
onFocusChange
(
e
=>
this
.
onFocusChange
(
e
),
this
,
this
.
disposables
);
this
.
list
.
onFocusChange
(
e
=>
extensionsViewState
.
onFocusChange
(
e
.
elements
),
this
,
this
.
disposables
);
this
.
disposables
.
push
(
this
.
list
);
this
.
disposables
.
push
(
extensionsViewState
);
Event
.
chain
(
this
.
list
.
onOpen
)
.
map
(
e
=>
e
.
elements
[
0
])
...
...
@@ -154,13 +173,6 @@ export class ExtensionsListView extends ViewletPanel {
return
Promise
.
resolve
(
emptyModel
);
}
private
currentlyFocusedItems
:
IExtension
[]
=
[];
private
onFocusChange
(
e
:
IListEvent
<
IExtension
>
):
void
{
this
.
currentlyFocusedItems
.
forEach
(
item
=>
item
.
onFocusChangeEventEmitter
.
fire
(
false
));
this
.
currentlyFocusedItems
=
e
.
elements
;
this
.
currentlyFocusedItems
.
forEach
(
item
=>
item
.
onFocusChangeEventEmitter
.
fire
(
true
));
}
private
onContextMenu
(
e
:
IListContextMenuEvent
<
IExtension
>
):
void
{
if
(
e
.
element
)
{
this
.
extensionService
.
getExtensions
()
...
...
@@ -660,28 +672,15 @@ export class ExtensionsListView extends ViewletPanel {
this
.
notificationService
.
error
(
err
);
}
private
getPagedModel
(
arg
:
IPager
<
IExtensionBase
>
|
IExtensionBase
[]):
IPagedModel
<
IExtension
>
{
const
convert
=
(
ext
:
IExtension
):
IExtension
=>
{
const
eventEmitter
=
new
Emitter
<
boolean
>
();
const
extFocus
:
IExtension
=
ext
;
extFocus
.
onFocusChangeEventEmitter
=
eventEmitter
;
extFocus
.
onDidFocusChange
=
eventEmitter
.
event
;
return
extFocus
;
};
private
getPagedModel
(
arg
:
IPager
<
IExtension
>
|
IExtension
[]):
IPagedModel
<
IExtension
>
{
if
(
Array
.
isArray
(
arg
))
{
return
new
PagedModel
(
arg
.
map
(
ext
=>
convert
(
ext
))
);
return
new
PagedModel
(
arg
);
}
const
pager
=
{
total
:
arg
.
total
,
pageSize
:
arg
.
pageSize
,
firstPage
:
arg
.
firstPage
.
map
(
ext
=>
convert
(
ext
)),
getPage
:
(
pageIndex
:
number
,
cancellationToken
:
CancellationToken
)
=>
{
return
arg
.
getPage
(
pageIndex
,
cancellationToken
).
then
(
extensions
=>
{
return
extensions
.
map
(
ext
=>
convert
(
ext
));
});
}
firstPage
:
arg
.
firstPage
,
getPage
:
(
pageIndex
:
number
,
cancellationToken
:
CancellationToken
)
=>
arg
.
getPage
(
pageIndex
,
cancellationToken
)
};
return
new
PagedModel
(
pager
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录