Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
bb22fc89
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,发现更多精彩内容 >>
提交
bb22fc89
编写于
7月 06, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - use modern Events for Action
上级
f0c30ada
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
83 addition
and
82 deletion
+83
-82
src/vs/base/browser/ui/actionbar/actionbar.ts
src/vs/base/browser/ui/actionbar/actionbar.ts
+28
-37
src/vs/base/common/actions.ts
src/vs/base/common/actions.ts
+23
-13
src/vs/platform/actions/common/actions.ts
src/vs/platform/actions/common/actions.ts
+11
-9
src/vs/workbench/browser/parts/activitybar/activityAction.ts
src/vs/workbench/browser/parts/activitybar/activityAction.ts
+18
-18
src/vs/workbench/parts/debug/browser/debugViewer.ts
src/vs/workbench/parts/debug/browser/debugViewer.ts
+1
-1
src/vs/workbench/parts/debug/browser/debugViews.ts
src/vs/workbench/parts/debug/browser/debugViews.ts
+1
-1
src/vs/workbench/parts/extensions/electron-browser/extensionsActions.ts
...ch/parts/extensions/electron-browser/extensionsActions.ts
+1
-3
未找到文件。
src/vs/base/browser/ui/actionbar/actionbar.ts
浏览文件 @
bb22fc89
...
...
@@ -11,11 +11,11 @@ import lifecycle = require('vs/base/common/lifecycle');
import
{
Promise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Builder
,
$
}
from
'
vs/base/browser/builder
'
;
import
platform
=
require
(
'
vs/base/common/platform
'
);
import
{
IAction
,
IActionRunner
,
Action
,
ActionRunner
}
from
'
vs/base/common/actions
'
;
import
{
IAction
,
IActionRunner
,
Action
,
IActionChangeEvent
,
ActionRunner
}
from
'
vs/base/common/actions
'
;
import
DOM
=
require
(
'
vs/base/browser/dom
'
);
import
{
EventType
as
CommonEventType
}
from
'
vs/base/common/events
'
;
import
types
=
require
(
'
vs/base/common/types
'
);
import
{
IEventEmitter
,
EventEmitter
,
EmitterEvent
}
from
'
vs/base/common/eventEmitter
'
;
import
{
IEventEmitter
,
EventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
Gesture
,
EventType
}
from
'
vs/base/browser/touch
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
CommonKeybindings
}
from
'
vs/base/common/keyCodes
'
;
...
...
@@ -48,38 +48,33 @@ export class BaseActionItem extends EventEmitter implements IActionItem {
this
.
_action
=
action
;
if
(
action
instanceof
Action
)
{
let
l
=
(
<
Action
>
action
).
addBulkListener2
((
events
:
EmitterEvent
[])
=>
{
this
.
_callOnDispose
.
push
(
action
.
onDidChange
(
event
=>
{
if
(
!
this
.
builder
)
{
// we have not been rendered yet, so there
// is no point in updating the UI
return
;
}
this
.
_handleActionChangeEvent
(
event
);
}));
}
}
events
.
forEach
((
event
:
EmitterEvent
)
=>
{
switch
(
event
.
getType
())
{
case
Action
.
ENABLED
:
this
.
_updateEnabled
();
break
;
case
Action
.
LABEL
:
this
.
_updateLabel
();
this
.
_updateTooltip
();
break
;
case
Action
.
TOOLTIP
:
this
.
_updateTooltip
();
break
;
case
Action
.
CLASS
:
this
.
_updateClass
();
break
;
case
Action
.
CHECKED
:
this
.
_updateChecked
();
break
;
default
:
this
.
_updateUnknown
(
event
);
break
;
}
});
});
this
.
_callOnDispose
.
push
(
l
);
protected
_handleActionChangeEvent
(
event
:
IActionChangeEvent
):
void
{
if
(
event
.
enabled
!==
void
0
)
{
this
.
_updateEnabled
();
}
if
(
event
.
checked
!==
void
0
)
{
this
.
_updateChecked
();
}
if
(
event
.
class
!==
void
0
)
{
this
.
_updateClass
();
}
if
(
event
.
label
!==
void
0
)
{
this
.
_updateLabel
();
this
.
_updateTooltip
();
}
if
(
event
.
tooltip
!==
void
0
)
{
this
.
_updateTooltip
();
}
}
...
...
@@ -161,30 +156,26 @@ export class BaseActionItem extends EventEmitter implements IActionItem {
}
}
p
ublic
_updateEnabled
():
void
{
p
rotected
_updateEnabled
():
void
{
// implement in subclass
}
p
ublic
_updateLabel
():
void
{
p
rotected
_updateLabel
():
void
{
// implement in subclass
}
p
ublic
_updateTooltip
():
void
{
p
rotected
_updateTooltip
():
void
{
// implement in subclass
}
p
ublic
_updateClass
():
void
{
p
rotected
_updateClass
():
void
{
// implement in subclass
}
p
ublic
_updateChecked
():
void
{
p
rotected
_updateChecked
():
void
{
// implement in subclass
}
public
_updateUnknown
(
event
:
EmitterEvent
):
void
{
// can implement in subclass
}
public
dispose
():
void
{
super
.
dispose
();
...
...
src/vs/base/common/actions.ts
浏览文件 @
bb22fc89
...
...
@@ -8,6 +8,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import
{
IEventEmitter
,
EventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
Events
from
'
vs/base/common/events
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
export
interface
IAction
extends
IDisposable
{
id
:
string
;
...
...
@@ -68,14 +69,17 @@ export interface IActionProvider {
getAction
(
id
:
string
):
IAction
;
}
export
class
Action
extends
EventEmitter
implements
IAction
{
export
interface
IActionChangeEvent
{
label
?:
string
;
tooltip
?:
string
;
class
?:
string
;
enabled
?:
boolean
;
checked
?:
boolean
;
}
static
LABEL
:
string
=
'
label
'
;
static
TOOLTIP
:
string
=
'
tooltip
'
;
static
CLASS
:
string
=
'
class
'
;
static
ENABLED
:
string
=
'
enabled
'
;
static
CHECKED
:
string
=
'
checked
'
;
export
class
Action
implements
IAction
{
protected
_onDidChange
=
new
Emitter
<
IActionChangeEvent
>
();
protected
_id
:
string
;
protected
_label
:
string
;
protected
_tooltip
:
string
;
...
...
@@ -86,8 +90,6 @@ export class Action extends EventEmitter implements IAction {
protected
_order
:
number
;
constructor
(
id
:
string
,
label
:
string
=
''
,
cssClass
:
string
=
''
,
enabled
:
boolean
=
true
,
actionCallback
:
IActionCallback
=
null
)
{
super
();
this
.
_id
=
id
;
this
.
_label
=
label
;
this
.
_cssClass
=
cssClass
;
...
...
@@ -95,6 +97,14 @@ export class Action extends EventEmitter implements IAction {
this
.
_actionCallback
=
actionCallback
;
}
public
dispose
()
{
this
.
_onDidChange
.
dispose
();
}
public
get
onDidChange
():
Event
<
IActionChangeEvent
>
{
return
this
.
_onDidChange
.
event
;
}
public
get
id
():
string
{
return
this
.
_id
;
}
...
...
@@ -110,7 +120,7 @@ export class Action extends EventEmitter implements IAction {
protected
_setLabel
(
value
:
string
):
void
{
if
(
this
.
_label
!==
value
)
{
this
.
_label
=
value
;
this
.
emit
(
Action
.
LABEL
,
{
source
:
this
});
this
.
_onDidChange
.
fire
({
label
:
value
});
}
}
...
...
@@ -125,7 +135,7 @@ export class Action extends EventEmitter implements IAction {
protected
_setTooltip
(
value
:
string
):
void
{
if
(
this
.
_tooltip
!==
value
)
{
this
.
_tooltip
=
value
;
this
.
emit
(
Action
.
TOOLTIP
,
{
source
:
this
});
this
.
_onDidChange
.
fire
({
tooltip
:
value
});
}
}
...
...
@@ -140,7 +150,7 @@ export class Action extends EventEmitter implements IAction {
protected
_setClass
(
value
:
string
):
void
{
if
(
this
.
_cssClass
!==
value
)
{
this
.
_cssClass
=
value
;
this
.
emit
(
Action
.
CLASS
,
{
source
:
this
});
this
.
_onDidChange
.
fire
({
class
:
value
});
}
}
...
...
@@ -155,7 +165,7 @@ export class Action extends EventEmitter implements IAction {
protected
_setEnabled
(
value
:
boolean
):
void
{
if
(
this
.
_enabled
!==
value
)
{
this
.
_enabled
=
value
;
this
.
emit
(
Action
.
ENABLED
,
{
source
:
this
});
this
.
_onDidChange
.
fire
({
enabled
:
value
});
}
}
...
...
@@ -170,7 +180,7 @@ export class Action extends EventEmitter implements IAction {
protected
_setChecked
(
value
:
boolean
):
void
{
if
(
this
.
_checked
!==
value
)
{
this
.
_checked
=
value
;
this
.
emit
(
Action
.
CHECKED
,
{
source
:
this
});
this
.
_onDidChange
.
fire
({
checked
:
value
});
}
}
...
...
src/vs/platform/actions/common/actions.ts
浏览文件 @
bb22fc89
...
...
@@ -7,7 +7,6 @@
import
URI
from
'
vs/base/common/uri
'
;
import
Actions
=
require
(
'
vs/base/common/actions
'
);
import
WinJS
=
require
(
'
vs/base/common/winjs.base
'
);
import
Assert
=
require
(
'
vs/base/common/assert
'
);
import
Descriptors
=
require
(
'
vs/platform/instantiation/common/descriptors
'
);
import
Instantiation
=
require
(
'
vs/platform/instantiation/common/instantiation
'
);
import
{
KbExpr
,
IKeybindings
,
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
...
...
@@ -168,7 +167,8 @@ export class DeferredAction extends Actions.Action {
private
_cachedAction
:
Actions
.
IAction
;
private
_emitterUnbind
:
IDisposable
;
constructor
(
private
_instantiationService
:
Instantiation
.
IInstantiationService
,
private
_descriptor
:
Descriptors
.
AsyncDescriptor0
<
Actions
.
Action
>
,
constructor
(
private
_instantiationService
:
Instantiation
.
IInstantiationService
,
private
_descriptor
:
Descriptors
.
AsyncDescriptor0
<
Actions
.
Action
>
,
id
:
string
,
label
=
''
,
cssClass
=
''
,
enabled
=
true
)
{
super
(
id
,
label
,
cssClass
,
enabled
);
...
...
@@ -265,13 +265,15 @@ export class DeferredAction extends Actions.Action {
let
promise
=
WinJS
.
TPromise
.
as
(
undefined
);
return
promise
.
then
(()
=>
{
return
this
.
_instantiationService
.
createInstance
(
this
.
_descriptor
);
}).
then
((
action
)
=>
{
Assert
.
ok
(
action
instanceof
Actions
.
Action
,
'
Action must be an instanceof Base Action
'
);
this
.
_cachedAction
=
action
;
// Pipe events from the instantated action through this deferred action
this
.
_emitterUnbind
=
this
.
addEmitter2
(
<
Actions
.
Action
>
this
.
_cachedAction
);
}).
then
(
action
=>
{
if
(
action
instanceof
Actions
.
Action
)
{
this
.
_cachedAction
=
action
;
// Pipe events from the instantated action through this deferred action
this
.
_emitterUnbind
=
action
.
onDidChange
(
e
=>
this
.
_onDidChange
.
fire
(
e
));
}
else
{
throw
new
Error
(
'
Action must be an instanceof Base Action
'
);
}
return
action
;
});
...
...
src/vs/workbench/browser/parts/activitybar/activityAction.ts
浏览文件 @
bb22fc89
...
...
@@ -11,14 +11,13 @@ import {Builder, $} from 'vs/base/browser/builder';
import
{
DelayedDragHandler
}
from
'
vs/base/browser/dnd
'
;
import
{
Action
}
from
'
vs/base/common/actions
'
;
import
{
BaseActionItem
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
EmitterEvent
}
from
'
vs/base/common/eventEmitter
'
;
import
{
ProgressBadge
,
TextBadge
,
NumberBadge
,
IconBadge
,
IBadge
}
from
'
vs/workbench/services/activity/common/activityService
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
export
class
ActivityAction
extends
Action
{
static
BADGE
=
'
badge
'
;
private
badge
:
IBadge
;
private
_onDidChangeBadge
=
new
Emitter
<
this
>
();
constructor
(
id
:
string
,
name
:
string
,
clazz
:
string
)
{
super
(
id
,
name
,
clazz
);
...
...
@@ -26,17 +25,19 @@ export class ActivityAction extends Action {
this
.
badge
=
null
;
}
public
get
onDidChangeBadge
():
Event
<
this
>
{
return
this
.
_onDidChangeBadge
.
event
;
}
public
activate
():
void
{
if
(
!
this
.
checked
)
{
this
.
checked
=
true
;
this
.
emit
(
'
checked
'
,
{
source
:
this
});
this
.
_setChecked
(
true
);
}
}
public
deactivate
():
void
{
if
(
this
.
checked
)
{
this
.
checked
=
false
;
this
.
emit
(
'
checked
'
,
{
source
:
this
});
this
.
_setChecked
(
false
);
}
}
...
...
@@ -46,7 +47,7 @@ export class ActivityAction extends Action {
public
setBadge
(
badge
:
IBadge
):
void
{
this
.
badge
=
badge
;
this
.
emit
(
ActivityAction
.
BADGE
,
{
source
:
this
}
);
this
.
_onDidChangeBadge
.
fire
(
this
);
}
}
...
...
@@ -59,12 +60,13 @@ export class ActivityActionItem extends BaseActionItem {
private
$badge
:
Builder
;
private
$badgeContent
:
Builder
;
constructor
(
action
:
Action
,
activityName
:
string
=
action
.
label
,
keybinding
:
string
=
null
)
{
constructor
(
action
:
Acti
vityActi
on
,
activityName
:
string
=
action
.
label
,
keybinding
:
string
=
null
)
{
super
(
null
,
action
);
this
.
cssClass
=
action
.
class
;
this
.
name
=
activityName
;
this
.
_keybinding
=
keybinding
;
action
.
onDidChangeBadge
(
this
.
_handleBadgeChangeEvenet
,
this
,
this
.
_callOnDispose
);
}
public
render
(
container
:
HTMLElement
):
void
{
...
...
@@ -158,7 +160,7 @@ export class ActivityActionItem extends BaseActionItem {
}
}
p
ublic
_updateClass
():
void
{
p
rotected
_updateClass
():
void
{
if
(
this
.
cssClass
)
{
this
.
$badge
.
removeClass
(
this
.
cssClass
);
}
...
...
@@ -167,7 +169,7 @@ export class ActivityActionItem extends BaseActionItem {
this
.
$badge
.
addClass
(
this
.
cssClass
);
}
p
ublic
_updateChecked
():
void
{
p
rotected
_updateChecked
():
void
{
if
(
this
.
getAction
().
checked
)
{
this
.
$e
.
addClass
(
'
active
'
);
}
else
{
...
...
@@ -175,16 +177,14 @@ export class ActivityActionItem extends BaseActionItem {
}
}
public
_updateUnknown
(
event
:
EmitterEvent
):
void
{
if
(
event
.
getType
()
===
ActivityAction
.
BADGE
)
{
let
action
=
this
.
getAction
();
if
(
action
instanceof
ActivityAction
)
{
this
.
updateBadge
((
<
ActivityAction
>
action
).
getBadge
());
}
private
_handleBadgeChangeEvenet
():
void
{
let
action
=
this
.
getAction
();
if
(
action
instanceof
ActivityAction
)
{
this
.
updateBadge
((
<
ActivityAction
>
action
).
getBadge
());
}
}
p
ublic
_updateEnabled
():
void
{
p
rotected
_updateEnabled
():
void
{
if
(
this
.
getAction
().
enabled
)
{
this
.
builder
.
removeClass
(
'
disabled
'
);
}
else
{
...
...
src/vs/workbench/parts/debug/browser/debugViewer.ts
浏览文件 @
bb22fc89
...
...
@@ -990,7 +990,7 @@ export class BreakpointsActionProvider implements renderer.IActionProvider {
actions
.
push
(
this
.
instantiationService
.
createInstance
(
debugactions
.
RemoveAllBreakpointsAction
,
debugactions
.
RemoveAllBreakpointsAction
.
ID
,
debugactions
.
RemoveAllBreakpointsAction
.
LABEL
));
actions
.
push
(
new
actionbar
.
Separator
());
actions
.
push
(
this
.
instantiationService
.
createInstance
(
debugactions
.
ToggleBreakpointsActivatedAction
,
debugactions
.
ToggleBreakpointsActivatedAction
.
ID
,
debugactions
.
ToggleBreakpointsActivatedAction
.
LABEL
));
actions
.
push
(
this
.
instantiationService
.
createInstance
(
debugactions
.
ToggleBreakpointsActivatedAction
,
debugactions
.
ToggleBreakpointsActivatedAction
.
ID
,
debugactions
.
ToggleBreakpointsActivatedAction
.
ACTIVATE_
LABEL
));
actions
.
push
(
new
actionbar
.
Separator
());
actions
.
push
(
this
.
instantiationService
.
createInstance
(
debugactions
.
EnableAllBreakpointsAction
,
debugactions
.
EnableAllBreakpointsAction
.
ID
,
debugactions
.
EnableAllBreakpointsAction
.
LABEL
));
...
...
src/vs/workbench/parts/debug/browser/debugViews.ts
浏览文件 @
bb22fc89
...
...
@@ -387,7 +387,7 @@ export class BreakpointsView extends viewlet.AdaptiveCollapsibleViewletView {
public
getActions
():
actions
.
IAction
[]
{
return
[
this
.
instantiationService
.
createInstance
(
debugactions
.
AddFunctionBreakpointAction
,
debugactions
.
AddFunctionBreakpointAction
.
ID
,
debugactions
.
AddFunctionBreakpointAction
.
LABEL
),
this
.
instantiationService
.
createInstance
(
debugactions
.
ToggleBreakpointsActivatedAction
,
debugactions
.
ToggleBreakpointsActivatedAction
.
ID
,
debugactions
.
ToggleBreakpointsActivatedAction
.
LABEL
),
this
.
instantiationService
.
createInstance
(
debugactions
.
ToggleBreakpointsActivatedAction
,
debugactions
.
ToggleBreakpointsActivatedAction
.
ID
,
debugactions
.
ToggleBreakpointsActivatedAction
.
ACTIVATE_
LABEL
),
this
.
instantiationService
.
createInstance
(
debugactions
.
RemoveAllBreakpointsAction
,
debugactions
.
RemoveAllBreakpointsAction
.
ID
,
debugactions
.
RemoveAllBreakpointsAction
.
LABEL
)
];
}
...
...
src/vs/workbench/parts/extensions/electron-browser/extensionsActions.ts
浏览文件 @
bb22fc89
...
...
@@ -104,9 +104,7 @@ export class CombinedInstallAction extends Action {
this
.
uninstallAction
=
instantiationService
.
createInstance
(
UninstallAction
,
extension
);
this
.
disposables
.
push
(
this
.
installAction
,
this
.
uninstallAction
);
this
.
disposables
.
push
(
this
.
installAction
.
addListener2
(
Action
.
ENABLED
,
()
=>
this
.
update
()));
this
.
disposables
.
push
(
this
.
installAction
.
addListener2
(
Action
.
LABEL
,
()
=>
this
.
update
()));
this
.
disposables
.
push
(
this
.
uninstallAction
.
addListener2
(
Action
.
ENABLED
,
()
=>
this
.
update
()));
this
.
installAction
.
onDidChange
(
this
.
update
,
this
,
this
.
disposables
);
this
.
update
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录