Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
07926e59
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,发现更多精彩内容 >>
提交
07926e59
编写于
6月 15, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shared context menu for title controls
上级
4c1020e7
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
81 addition
and
62 deletion
+81
-62
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
+6
-1
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
+6
-60
src/vs/workbench/browser/parts/editor/titleControl.ts
src/vs/workbench/browser/parts/editor/titleControl.ts
+69
-1
未找到文件。
src/vs/workbench/browser/parts/editor/noTabsTitleControl.ts
浏览文件 @
07926e59
...
...
@@ -16,6 +16,7 @@ import {ToolBar} from 'vs/base/browser/ui/toolbar/toolbar';
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -36,13 +37,14 @@ export class NoTabsTitleControl extends TitleControl {
constructor
(
@
IContextMenuService
contextMenuService
:
IContextMenuService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IMessageService
messageService
:
IMessageService
)
{
super
(
contextMenuService
,
instantiationService
,
editorService
,
editorGroupService
,
keybindingService
,
telemetryService
,
messageService
);
super
(
contextMenuService
,
instantiationService
,
configurationService
,
editorService
,
editorGroupService
,
keybindingService
,
telemetryService
,
messageService
);
this
.
currentPrimaryEditorActionIds
=
[];
this
.
currentSecondaryEditorActionIds
=
[];
...
...
@@ -98,6 +100,9 @@ export class NoTabsTitleControl extends TitleControl {
// Editor actions
this
.
editorActionsToolbar
=
this
.
doCreateToolbar
(
div
);
});
// Context Menu
this
.
titleContainer
.
on
(
DOM
.
EventType
.
CONTEXT_MENU
,
(
e
:
Event
)
=>
this
.
onContextMenu
({
group
:
this
.
context
,
editor
:
this
.
context
.
activeEditor
},
e
,
this
.
titleContainer
.
getHTMLElement
()));
}
private
onTitleDoubleClick
():
void
{
...
...
src/vs/workbench/browser/parts/editor/tabsTitleControl.ts
浏览文件 @
07926e59
...
...
@@ -6,7 +6,6 @@
'
use strict
'
;
import
'
vs/css!./media/tabstitle
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
nls
=
require
(
'
vs/nls
'
);
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
{
prepareActions
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
...
...
@@ -18,12 +17,11 @@ import {isMacintosh} from 'vs/base/common/platform';
import
{
Builder
,
$
}
from
'
vs/base/browser/builder
'
;
import
{
MIME_BINARY
}
from
'
vs/base/common/mime
'
;
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorGroup
,
IEditorIdentifier
,
asFileEditorInput
,
EditorOptions
,
IWorkbenchEditorConfiguration
}
from
'
vs/workbench/common/editor
'
;
import
{
IEditorGroup
,
IEditorIdentifier
,
asFileEditorInput
,
EditorOptions
}
from
'
vs/workbench/common/editor
'
;
import
{
ToolBar
}
from
'
vs/base/browser/ui/toolbar/toolbar
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
CommonKeybindings
as
Kb
}
from
'
vs/base/common/keyCodes
'
;
import
{
ActionBar
,
Separator
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
StandardMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
...
...
@@ -52,36 +50,22 @@ export class TabsTitleControl extends TitleControl {
private
currentPrimaryGroupActionIds
:
string
[];
private
currentSecondaryGroupActionIds
:
string
[];
private
previewEditors
:
boolean
;
constructor
(
@
IContextMenuService
contextMenuService
:
IContextMenuService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IWorkbenchEditorService
editorService
:
IWorkbenchEditorService
,
@
IEditorGroupService
editorGroupService
:
IEditorGroupService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
@
IMessageService
messageService
:
IMessageService
)
{
super
(
contextMenuService
,
instantiationService
,
editorService
,
editorGroupService
,
keybindingService
,
telemetryService
,
messageService
);
super
(
contextMenuService
,
instantiationService
,
configurationService
,
editorService
,
editorGroupService
,
keybindingService
,
telemetryService
,
messageService
);
this
.
currentPrimaryGroupActionIds
=
[];
this
.
currentSecondaryGroupActionIds
=
[];
this
.
tabDisposeables
=
[];
this
.
onConfigurationUpdated
(
configurationService
.
getConfiguration
<
IWorkbenchEditorConfiguration
>
());
this
.
registerListeners
();
}
private
registerListeners
():
void
{
this
.
toDispose
.
push
(
this
.
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onConfigurationUpdated
(
e
.
config
)));
}
private
onConfigurationUpdated
(
config
:
IWorkbenchEditorConfiguration
):
void
{
this
.
previewEditors
=
config
.
workbench
.
previewEditors
;
}
public
setContext
(
group
:
IEditorGroup
):
void
{
...
...
@@ -425,29 +409,7 @@ export class TabsTitleControl extends TitleControl {
}));
// Context menu
this
.
tabDisposeables
.
push
(
DOM
.
addDisposableListener
(
tab
,
DOM
.
EventType
.
CONTEXT_MENU
,
(
e
:
Event
)
=>
{
DOM
.
EventHelper
.
stop
(
e
);
let
anchor
:
HTMLElement
|
{
x
:
number
,
y
:
number
}
=
tab
;
if
(
e
instanceof
MouseEvent
)
{
const
event
=
new
StandardMouseEvent
(
e
);
anchor
=
{
x
:
event
.
posx
,
y
:
event
.
posy
};
}
this
.
contextMenuService
.
showContextMenu
({
getAnchor
:
()
=>
anchor
,
getActions
:
()
=>
TPromise
.
as
(
this
.
getTabActions
(
identifier
)),
getActionsContext
:
()
=>
identifier
,
getKeyBinding
:
(
action
)
=>
{
var
opts
=
this
.
keybindingService
.
lookupKeybindings
(
action
.
id
);
if
(
opts
.
length
>
0
)
{
return
opts
[
0
];
// only take the first one
}
return
null
;
}
});
}));
this
.
tabDisposeables
.
push
(
DOM
.
addDisposableListener
(
tab
,
DOM
.
EventType
.
CONTEXT_MENU
,
(
e
:
Event
)
=>
this
.
onContextMenu
(
identifier
,
e
,
tab
)));
// Drag start
this
.
tabDisposeables
.
push
(
DOM
.
addDisposableListener
(
tab
,
DOM
.
EventType
.
DRAG_START
,
(
e
:
DragEvent
)
=>
{
...
...
@@ -557,26 +519,10 @@ export class TabsTitleControl extends TitleControl {
return
!
isCopy
||
source
.
id
===
target
.
id
;
}
private
getTabActions
(
identifier
:
IEditorIdentifier
):
IAction
[]
{
protected
getContextMenuActions
(
identifier
:
IEditorIdentifier
):
IAction
[]
{
const
actions
=
super
.
getContextMenuActions
(
identifier
);
const
{
editor
,
group
}
=
identifier
;
// Enablement
this
.
closeOtherEditorsAction
.
enabled
=
group
.
count
>
1
;
this
.
pinEditorAction
.
enabled
=
!
group
.
isPinned
(
editor
);
this
.
closeRightEditorsAction
.
enabled
=
group
.
indexOf
(
editor
)
!==
group
.
count
-
1
;
// Actions: For all editors
const
actions
:
IAction
[]
=
[
this
.
closeEditorAction
,
this
.
closeOtherEditorsAction
,
this
.
closeRightEditorsAction
,
this
.
closeEditorsInGroupAction
];
if
(
this
.
previewEditors
)
{
actions
.
push
(
new
Separator
(),
this
.
pinEditorAction
);
}
// Actions: For active editor
if
(
group
.
isActive
(
editor
))
{
const
editorActions
=
this
.
getEditorActions
(
group
);
...
...
src/vs/workbench/browser/parts/editor/titleControl.ts
浏览文件 @
07926e59
...
...
@@ -13,18 +13,21 @@ import {IAction, Action} from 'vs/base/common/actions';
import
errors
=
require
(
'
vs/base/common/errors
'
);
import
{
Builder
}
from
'
vs/base/browser/builder
'
;
import
DOM
=
require
(
'
vs/base/browser/dom
'
);
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
BaseEditor
,
IEditorInputActionContext
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
IEditorStacksModel
,
IEditorGroup
,
EditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
IEditorStacksModel
,
IEditorGroup
,
IEditorIdentifier
,
EditorInput
,
IWorkbenchEditorConfiguration
}
from
'
vs/workbench/common/editor
'
;
import
{
EventType
as
BaseEventType
}
from
'
vs/base/common/events
'
;
import
{
IActionItem
,
ActionsOrientation
,
Separator
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
ToolBar
}
from
'
vs/base/browser/ui/toolbar/toolbar
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IMessageService
,
Severity
}
from
'
vs/platform/message/common/message
'
;
import
{
QuickOpenAction
}
from
'
vs/workbench/browser/quickopen
'
;
import
{
StandardMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
...
...
@@ -66,6 +69,9 @@ export abstract class TitleControl {
protected
splitEditorAction
:
SplitEditorAction
;
protected
showAllEditorsAction
:
ShowAllEditorsAction
;
private
previewEditors
:
boolean
;
private
showTabs
:
boolean
;
private
mapActionsToEditors
:
{
[
editorId
:
string
]:
IToolbarActions
;
};
private
scheduler
:
RunOnceScheduler
;
private
refreshScheduled
:
boolean
;
...
...
@@ -73,6 +79,7 @@ export abstract class TitleControl {
constructor
(
@
IContextMenuService
protected
contextMenuService
:
IContextMenuService
,
@
IInstantiationService
protected
instantiationService
:
IInstantiationService
,
@
IConfigurationService
protected
configurationService
:
IConfigurationService
,
@
IWorkbenchEditorService
protected
editorService
:
IWorkbenchEditorService
,
@
IEditorGroupService
protected
editorGroupService
:
IEditorGroupService
,
@
IKeybindingService
protected
keybindingService
:
IKeybindingService
,
...
...
@@ -83,10 +90,22 @@ export abstract class TitleControl {
this
.
stacks
=
editorGroupService
.
getStacksModel
();
this
.
mapActionsToEditors
=
Object
.
create
(
null
);
this
.
onConfigurationUpdated
(
configurationService
.
getConfiguration
<
IWorkbenchEditorConfiguration
>
());
this
.
scheduler
=
new
RunOnceScheduler
(()
=>
this
.
onSchedule
(),
0
);
this
.
toDispose
.
push
(
this
.
scheduler
);
this
.
initActions
();
this
.
registerListeners
();
}
private
registerListeners
():
void
{
this
.
toDispose
.
push
(
this
.
configurationService
.
onDidUpdateConfiguration
(
e
=>
this
.
onConfigurationUpdated
(
e
.
config
)));
}
private
onConfigurationUpdated
(
config
:
IWorkbenchEditorConfiguration
):
void
{
this
.
previewEditors
=
config
.
workbench
.
previewEditors
;
this
.
showTabs
=
config
.
workbench
.
showEditorTabs
;
}
private
updateActionEnablement
():
void
{
...
...
@@ -335,6 +354,55 @@ export abstract class TitleControl {
return
{
primary
,
secondary
};
}
protected
onContextMenu
(
identifier
:
IEditorIdentifier
,
e
:
Event
,
node
:
HTMLElement
):
void
{
let
anchor
:
HTMLElement
|
{
x
:
number
,
y
:
number
}
=
node
;
if
(
e
instanceof
MouseEvent
)
{
const
event
=
new
StandardMouseEvent
(
e
);
anchor
=
{
x
:
event
.
posx
,
y
:
event
.
posy
};
}
this
.
contextMenuService
.
showContextMenu
({
getAnchor
:
()
=>
anchor
,
getActions
:
()
=>
TPromise
.
as
(
this
.
getContextMenuActions
(
identifier
)),
getActionsContext
:
()
=>
identifier
,
getKeyBinding
:
(
action
)
=>
{
var
opts
=
this
.
keybindingService
.
lookupKeybindings
(
action
.
id
);
if
(
opts
.
length
>
0
)
{
return
opts
[
0
];
// only take the first one
}
return
null
;
}
});
}
protected
getContextMenuActions
(
identifier
:
IEditorIdentifier
):
IAction
[]
{
const
{
editor
,
group
}
=
identifier
;
// Enablement
this
.
closeOtherEditorsAction
.
enabled
=
group
.
count
>
1
;
this
.
pinEditorAction
.
enabled
=
!
group
.
isPinned
(
editor
);
this
.
closeRightEditorsAction
.
enabled
=
group
.
indexOf
(
editor
)
!==
group
.
count
-
1
;
// Actions: For all editors
const
actions
:
IAction
[]
=
[
this
.
closeEditorAction
,
this
.
closeOtherEditorsAction
];
if
(
this
.
showTabs
)
{
actions
.
push
(
this
.
closeRightEditorsAction
);
}
actions
.
push
(
this
.
closeEditorsInGroupAction
);
if
(
this
.
previewEditors
)
{
actions
.
push
(
new
Separator
(),
this
.
pinEditorAction
);
}
return
actions
;
}
public
dispose
():
void
{
dispose
(
this
.
toDispose
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录