Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
43a42281
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,发现更多精彩内容 >>
提交
43a42281
编写于
2月 14, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
notifications - introduce simple alerts
上级
e96078d0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
85 addition
and
27 deletion
+85
-27
src/vs/workbench/browser/parts/notifications/notificationsAlerts.ts
...kbench/browser/parts/notifications/notificationsAlerts.ts
+53
-0
src/vs/workbench/browser/parts/notifications/notificationsCenter.ts
...kbench/browser/parts/notifications/notificationsCenter.ts
+19
-21
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+13
-6
未找到文件。
src/vs/workbench/browser/parts/notifications/notificationsAlerts.ts
0 → 100644
浏览文件 @
43a42281
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
alert
}
from
'
vs/base/browser/ui/aria/aria
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
INotificationViewItem
,
INotificationsModel
,
NotificationChangeType
,
INotificationChangeEvent
}
from
'
vs/workbench/common/notifications
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
export
class
NotificationsAlerts
{
private
toDispose
:
IDisposable
[];
constructor
(
private
model
:
INotificationsModel
)
{
this
.
toDispose
=
[];
// Alert initial notifications if any
model
.
notifications
.
forEach
(
n
=>
this
.
ariaAlert
(
n
));
this
.
registerListeners
();
}
private
registerListeners
():
void
{
this
.
toDispose
.
push
(
this
.
model
.
onDidNotificationsChange
(
e
=>
this
.
onDidNotificationsChange
(
e
)));
}
private
onDidNotificationsChange
(
e
:
INotificationChangeEvent
):
void
{
if
(
e
.
kind
===
NotificationChangeType
.
ADD
)
{
this
.
ariaAlert
(
e
.
item
);
}
}
private
ariaAlert
(
notifiation
:
INotificationViewItem
):
void
{
let
alertText
:
string
;
if
(
notifiation
.
severity
===
Severity
.
Error
)
{
alertText
=
localize
(
'
alertErrorMessage
'
,
"
Error: {0}
"
,
notifiation
.
message
.
value
);
}
else
if
(
notifiation
.
severity
===
Severity
.
Warning
)
{
alertText
=
localize
(
'
alertWarningMessage
'
,
"
Warning: {0}
"
,
notifiation
.
message
.
value
);
}
else
{
alertText
=
localize
(
'
alertInfoMessage
'
,
"
Info: {0}
"
,
notifiation
.
message
.
value
);
}
alert
(
alertText
);
}
public
dispose
():
void
{
this
.
toDispose
=
dispose
(
this
.
toDispose
);
}
}
\ No newline at end of file
src/vs/workbench/browser/parts/notifications/notifications
List
.ts
→
src/vs/workbench/browser/parts/notifications/notifications
Center
.ts
浏览文件 @
43a42281
...
...
@@ -16,13 +16,12 @@ import { IThemeService, registerThemingParticipant, ITheme, ICssStyleCollector }
import
{
contrastBorder
,
widgetShadow
,
textLinkForeground
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
INotificationViewItem
,
INotificationsModel
,
INotificationChangeEvent
,
NotificationChangeType
}
from
'
vs/workbench/common/notifications
'
;
import
{
NotificationsListDelegate
,
NotificationRenderer
}
from
'
vs/workbench/browser/parts/notifications/notificationsViewer
'
;
import
{
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
alert
}
from
'
vs/base/browser/ui/aria/aria
'
;
export
class
Notification
List
extends
Themable
{
export
class
Notification
sCenter
extends
Themable
{
private
listContainer
:
HTMLElement
;
private
list
:
WorkbenchList
<
INotificationViewItem
>
;
private
viewModel
:
INotificationViewItem
[];
constructor
(
private
container
:
HTMLElement
,
...
...
@@ -32,6 +31,8 @@ export class NotificationList extends Themable {
)
{
super
(
themeService
);
this
.
viewModel
=
[];
this
.
create
();
// Show initial notifications if any
...
...
@@ -94,11 +95,6 @@ export class NotificationList extends Themable {
}
private
onNotificationsAdded
(
index
:
number
,
items
:
INotificationViewItem
[]):
void
{
// Support in Screen Readers too
items
.
forEach
(
item
=>
this
.
ariaAlert
(
item
));
// Update list
this
.
updateNotificationsList
(
index
,
0
,
items
);
}
...
...
@@ -119,9 +115,24 @@ export class NotificationList extends Themable {
this
.
hide
();
}
// Remember focus/selection
const
selection
=
this
.
indexToItems
(
this
.
list
.
getSelection
());
const
focus
=
this
.
indexToItems
(
this
.
list
.
getFocus
());
// Update view model
this
.
viewModel
.
splice
(
start
,
deleteCount
,
...
items
);
// Update list
this
.
list
.
splice
(
start
,
deleteCount
,
items
);
this
.
list
.
layout
();
// Restore focus/selection
this
.
list
.
setSelection
(
selection
.
map
(
s
=>
this
.
viewModel
.
indexOf
(
s
)));
this
.
list
.
setFocus
(
focus
.
map
(
f
=>
this
.
viewModel
.
indexOf
(
f
)));
}
private
indexToItems
(
indeces
:
number
[]):
INotificationViewItem
[]
{
return
indeces
.
map
(
index
=>
this
.
viewModel
[
index
]).
filter
(
item
=>
!!
item
);
}
private
show
():
void
{
...
...
@@ -131,19 +142,6 @@ export class NotificationList extends Themable {
private
hide
():
void
{
removeClass
(
this
.
listContainer
,
'
visible
'
);
}
private
ariaAlert
(
notifiation
:
INotificationViewItem
):
void
{
let
alertText
:
string
;
if
(
notifiation
.
severity
===
Severity
.
Error
)
{
alertText
=
localize
(
'
alertErrorMessage
'
,
"
Error: {0}
"
,
notifiation
.
message
.
value
);
}
else
if
(
notifiation
.
severity
===
Severity
.
Warning
)
{
alertText
=
localize
(
'
alertWarningMessage
'
,
"
Warning: {0}
"
,
notifiation
.
message
.
value
);
}
else
{
alertText
=
localize
(
'
alertInfoMessage
'
,
"
Info: {0}
"
,
notifiation
.
message
.
value
);
}
alert
(
alertText
);
}
}
registerThemingParticipant
((
theme
:
ITheme
,
collector
:
ICssStyleCollector
)
=>
{
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
43a42281
...
...
@@ -101,7 +101,8 @@ import { ICustomViewsService } from 'vs/workbench/common/views';
import
{
CustomViewsService
}
from
'
vs/workbench/browser/parts/views/customView
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
NotificationService
}
from
'
vs/workbench/services/notification/common/notificationService
'
;
import
{
NotificationList
}
from
'
vs/workbench/browser/parts/notifications/notificationsList
'
;
import
{
NotificationsCenter
}
from
'
vs/workbench/browser/parts/notifications/notificationsCenter
'
;
import
{
NotificationsAlerts
}
from
'
vs/workbench/browser/parts/notifications/notificationsAlerts
'
;
export
const
MessagesVisibleContext
=
new
RawContextKey
<
boolean
>
(
'
globalMessageVisible
'
,
false
);
export
const
EditorsVisibleContext
=
new
RawContextKey
<
boolean
>
(
'
editorIsOpen
'
,
false
);
...
...
@@ -1173,8 +1174,8 @@ export class Workbench implements IPartService {
this
.
createPanelPart
();
this
.
createStatusbarPart
();
// Notification
s List
this
.
createNotifications
List
();
// Notification
Handlers
this
.
createNotifications
Handlers
();
// Add Workbench to DOM
this
.
workbenchContainer
.
build
(
this
.
container
);
...
...
@@ -1244,9 +1245,15 @@ export class Workbench implements IPartService {
this
.
statusbarPart
.
create
(
statusbarContainer
);
}
private
createNotificationsList
():
void
{
const
notificationsList
=
this
.
instantiationService
.
createInstance
(
NotificationList
,
this
.
workbench
.
getHTMLElement
(),
this
.
notificationService
.
model
);
this
.
toUnbind
.
push
(
notificationsList
);
private
createNotificationsHandlers
():
void
{
// Notification Center
const
notificationsCenter
=
this
.
instantiationService
.
createInstance
(
NotificationsCenter
,
this
.
workbench
.
getHTMLElement
(),
this
.
notificationService
.
model
);
this
.
toUnbind
.
push
(
notificationsCenter
);
// Notification Alerts
const
notificationsAlerts
=
this
.
instantiationService
.
createInstance
(
NotificationsAlerts
,
this
.
notificationService
.
model
);
this
.
toUnbind
.
push
(
notificationsAlerts
);
}
public
getInstantiationService
():
IInstantiationService
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录