Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7d2bf6ac
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,发现更多精彩内容 >>
提交
7d2bf6ac
编写于
2月 14, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
list: support trait persistence
上级
8dde28b8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
24 deletion
+35
-24
src/vs/base/browser/ui/list/listPaging.ts
src/vs/base/browser/ui/list/listPaging.ts
+1
-1
src/vs/base/browser/ui/list/listWidget.ts
src/vs/base/browser/ui/list/listWidget.ts
+34
-23
未找到文件。
src/vs/base/browser/ui/list/listPaging.ts
浏览文件 @
7d2bf6ac
...
@@ -67,7 +67,7 @@ export class PagedList<T> {
...
@@ -67,7 +67,7 @@ export class PagedList<T> {
container
:
HTMLElement
,
container
:
HTMLElement
,
delegate
:
IDelegate
<
number
>
,
delegate
:
IDelegate
<
number
>
,
renderers
:
IPagedRenderer
<
T
,
any
>
[],
renderers
:
IPagedRenderer
<
T
,
any
>
[],
options
:
IListOptions
=
{}
options
:
IListOptions
<
any
>
=
{}
// TODO@Joao: should be IListOptions<T>
)
{
)
{
const
pagedRenderers
=
renderers
.
map
(
r
=>
new
PagedRenderer
<
T
,
ITemplateData
<
T
>>
(
r
,
()
=>
this
.
model
));
const
pagedRenderers
=
renderers
.
map
(
r
=>
new
PagedRenderer
<
T
,
ITemplateData
<
T
>>
(
r
,
()
=>
this
.
model
));
this
.
list
=
new
List
(
container
,
delegate
,
pagedRenderers
,
options
);
this
.
list
=
new
List
(
container
,
delegate
,
pagedRenderers
,
options
);
...
...
src/vs/base/browser/ui/list/listWidget.ts
浏览文件 @
7d2bf6ac
...
@@ -16,6 +16,10 @@ import { domEvent } from 'vs/base/browser/event';
...
@@ -16,6 +16,10 @@ import { domEvent } from 'vs/base/browser/event';
import
{
IDelegate
,
IRenderer
,
IListMouseEvent
,
IFocusChangeEvent
,
ISelectionChangeEvent
}
from
'
./list
'
;
import
{
IDelegate
,
IRenderer
,
IListMouseEvent
,
IFocusChangeEvent
,
ISelectionChangeEvent
}
from
'
./list
'
;
import
{
ListView
,
IListViewOptions
}
from
'
./listView
'
;
import
{
ListView
,
IListViewOptions
}
from
'
./listView
'
;
export
interface
IIdentityProvider
<
T
>
{
(
element
:
T
):
string
;
}
interface
ITraitTemplateData
<
D
>
{
interface
ITraitTemplateData
<
D
>
{
container
:
HTMLElement
;
container
:
HTMLElement
;
data
:
D
;
data
:
D
;
...
@@ -63,18 +67,14 @@ class Trait<T> implements IDisposable {
...
@@ -63,18 +67,14 @@ class Trait<T> implements IDisposable {
this
.
indexes
=
[];
this
.
indexes
=
[];
}
}
splice
(
start
:
number
,
deleteCount
:
number
,
insertCount
:
number
):
void
{
splice
(
start
:
number
,
deleteCount
:
number
,
elements
:
boolean
[]
):
void
{
const
diff
=
insertCount
-
deleteCount
;
const
diff
=
elements
.
length
-
deleteCount
;
const
end
=
start
+
deleteCount
;
const
end
=
start
+
deleteCount
;
const
indexes
:
number
[]
=
[];
const
indexes
=
[
...
this
.
indexes
.
filter
(
i
=>
i
<
start
),
for
(
let
index
of
indexes
)
{
...
elements
.
reduce
((
r
,
hasTrait
,
i
)
=>
hasTrait
?
[...
r
,
i
+
start
]
:
r
,
[]),
if
(
index
>=
start
&&
index
<
end
)
{
...
this
.
indexes
.
filter
(
i
=>
i
>=
end
).
map
(
i
=>
i
+
diff
)
continue
;
];
}
indexes
.
push
(
index
>
start
?
index
+
diff
:
index
);
}
this
.
indexes
=
indexes
;
this
.
indexes
=
indexes
;
this
.
_onChange
.
fire
({
indexes
});
this
.
_onChange
.
fire
({
indexes
});
...
@@ -111,14 +111,16 @@ class Trait<T> implements IDisposable {
...
@@ -111,14 +111,16 @@ class Trait<T> implements IDisposable {
class
FocusTrait
<
T
>
extends
Trait
<
T
>
{
class
FocusTrait
<
T
>
extends
Trait
<
T
>
{
constructor
(
private
getElementId
:
(
number
:
number
)
=>
string
)
{
constructor
(
private
getDomId
:
IIdentityProvider
<
number
>
)
{
super
(
'
focused
'
);
super
(
'
focused
'
);
}
}
renderElement
(
element
:
T
,
index
:
number
,
container
:
HTMLElement
):
void
{
renderElement
(
element
:
T
,
index
:
number
,
container
:
HTMLElement
):
void
{
super
.
renderElement
(
element
,
index
,
container
);
super
.
renderElement
(
element
,
index
,
container
);
container
.
setAttribute
(
'
role
'
,
'
treeitem
'
);
container
.
setAttribute
(
'
role
'
,
'
treeitem
'
);
container
.
setAttribute
(
'
id
'
,
this
.
get
Element
Id
(
index
));
container
.
setAttribute
(
'
id
'
,
this
.
get
Dom
Id
(
index
));
}
}
}
}
...
@@ -215,13 +217,14 @@ class MouseController<T> implements IDisposable {
...
@@ -215,13 +217,14 @@ class MouseController<T> implements IDisposable {
}
}
}
}
export
interface
IListOptions
extends
IListViewOptions
{
export
interface
IListOptions
<
T
>
extends
IListViewOptions
{
identityProvider
?:
IIdentityProvider
<
T
>
;
ariaLabel
?:
string
;
ariaLabel
?:
string
;
mouseSupport
?:
boolean
;
mouseSupport
?:
boolean
;
keyboardSupport
?:
boolean
;
keyboardSupport
?:
boolean
;
}
}
const
DefaultOptions
:
IListOptions
=
{
const
DefaultOptions
:
IListOptions
<
any
>
=
{
keyboardSupport
:
true
,
keyboardSupport
:
true
,
mouseSupport
:
true
mouseSupport
:
true
};
};
...
@@ -235,16 +238,17 @@ export class List<T> implements IDisposable {
...
@@ -235,16 +238,17 @@ export class List<T> implements IDisposable {
private
selection
:
Trait
<
T
>
;
private
selection
:
Trait
<
T
>
;
private
eventBufferer
:
EventBufferer
;
private
eventBufferer
:
EventBufferer
;
private
view
:
ListView
<
T
>
;
private
view
:
ListView
<
T
>
;
private
getId
?:
IIdentityProvider
<
T
>
;
private
disposables
:
IDisposable
[];
private
disposables
:
IDisposable
[];
@
memoize
@
memoize
get
onFocusChange
():
Event
<
IFocusChangeEvent
<
T
>>
{
get
onFocusChange
():
Event
<
IFocusChangeEvent
<
T
>>
{
return
this
.
eventBufferer
.
wrapEvent
(
mapEvent
(
this
.
focus
.
onChange
,
e
=>
this
.
toListEvent
(
e
)
));
return
mapEvent
(
this
.
eventBufferer
.
wrapEvent
(
this
.
focus
.
onChange
),
e
=>
this
.
toListEvent
(
e
));
}
}
@
memoize
@
memoize
get
onSelectionChange
():
Event
<
ISelectionChangeEvent
<
T
>>
{
get
onSelectionChange
():
Event
<
ISelectionChangeEvent
<
T
>>
{
return
this
.
eventBufferer
.
wrapEvent
(
mapEvent
(
this
.
selection
.
onChange
,
e
=>
this
.
toListEvent
(
e
)
));
return
mapEvent
(
this
.
eventBufferer
.
wrapEvent
(
this
.
selection
.
onChange
),
e
=>
this
.
toListEvent
(
e
));
}
}
@
memoize
@
memoize
...
@@ -265,11 +269,12 @@ export class List<T> implements IDisposable {
...
@@ -265,11 +269,12 @@ export class List<T> implements IDisposable {
container
:
HTMLElement
,
container
:
HTMLElement
,
delegate
:
IDelegate
<
T
>
,
delegate
:
IDelegate
<
T
>
,
renderers
:
IRenderer
<
T
,
any
>
[],
renderers
:
IRenderer
<
T
,
any
>
[],
options
:
IListOptions
=
DefaultOptions
options
:
IListOptions
<
T
>
=
DefaultOptions
)
{
)
{
this
.
focus
=
new
FocusTrait
(
i
=>
this
.
getElementId
(
i
));
this
.
focus
=
new
FocusTrait
(
i
=>
this
.
getElement
Dom
Id
(
i
));
this
.
selection
=
new
Trait
(
'
selected
'
);
this
.
selection
=
new
Trait
(
'
selected
'
);
this
.
eventBufferer
=
new
EventBufferer
();
this
.
eventBufferer
=
new
EventBufferer
();
this
.
getId
=
options
.
identityProvider
;
renderers
=
renderers
.
map
(
r
=>
{
renderers
=
renderers
.
map
(
r
=>
{
r
=
this
.
focus
.
wrapRenderer
(
r
);
r
=
this
.
focus
.
wrapRenderer
(
r
);
...
@@ -304,8 +309,14 @@ export class List<T> implements IDisposable {
...
@@ -304,8 +309,14 @@ export class List<T> implements IDisposable {
splice
(
start
:
number
,
deleteCount
:
number
,
elements
:
T
[]
=
[]):
void
{
splice
(
start
:
number
,
deleteCount
:
number
,
elements
:
T
[]
=
[]):
void
{
this
.
eventBufferer
.
bufferEvents
(()
=>
{
this
.
eventBufferer
.
bufferEvents
(()
=>
{
this
.
focus
.
splice
(
start
,
deleteCount
,
elements
.
length
);
const
focus
=
this
.
focus
.
get
().
map
(
i
=>
this
.
getId
(
this
.
view
.
element
(
i
)));
this
.
selection
.
splice
(
start
,
deleteCount
,
elements
.
length
);
const
focusElements
=
elements
.
map
(
e
=>
focus
.
indexOf
(
this
.
getId
(
e
))
>
-
1
);
const
selection
=
this
.
selection
.
get
().
map
(
i
=>
this
.
getId
(
this
.
view
.
element
(
i
)));
const
selectionElements
=
elements
.
map
(
e
=>
selection
.
indexOf
(
this
.
getId
(
e
))
>
-
1
);
this
.
focus
.
splice
(
start
,
deleteCount
,
focusElements
);
this
.
selection
.
splice
(
start
,
deleteCount
,
selectionElements
);
this
.
view
.
splice
(
start
,
deleteCount
,
elements
);
this
.
view
.
splice
(
start
,
deleteCount
,
elements
);
});
});
}
}
...
@@ -457,7 +468,7 @@ export class List<T> implements IDisposable {
...
@@ -457,7 +468,7 @@ export class List<T> implements IDisposable {
}
}
}
}
getElementId
(
index
:
number
):
string
{
getElement
Dom
Id
(
index
:
number
):
string
{
return
`
${
this
.
idPrefix
}
_
${
index
}
`
;
return
`
${
this
.
idPrefix
}
_
${
index
}
`
;
}
}
...
@@ -477,7 +488,7 @@ export class List<T> implements IDisposable {
...
@@ -477,7 +488,7 @@ export class List<T> implements IDisposable {
const
focus
=
this
.
focus
.
get
();
const
focus
=
this
.
focus
.
get
();
if
(
focus
.
length
>
0
)
{
if
(
focus
.
length
>
0
)
{
this
.
view
.
domNode
.
setAttribute
(
'
aria-activedescendant
'
,
this
.
getElementId
(
focus
[
0
]));
this
.
view
.
domNode
.
setAttribute
(
'
aria-activedescendant
'
,
this
.
getElement
Dom
Id
(
focus
[
0
]));
}
else
{
}
else
{
this
.
view
.
domNode
.
removeAttribute
(
'
aria-activedescendant
'
);
this
.
view
.
domNode
.
removeAttribute
(
'
aria-activedescendant
'
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录