Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
b329bf4c
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b329bf4c
编写于
3月 07, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - allow parts to register with the workbench and adopt for title bar
上级
a6e596d7
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
98 addition
and
109 deletion
+98
-109
src/vs/workbench/browser/legacyLayout.ts
src/vs/workbench/browser/legacyLayout.ts
+13
-18
src/vs/workbench/browser/part.ts
src/vs/workbench/browser/part.ts
+5
-3
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
...vs/workbench/browser/parts/activitybar/activitybarPart.ts
+3
-6
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+3
-9
src/vs/workbench/browser/parts/panel/panelPart.ts
src/vs/workbench/browser/parts/panel/panelPart.ts
+5
-6
src/vs/workbench/browser/parts/sidebar/sidebarPart.ts
src/vs/workbench/browser/parts/sidebar/sidebarPart.ts
+4
-5
src/vs/workbench/browser/parts/statusbar/statusbarPart.ts
src/vs/workbench/browser/parts/statusbar/statusbarPart.ts
+3
-6
src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
+11
-9
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+28
-34
src/vs/workbench/services/editor/test/browser/editorGroupsService.test.ts
.../services/editor/test/browser/editorGroupsService.test.ts
+1
-1
src/vs/workbench/services/editor/test/browser/editorService.test.ts
...kbench/services/editor/test/browser/editorService.test.ts
+6
-6
src/vs/workbench/services/layout/browser/layoutService.ts
src/vs/workbench/services/layout/browser/layoutService.ts
+12
-6
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+3
-0
src/vs/workbench/workbench.main.ts
src/vs/workbench/workbench.main.ts
+1
-0
未找到文件。
src/vs/workbench/browser/legacyLayout.ts
浏览文件 @
b329bf4c
...
...
@@ -14,13 +14,8 @@ import { isMacintosh } from 'vs/base/common/platform';
import
{
memoize
}
from
'
vs/base/common/decorators
'
;
import
{
Dimension
,
getClientArea
,
size
,
position
,
hide
,
show
}
from
'
vs/base/browser/dom
'
;
import
{
IEditorGroupsService
}
from
'
vs/workbench/services/editor/common/editorGroupsService
'
;
import
{
EditorPart
}
from
'
vs/workbench/browser/parts/editor/editorPart
'
;
import
{
TitlebarPart
}
from
'
vs/workbench/browser/parts/titlebar/titlebarPart
'
;
import
{
ActivitybarPart
}
from
'
vs/workbench/browser/parts/activitybar/activitybarPart
'
;
import
{
SidebarPart
}
from
'
vs/workbench/browser/parts/sidebar/sidebarPart
'
;
import
{
PanelPart
}
from
'
vs/workbench/browser/parts/panel/panelPart
'
;
import
{
StatusbarPart
}
from
'
vs/workbench/browser/parts/statusbar/statusbarPart
'
;
import
{
getZoomFactor
}
from
'
vs/base/browser/browser
'
;
import
{
Part
}
from
'
vs/workbench/browser/part
'
;
const
TITLE_BAR_HEIGHT
=
isMacintosh
?
22
:
30
;
const
STATUS_BAR_HEIGHT
=
22
;
...
...
@@ -67,12 +62,12 @@ export class WorkbenchLegacyLayout extends Disposable implements IVerticalSashLa
private
parent
:
HTMLElement
,
private
workbenchContainer
:
HTMLElement
,
private
parts
:
{
titlebar
:
Titlebar
Part
,
activitybar
:
Activitybar
Part
,
editor
:
Editor
Part
,
sidebar
:
Sidebar
Part
,
panel
:
Pa
nelPa
rt
,
statusbar
:
Statusbar
Part
titlebar
:
Part
,
activitybar
:
Part
,
editor
:
Part
,
sidebar
:
Part
,
panel
:
Part
,
statusbar
:
Part
},
@
IStorageService
private
readonly
storageService
:
IStorageService
,
@
IContextViewService
private
readonly
contextViewService
:
IContextViewService
,
...
...
@@ -106,7 +101,7 @@ export class WorkbenchLegacyLayout extends Disposable implements IVerticalSashLa
private
registerListeners
():
void
{
this
.
_register
(
this
.
themeService
.
onThemeChange
(
_
=>
this
.
layout
()));
this
.
_register
(
this
.
parts
.
editor
.
onDidSizeConstraintsChange
(()
=>
this
.
onDidEditorSizeConstraintsChange
()));
this
.
_register
(
(
this
.
parts
.
editor
as
any
)
.
onDidSizeConstraintsChange
(()
=>
this
.
onDidEditorSizeConstraintsChange
()));
this
.
registerSashListeners
();
}
...
...
@@ -631,11 +626,11 @@ export class WorkbenchLegacyLayout extends Disposable implements IVerticalSashLa
}
// Propagate to Part Layouts
this
.
parts
.
titlebar
.
layout
(
this
.
workbenchSize
.
width
,
this
.
titlebarHeight
);
this
.
parts
.
editor
.
layout
(
editorSize
.
width
,
editorSize
.
height
);
this
.
parts
.
sidebar
.
layout
(
sidebarSize
.
width
,
sidebarSize
.
height
);
this
.
parts
.
panel
.
layout
(
panelDimension
.
width
,
panelDimension
.
height
);
this
.
parts
.
activitybar
.
layout
(
activityBarSize
.
width
,
activityBarSize
.
height
);
this
.
parts
.
titlebar
.
layout
(
this
.
workbenchSize
.
width
,
this
.
titlebarHeight
,
-
1
);
this
.
parts
.
editor
.
layout
(
editorSize
.
width
,
editorSize
.
height
,
-
1
);
this
.
parts
.
sidebar
.
layout
(
sidebarSize
.
width
,
sidebarSize
.
height
,
-
1
);
this
.
parts
.
panel
.
layout
(
panelDimension
.
width
,
panelDimension
.
height
,
-
1
);
this
.
parts
.
activitybar
.
layout
(
activityBarSize
.
width
,
activityBarSize
.
height
,
-
1
);
// Propagate to Context View
this
.
contextViewService
.
layout
();
...
...
src/vs/workbench/browser/part.ts
浏览文件 @
b329bf4c
...
...
@@ -10,7 +10,7 @@ import { Dimension, size } from 'vs/base/browser/dom';
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IDimension
}
from
'
vs/platform/layout/browser/layoutService
'
;
import
{
ISerializableView
,
Orientation
}
from
'
vs/base/browser/ui/grid/grid
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
export
interface
IPartOptions
{
hasTitle
?:
boolean
;
...
...
@@ -109,9 +109,11 @@ export abstract class Part extends Component implements ISerializableView {
//#region ISerializableView
abstract
onDidChange
:
Event
<
IDimension
>
;
private
_onDidChange
=
this
.
_register
(
new
Emitter
<
{
width
:
number
;
height
:
number
;
}
>
());
get
onDidChange
():
Event
<
{
width
:
number
,
height
:
number
}
>
{
return
this
.
_onDidChange
.
event
;
}
element
:
HTMLElement
;
abstract
element
:
HTMLElement
;
abstract
minimumWidth
:
number
;
abstract
maximumWidth
:
number
;
abstract
minimumHeight
:
number
;
...
...
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
浏览文件 @
b329bf4c
...
...
@@ -6,7 +6,6 @@
import
'
vs/css!./media/activitybarpart
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
illegalArgument
}
from
'
vs/base/common/errors
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
ActionsOrientation
,
ActionBar
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
GlobalActivityExtensions
,
IGlobalActivityRegistry
}
from
'
vs/workbench/common/activity
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
...
...
@@ -49,15 +48,14 @@ export class ActivitybarPart extends Part {
private
static
readonly
ACTION_HEIGHT
=
50
;
private
static
readonly
PINNED_VIEWLETS
=
'
workbench.activity.pinnedViewlets
'
;
element
:
HTMLElement
;
//#region IView
readonly
minimumWidth
:
number
=
50
;
readonly
maximumWidth
:
number
=
50
;
readonly
minimumHeight
:
number
=
0
;
readonly
maximumHeight
:
number
=
Number
.
POSITIVE_INFINITY
;
private
_onDidChange
=
this
.
_register
(
new
Emitter
<
{
width
:
number
;
height
:
number
;
}
>
());
get
onDidChange
():
Event
<
{
width
:
number
,
height
:
number
}
>
{
return
this
.
_onDidChange
.
event
;
}
//#endregion
private
globalActionBar
:
ActionBar
;
private
globalActivityIdToActions
:
{
[
globalActivityId
:
string
]:
GlobalActivityAction
;
}
=
Object
.
create
(
null
);
...
...
@@ -67,7 +65,6 @@ export class ActivitybarPart extends Part {
private
compositeActions
:
{
[
compositeId
:
string
]:
{
activityAction
:
ViewletActivityAction
,
pinnedAction
:
ToggleCompositePinnedAction
}
}
=
Object
.
create
(
null
);
constructor
(
id
:
string
,
@
IViewletService
private
readonly
viewletService
:
IViewletService
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
@
IWorkbenchLayoutService
private
readonly
layoutService
:
IWorkbenchLayoutService
,
...
...
@@ -77,7 +74,7 @@ export class ActivitybarPart extends Part {
@
IViewsService
private
readonly
viewsService
:
IViewsService
,
@
IContextKeyService
private
readonly
contextKeyService
:
IContextKeyService
)
{
super
(
id
,
{
hasTitle
:
false
},
themeService
,
storageService
);
super
(
Parts
.
ACTIVITYBAR_PART
,
{
hasTitle
:
false
},
themeService
,
storageService
);
this
.
cachedViewlets
=
this
.
getCachedViewlets
();
for
(
const
cachedViewlet
of
this
.
cachedViewlets
)
{
...
...
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
b329bf4c
...
...
@@ -86,13 +86,6 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
private
static
readonly
EDITOR_PART_UI_STATE_STORAGE_KEY
=
'
editorpart.state
'
;
private
static
readonly
EDITOR_PART_CENTERED_VIEW_STORAGE_KEY
=
'
editorpart.centeredview
'
;
element
:
HTMLElement
;
private
_onDidChange
=
this
.
_register
(
new
Emitter
<
{
width
:
number
;
height
:
number
;
}
>
());
get
onDidChange
():
Event
<
{
width
:
number
,
height
:
number
}
>
{
return
this
.
_onDidChange
.
event
;
}
readonly
priority
:
LayoutPriority
=
LayoutPriority
.
High
;
//#region Events
private
readonly
_onDidLayout
:
Emitter
<
Dimension
>
=
this
.
_register
(
new
Emitter
<
Dimension
>
());
...
...
@@ -143,14 +136,13 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
private
whenRestoredResolve
:
()
=>
void
;
constructor
(
id
:
string
,
private
restorePreviousState
:
boolean
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
@
IThemeService
themeService
:
IThemeService
,
@
IConfigurationService
private
readonly
configurationService
:
IConfigurationService
,
@
IStorageService
storageService
:
IStorageService
)
{
super
(
id
,
{
hasTitle
:
false
},
themeService
,
storageService
);
super
(
Parts
.
EDITOR_PART
,
{
hasTitle
:
false
},
themeService
,
storageService
);
this
.
gridWidgetView
=
new
GridWidgetView
<
IEditorGroupView
>
();
...
...
@@ -753,6 +745,8 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
//#region Part
readonly
priority
:
LayoutPriority
=
LayoutPriority
.
High
;
get
minimumWidth
():
number
{
return
this
.
centeredLayoutWidget
.
minimumWidth
;
}
get
maximumWidth
():
number
{
return
this
.
centeredLayoutWidget
.
maximumWidth
;
}
get
minimumHeight
():
number
{
return
this
.
centeredLayoutWidget
.
minimumHeight
;
}
...
...
src/vs/workbench/browser/parts/panel/panelPart.ts
浏览文件 @
b329bf4c
...
...
@@ -5,7 +5,7 @@
import
'
vs/css!./media/panelpart
'
;
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
ActionsOrientation
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
IPanel
,
ActivePanelContext
,
PanelFocusContext
}
from
'
vs/workbench/common/panel
'
;
...
...
@@ -50,17 +50,17 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
_serviceBrand
:
ServiceIdentifier
<
any
>
;
element
:
HTMLElement
;
//#region IView
readonly
minimumWidth
:
number
=
300
;
readonly
maximumWidth
:
number
=
Number
.
POSITIVE_INFINITY
;
readonly
minimumHeight
:
number
=
77
;
readonly
maximumHeight
:
number
=
Number
.
POSITIVE_INFINITY
;
readonly
snapSize
:
number
=
50
;
readonly
priority
:
LayoutPriority
=
LayoutPriority
.
Low
;
private
_onDidChange
=
this
.
_register
(
new
Emitter
<
{
width
:
number
;
height
:
number
;
}
>
());
get
onDidChange
():
Event
<
{
width
:
number
,
height
:
number
}
>
{
return
this
.
_onDidChange
.
event
;
}
//#endregion
get
onDidPanelOpen
():
Event
<
{
panel
:
IPanel
,
focus
:
boolean
}
>
{
return
Event
.
map
(
this
.
onDidCompositeOpen
.
event
,
compositeOpen
=>
({
panel
:
compositeOpen
.
composite
,
focus
:
compositeOpen
.
focus
}));
}
get
onDidPanelClose
():
Event
<
IPanel
>
{
return
this
.
onDidCompositeClose
.
event
;
}
...
...
@@ -75,7 +75,6 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
private
dimension
:
Dimension
;
constructor
(
id
:
string
,
@
INotificationService
notificationService
:
INotificationService
,
@
IStorageService
storageService
:
IStorageService
,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
...
...
@@ -102,7 +101,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
'
panel
'
,
'
panel
'
,
undefined
,
id
,
Parts
.
PANEL_PART
,
{
hasTitle
:
true
}
);
...
...
src/vs/workbench/browser/parts/sidebar/sidebarPart.ts
浏览文件 @
b329bf4c
...
...
@@ -38,17 +38,17 @@ export class SidebarPart extends CompositePart<Viewlet> implements IViewletServi
static
readonly
activeViewletSettingsKey
=
'
workbench.sidebar.activeviewletid
'
;
element
:
HTMLElement
;
//#region IView
readonly
minimumWidth
:
number
=
170
;
readonly
maximumWidth
:
number
=
Number
.
POSITIVE_INFINITY
;
readonly
minimumHeight
:
number
=
0
;
readonly
maximumHeight
:
number
=
Number
.
POSITIVE_INFINITY
;
readonly
snapSize
:
number
=
50
;
readonly
priority
:
LayoutPriority
=
LayoutPriority
.
Low
;
private
_onDidChange
=
this
.
_register
(
new
Emitter
<
{
width
:
number
;
height
:
number
;
}
>
());
get
onDidChange
():
Event
<
{
width
:
number
,
height
:
number
}
>
{
return
this
.
_onDidChange
.
event
;
}
//#endregion
get
onDidViewletRegister
():
Event
<
ViewletDescriptor
>
{
return
<
Event
<
ViewletDescriptor
>>
this
.
viewletRegistry
.
onDidRegister
;
}
...
...
@@ -64,7 +64,6 @@ export class SidebarPart extends CompositePart<Viewlet> implements IViewletServi
private
blockOpeningViewlet
:
boolean
;
constructor
(
id
:
string
,
@
INotificationService
notificationService
:
INotificationService
,
@
IStorageService
storageService
:
IStorageService
,
@
ITelemetryService
telemetryService
:
ITelemetryService
,
...
...
@@ -91,7 +90,7 @@ export class SidebarPart extends CompositePart<Viewlet> implements IViewletServi
'
sideBar
'
,
'
viewlet
'
,
SIDE_BAR_TITLE_FOREGROUND
,
id
,
Parts
.
SIDEBAR_PART
,
{
hasTitle
:
true
,
borderWidth
:
()
=>
(
this
.
getColor
(
SIDE_BAR_BORDER
)
||
this
.
getColor
(
contrastBorder
))
?
1
:
0
}
);
...
...
src/vs/workbench/browser/parts/statusbar/statusbarPart.ts
浏览文件 @
b329bf4c
...
...
@@ -27,7 +27,6 @@ import { Color } from 'vs/base/common/color';
import
{
addClass
,
EventHelper
,
createStyleSheet
,
addDisposableListener
}
from
'
vs/base/browser/dom
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Parts
}
from
'
vs/workbench/services/layout/browser/layoutService
'
;
export
class
StatusbarPart
extends
Part
implements
IStatusbarService
{
...
...
@@ -37,27 +36,25 @@ export class StatusbarPart extends Part implements IStatusbarService {
private
static
readonly
PRIORITY_PROP
=
'
statusbar-entry-priority
'
;
private
static
readonly
ALIGNMENT_PROP
=
'
statusbar-entry-alignment
'
;
element
:
HTMLElement
;
//#region IView
readonly
minimumWidth
:
number
=
0
;
readonly
maximumWidth
:
number
=
Number
.
POSITIVE_INFINITY
;
readonly
minimumHeight
:
number
=
22
;
readonly
maximumHeight
:
number
=
22
;
private
_onDidChange
=
this
.
_register
(
new
Emitter
<
{
width
:
number
;
height
:
number
;
}
>
());
get
onDidChange
():
Event
<
{
width
:
number
,
height
:
number
}
>
{
return
this
.
_onDidChange
.
event
;
}
//#endregion
private
statusMsgDispose
:
IDisposable
;
private
styleElement
:
HTMLStyleElement
;
constructor
(
id
:
string
,
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
@
IThemeService
themeService
:
IThemeService
,
@
IWorkspaceContextService
private
readonly
contextService
:
IWorkspaceContextService
,
@
IStorageService
storageService
:
IStorageService
)
{
super
(
id
,
{
hasTitle
:
false
},
themeService
,
storageService
);
super
(
Parts
.
STATUSBAR_PART
,
{
hasTitle
:
false
},
themeService
,
storageService
);
this
.
registerListeners
();
}
...
...
src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
浏览文件 @
b329bf4c
...
...
@@ -33,8 +33,9 @@ import { template, getBaseLabel } from 'vs/base/common/labels';
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
Parts
}
from
'
vs/workbench/services/layout/browser/layoutService
'
;
import
{
Parts
,
IWorkbenchLayoutService
}
from
'
vs/workbench/services/layout/browser/layoutService
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
export
class
TitlebarPart
extends
Part
implements
ITitleService
{
...
...
@@ -44,16 +45,13 @@ export class TitlebarPart extends Part implements ITitleService {
private
static
readonly
TITLE_DIRTY
=
'
\
u25cf
'
;
private
static
readonly
TITLE_SEPARATOR
=
isMacintosh
?
'
—
'
:
'
-
'
;
// macOS uses special - separator
element
:
HTMLElement
;
//#region IView
readonly
minimumWidth
:
number
=
0
;
readonly
maximumWidth
:
number
=
Number
.
POSITIVE_INFINITY
;
get
minimumHeight
():
number
{
return
isMacintosh
?
22
/
getZoomFactor
()
:
(
30
/
(
this
.
configurationService
.
getValue
<
MenuBarVisibility
>
(
'
window.menuBarVisibility
'
)
===
'
hidden
'
?
getZoomFactor
()
:
1
));
}
get
maximumHeight
():
number
{
return
isMacintosh
?
22
/
getZoomFactor
()
:
(
30
/
(
this
.
configurationService
.
getValue
<
MenuBarVisibility
>
(
'
window.menuBarVisibility
'
)
===
'
hidden
'
?
getZoomFactor
()
:
1
));
}
private
_onDidChange
=
this
.
_register
(
new
Emitter
<
{
width
:
number
,
height
:
number
}
>
());
get
onDidChange
():
Event
<
{
width
:
number
,
height
:
number
}
>
{
return
this
.
_onDidChange
.
event
;
}
//#endregion
private
_onMenubarVisibilityChange
=
this
.
_register
(
new
Emitter
<
boolean
>
());
get
onMenubarVisibilityChange
():
Event
<
boolean
>
{
return
this
.
_onMenubarVisibilityChange
.
event
;
}
...
...
@@ -80,7 +78,6 @@ export class TitlebarPart extends Part implements ITitleService {
private
titleUpdater
:
RunOnceScheduler
=
this
.
_register
(
new
RunOnceScheduler
(()
=>
this
.
doUpdateTitle
(),
0
));
constructor
(
id
:
string
,
@
IContextMenuService
private
readonly
contextMenuService
:
IContextMenuService
,
@
IWindowService
private
readonly
windowService
:
IWindowService
,
@
IConfigurationService
private
readonly
configurationService
:
IConfigurationService
,
...
...
@@ -91,13 +88,16 @@ export class TitlebarPart extends Part implements ITitleService {
@
IInstantiationService
private
readonly
instantiationService
:
IInstantiationService
,
@
IThemeService
themeService
:
IThemeService
,
@
ILabelService
private
readonly
labelService
:
ILabelService
,
@
IStorageService
storageService
:
IStorageService
@
IStorageService
storageService
:
IStorageService
,
@
IWorkbenchLayoutService
layoutService
:
IWorkbenchLayoutService
)
{
super
(
id
,
{
hasTitle
:
false
},
themeService
,
storageService
);
super
(
Parts
.
TITLEBAR_PART
,
{
hasTitle
:
false
},
themeService
,
storageService
);
this
.
properties
=
{
isPure
:
true
,
isAdmin
:
false
};
this
.
activeEditorListeners
=
[];
layoutService
.
registerPart
(
this
);
this
.
registerListeners
();
}
...
...
@@ -630,3 +630,5 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
`
);
}
});
registerSingleton
(
ITitleService
,
TitlebarPart
);
\ No newline at end of file
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
b329bf4c
...
...
@@ -24,7 +24,6 @@ import { ActivitybarPart } from 'vs/workbench/browser/parts/activitybar/activity
import
{
SidebarPart
}
from
'
vs/workbench/browser/parts/sidebar/sidebarPart
'
;
import
{
PanelPart
}
from
'
vs/workbench/browser/parts/panel/panelPart
'
;
import
{
StatusbarPart
}
from
'
vs/workbench/browser/parts/statusbar/statusbarPart
'
;
import
{
TitlebarPart
}
from
'
vs/workbench/browser/parts/titlebar/titlebarPart
'
;
import
{
EditorPart
}
from
'
vs/workbench/browser/parts/editor/editorPart
'
;
import
{
IActionBarRegistry
,
Extensions
as
ActionBarExtensions
}
from
'
vs/workbench/browser/actions
'
;
import
{
PanelRegistry
,
Extensions
as
PanelExtensions
}
from
'
vs/workbench/browser/panel
'
;
...
...
@@ -43,7 +42,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IPanelService
}
from
'
vs/workbench/services/panel/common/panelService
'
;
import
{
ITitleService
}
from
'
vs/workbench/services/title/common/titleService
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
,
ServicesAccessor
,
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
LifecyclePhase
,
StartupKind
,
ILifecycleService
,
WillShutdownEvent
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
...
...
@@ -97,6 +96,7 @@ import { IProductService } from 'vs/platform/product/common/product';
import
{
IAccessibilityService
}
from
'
vs/platform/accessibility/common/accessibility
'
;
import
{
WorkbenchContextKeysHandler
}
from
'
vs/workbench/browser/contextkeys
'
;
import
{
IDimension
}
from
'
vs/platform/layout/browser/layoutService
'
;
import
{
Part
}
from
'
vs/workbench/browser/part
'
;
// import@node
import
{
getDelayedChannel
}
from
'
vs/base/parts/ipc/node/ipc
'
;
...
...
@@ -128,15 +128,6 @@ import { RemoteAgentService } from 'vs/workbench/services/remote/electron-browse
import
{
ExtensionService
}
from
'
vs/workbench/services/extensions/electron-browser/extensionService
'
;
import
{
RequestService
}
from
'
vs/platform/request/electron-browser/requestService
'
;
enum
Identifiers
{
TITLEBAR_PART
=
'
workbench.parts.titlebar
'
,
ACTIVITYBAR_PART
=
'
workbench.parts.activitybar
'
,
SIDEBAR_PART
=
'
workbench.parts.sidebar
'
,
PANEL_PART
=
'
workbench.parts.panel
'
,
EDITOR_PART
=
'
workbench.parts.editor
'
,
STATUSBAR_PART
=
'
workbench.parts.statusbar
'
}
enum
Settings
{
MENUBAR_VISIBLE
=
'
window.menuBarVisibility
'
,
ACTIVITYBAR_VISIBLE
=
'
workbench.activityBar.visible
'
,
...
...
@@ -163,7 +154,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
//#region workbench
_serviceBrand
:
any
;
_serviceBrand
:
ServiceIdentifier
<
any
>
;
private
readonly
_onShutdown
=
this
.
_register
(
new
Emitter
<
void
>
());
get
onShutdown
():
Event
<
void
>
{
return
this
.
_onShutdown
.
event
;
}
...
...
@@ -190,7 +181,8 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
private
logService
:
ILogService
;
private
windowsService
:
IWindowsService
;
private
titlebarPart
:
TitlebarPart
;
private
parts
:
Map
<
string
,
Part
>
=
new
Map
<
string
,
Part
>
();
private
activitybarPart
:
ActivitybarPart
;
private
sidebarPart
:
SidebarPart
;
private
panelPart
:
PanelPart
;
...
...
@@ -439,7 +431,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
serviceCollection
.
set
(
ILocalizationsService
,
new
SyncDescriptor
(
LocalizationsChannelClient
,
[
localizationsChannel
]));
// Status bar
this
.
statusbarPart
=
this
.
instantiationService
.
createInstance
(
StatusbarPart
,
Identifiers
.
STATUSBAR_PART
);
this
.
statusbarPart
=
this
.
instantiationService
.
createInstance
(
StatusbarPart
);
serviceCollection
.
set
(
IStatusbarService
,
this
.
statusbarPart
);
// TODO@Ben use SyncDescriptor
// Context Keys
...
...
@@ -459,25 +451,25 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
}
// Viewlet service (sidebar part)
this
.
sidebarPart
=
this
.
instantiationService
.
createInstance
(
SidebarPart
,
Identifiers
.
SIDEBAR_PART
);
this
.
sidebarPart
=
this
.
instantiationService
.
createInstance
(
SidebarPart
);
serviceCollection
.
set
(
IViewletService
,
this
.
sidebarPart
);
// TODO@Ben use SyncDescriptor
// Panel service (panel part)
this
.
panelPart
=
this
.
instantiationService
.
createInstance
(
PanelPart
,
Identifiers
.
PANEL_PART
);
this
.
panelPart
=
this
.
instantiationService
.
createInstance
(
PanelPart
);
serviceCollection
.
set
(
IPanelService
,
this
.
panelPart
);
// TODO@Ben use SyncDescriptor
// Views service
serviceCollection
.
set
(
IViewsService
,
new
SyncDescriptor
(
ViewsService
));
// Activity service (activitybar part)
this
.
activitybarPart
=
this
.
instantiationService
.
createInstance
(
ActivitybarPart
,
Identifiers
.
ACTIVITYBAR_PART
);
this
.
activitybarPart
=
this
.
instantiationService
.
createInstance
(
ActivitybarPart
);
serviceCollection
.
set
(
IActivityService
,
new
SyncDescriptor
(
ActivityService
,
[
this
.
activitybarPart
,
this
.
panelPart
],
true
));
// File Service
serviceCollection
.
set
(
IFileService
,
new
SyncDescriptor
(
RemoteFileService
));
// Editor and Group services
this
.
editorPart
=
this
.
instantiationService
.
createInstance
(
EditorPart
,
Identifiers
.
EDITOR_PART
,
!
this
.
hasInitialFilesToOpen
());
this
.
editorPart
=
this
.
instantiationService
.
createInstance
(
EditorPart
,
!
this
.
hasInitialFilesToOpen
());
this
.
editorGroupService
=
this
.
editorPart
;
serviceCollection
.
set
(
IEditorGroupsService
,
this
.
editorPart
);
// TODO@Ben use SyncDescriptor
this
.
editorService
=
this
.
instantiationService
.
createInstance
(
EditorService
);
...
...
@@ -486,10 +478,6 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
// Accessibility
serviceCollection
.
set
(
IAccessibilityService
,
new
SyncDescriptor
(
AccessibilityService
,
undefined
,
true
));
// Title bar
this
.
titlebarPart
=
this
.
instantiationService
.
createInstance
(
TitlebarPart
,
Identifiers
.
TITLEBAR_PART
);
serviceCollection
.
set
(
ITitleService
,
this
.
titlebarPart
);
// TODO@Ben use SyncDescriptor
// Contributed services
const
contributedServices
=
getServices
();
for
(
let
contributedService
of
contributedServices
)
{
...
...
@@ -616,37 +604,37 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
}
private
createTitlebarPart
():
void
{
const
titlebarContainer
=
this
.
createPart
(
Identifier
s
.
TITLEBAR_PART
,
'
contentinfo
'
,
'
titlebar
'
);
const
titlebarContainer
=
this
.
createPart
(
Part
s
.
TITLEBAR_PART
,
'
contentinfo
'
,
'
titlebar
'
);
this
.
titlebarPart
.
create
(
titlebarContainer
);
this
.
parts
.
get
(
Parts
.
TITLEBAR_PART
)
.
create
(
titlebarContainer
);
}
private
createActivityBarPart
():
void
{
const
activitybarPartContainer
=
this
.
createPart
(
Identifier
s
.
ACTIVITYBAR_PART
,
'
navigation
'
,
'
activitybar
'
,
this
.
state
.
sideBar
.
position
===
Position
.
LEFT
?
'
left
'
:
'
right
'
);
const
activitybarPartContainer
=
this
.
createPart
(
Part
s
.
ACTIVITYBAR_PART
,
'
navigation
'
,
'
activitybar
'
,
this
.
state
.
sideBar
.
position
===
Position
.
LEFT
?
'
left
'
:
'
right
'
);
this
.
activitybarPart
.
create
(
activitybarPartContainer
);
}
private
createSidebarPart
():
void
{
const
sidebarPartContainer
=
this
.
createPart
(
Identifier
s
.
SIDEBAR_PART
,
'
complementary
'
,
'
sidebar
'
,
this
.
state
.
sideBar
.
position
===
Position
.
LEFT
?
'
left
'
:
'
right
'
);
const
sidebarPartContainer
=
this
.
createPart
(
Part
s
.
SIDEBAR_PART
,
'
complementary
'
,
'
sidebar
'
,
this
.
state
.
sideBar
.
position
===
Position
.
LEFT
?
'
left
'
:
'
right
'
);
this
.
sidebarPart
.
create
(
sidebarPartContainer
);
}
private
createPanelPart
():
void
{
const
panelPartContainer
=
this
.
createPart
(
Identifier
s
.
PANEL_PART
,
'
complementary
'
,
'
panel
'
,
this
.
state
.
panel
.
position
===
Position
.
BOTTOM
?
'
bottom
'
:
'
right
'
);
const
panelPartContainer
=
this
.
createPart
(
Part
s
.
PANEL_PART
,
'
complementary
'
,
'
panel
'
,
this
.
state
.
panel
.
position
===
Position
.
BOTTOM
?
'
bottom
'
:
'
right
'
);
this
.
panelPart
.
create
(
panelPartContainer
);
}
private
createEditorPart
():
void
{
const
editorContainer
=
this
.
createPart
(
Identifier
s
.
EDITOR_PART
,
'
main
'
,
'
editor
'
);
const
editorContainer
=
this
.
createPart
(
Part
s
.
EDITOR_PART
,
'
main
'
,
'
editor
'
);
this
.
editorPart
.
create
(
editorContainer
);
}
private
createStatusbarPart
():
void
{
const
statusbarContainer
=
this
.
createPart
(
Identifier
s
.
STATUSBAR_PART
,
'
contentinfo
'
,
'
statusbar
'
);
const
statusbarContainer
=
this
.
createPart
(
Part
s
.
STATUSBAR_PART
,
'
contentinfo
'
,
'
statusbar
'
);
this
.
statusbarPart
.
create
(
statusbarContainer
);
}
...
...
@@ -793,7 +781,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
//#endregion
//#region I
Par
tService
//#region I
Layou
tService
private
readonly
_onTitleBarVisibilityChange
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
get
onTitleBarVisibilityChange
():
Event
<
void
>
{
return
this
.
_onTitleBarVisibilityChange
.
event
;
}
...
...
@@ -867,6 +855,10 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
}
};
registerPart
(
part
:
Part
):
void
{
this
.
parts
.
set
(
part
.
getId
(),
part
);
}
private
registerLayoutListeners
(
accessor
:
ServicesAccessor
):
void
{
const
storageService
=
accessor
.
get
(
IStorageService
);
const
editorService
=
accessor
.
get
(
IEditorService
);
...
...
@@ -1180,7 +1172,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
getContainer
(
part
:
Parts
):
HTMLElement
|
null
{
switch
(
part
)
{
case
Parts
.
TITLEBAR_PART
:
return
this
.
titlebarPart
.
getContainer
();
return
this
.
parts
.
get
(
Parts
.
TITLEBAR_PART
)
.
getContainer
();
case
Parts
.
ACTIVITYBAR_PART
:
return
this
.
activitybarPart
.
getContainer
();
case
Parts
.
SIDEBAR_PART
:
...
...
@@ -1231,7 +1223,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
let
offset
=
0
;
if
(
this
.
isVisible
(
Parts
.
TITLEBAR_PART
))
{
if
(
this
.
workbenchGrid
instanceof
Grid
)
{
offset
=
this
.
titlebarPart
.
maximumHeight
;
offset
=
this
.
parts
.
get
(
Parts
.
TITLEBAR_PART
)
.
maximumHeight
;
}
else
{
offset
=
this
.
workbenchGrid
.
partLayoutInfo
.
titlebar
.
height
;
...
...
@@ -1358,10 +1350,12 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
}
private
createWorkbenchLayout
():
void
{
const
titlePart
=
this
.
parts
.
get
(
Parts
.
TITLEBAR_PART
);
if
(
this
.
configurationService
.
getValue
(
'
workbench.useExperimentalGridLayout
'
))
{
// Create view wrappers for all parts
this
.
titleBarPartView
=
new
View
(
t
his
.
titlebar
Part
);
this
.
titleBarPartView
=
new
View
(
t
itle
Part
);
this
.
sideBarPartView
=
new
View
(
this
.
sidebarPart
);
this
.
activityBarPartView
=
new
View
(
this
.
activitybarPart
);
this
.
editorPartView
=
new
View
(
this
.
editorPart
);
...
...
@@ -1377,7 +1371,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
this
.
container
,
this
.
workbench
,
{
titlebar
:
t
his
.
titlebar
Part
,
titlebar
:
t
itle
Part
,
activitybar
:
this
.
activitybarPart
,
editor
:
this
.
editorPart
,
sidebar
:
this
.
sidebarPart
,
...
...
src/vs/workbench/services/editor/test/browser/editorGroupsService.test.ts
浏览文件 @
b329bf4c
...
...
@@ -87,7 +87,7 @@ suite('Editor groups service', () => {
function
createPart
():
EditorPart
{
const
instantiationService
=
workbenchInstantiationService
();
const
part
=
instantiationService
.
createInstance
(
EditorPart
,
'
id
'
,
false
);
const
part
=
instantiationService
.
createInstance
(
EditorPart
,
false
);
part
.
create
(
document
.
createElement
(
'
div
'
));
part
.
layout
(
400
,
300
);
...
...
src/vs/workbench/services/editor/test/browser/editorService.test.ts
浏览文件 @
b329bf4c
...
...
@@ -76,7 +76,7 @@ suite('Editor service', () => {
test
(
'
basics
'
,
function
()
{
const
partInstantiator
=
workbenchInstantiationService
();
const
part
=
partInstantiator
.
createInstance
(
EditorPart
,
'
id
'
,
false
);
const
part
=
partInstantiator
.
createInstance
(
EditorPart
,
false
);
part
.
create
(
document
.
createElement
(
'
div
'
));
part
.
layout
(
400
,
300
);
...
...
@@ -149,7 +149,7 @@ suite('Editor service', () => {
test
(
'
openEditors() / replaceEditors()
'
,
function
()
{
const
partInstantiator
=
workbenchInstantiationService
();
const
part
=
partInstantiator
.
createInstance
(
EditorPart
,
'
id
'
,
false
);
const
part
=
partInstantiator
.
createInstance
(
EditorPart
,
false
);
part
.
create
(
document
.
createElement
(
'
div
'
));
part
.
layout
(
400
,
300
);
...
...
@@ -290,7 +290,7 @@ suite('Editor service', () => {
test
(
'
close editor does not dispose when editor opened in other group
'
,
function
()
{
const
partInstantiator
=
workbenchInstantiationService
();
const
part
=
partInstantiator
.
createInstance
(
EditorPart
,
'
id
'
,
false
);
const
part
=
partInstantiator
.
createInstance
(
EditorPart
,
false
);
part
.
create
(
document
.
createElement
(
'
div
'
));
part
.
layout
(
400
,
300
);
...
...
@@ -329,7 +329,7 @@ suite('Editor service', () => {
test
(
'
open to the side
'
,
function
()
{
const
partInstantiator
=
workbenchInstantiationService
();
const
part
=
partInstantiator
.
createInstance
(
EditorPart
,
'
id
'
,
false
);
const
part
=
partInstantiator
.
createInstance
(
EditorPart
,
false
);
part
.
create
(
document
.
createElement
(
'
div
'
));
part
.
layout
(
400
,
300
);
...
...
@@ -363,7 +363,7 @@ suite('Editor service', () => {
test
(
'
active editor change / visible editor change events
'
,
async
function
()
{
const
partInstantiator
=
workbenchInstantiationService
();
const
part
=
partInstantiator
.
createInstance
(
EditorPart
,
'
id
'
,
false
);
const
part
=
partInstantiator
.
createInstance
(
EditorPart
,
false
);
part
.
create
(
document
.
createElement
(
'
div
'
));
part
.
layout
(
400
,
300
);
...
...
@@ -573,7 +573,7 @@ suite('Editor service', () => {
test
(
'
openEditor returns NULL when opening fails or is inactive
'
,
async
function
()
{
const
partInstantiator
=
workbenchInstantiationService
();
const
part
=
partInstantiator
.
createInstance
(
EditorPart
,
'
id
'
,
false
);
const
part
=
partInstantiator
.
createInstance
(
EditorPart
,
false
);
part
.
create
(
document
.
createElement
(
'
div
'
));
part
.
layout
(
400
,
300
);
...
...
src/vs/workbench/services/layout/browser/layoutService.ts
浏览文件 @
b329bf4c
...
...
@@ -7,16 +7,17 @@ import { ServiceIdentifier, createDecorator } from 'vs/platform/instantiation/co
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
MenuBarVisibility
}
from
'
vs/platform/windows/common/windows
'
;
import
{
ILayoutService
}
from
'
vs/platform/layout/browser/layoutService
'
;
import
{
Part
}
from
'
vs/workbench/browser/part
'
;
export
const
IWorkbenchLayoutService
=
createDecorator
<
IWorkbenchLayoutService
>
(
'
layoutService
'
);
export
const
enum
Parts
{
ACTIVITYBAR_PART
,
SIDEBAR_PART
,
PANEL_PART
,
EDITOR_PART
,
STATUSBAR_PART
,
TITLEBAR_PART
TITLEBAR_PART
=
'
workbench.parts.titlebar
'
,
ACTIVITYBAR_PART
=
'
workbench.parts.activitybar
'
,
SIDEBAR_PART
=
'
workbench.parts.sidebar
'
,
PANEL_PART
=
'
workbench.parts.panel
'
,
EDITOR_PART
=
'
workbench.parts.editor
'
,
STATUSBAR_PART
=
'
workbench.parts.statusbar
'
}
export
const
enum
Position
{
...
...
@@ -145,4 +146,9 @@ export interface IWorkbenchLayoutService extends ILayoutService {
* Resizes currently focused part on main access
*/
resizePart
(
part
:
Parts
,
sizeChange
:
number
):
void
;
/**
* Register a part to participate in the layout.
*/
registerPart
(
part
:
Part
):
void
;
}
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
b329bf4c
...
...
@@ -78,6 +78,7 @@ import { IStorageService, InMemoryStorageService } from 'vs/platform/storage/com
import
{
isLinux
,
isMacintosh
}
from
'
vs/base/common/platform
'
;
import
{
LabelService
}
from
'
vs/workbench/services/label/common/labelService
'
;
import
{
IDimension
}
from
'
vs/platform/layout/browser/layoutService
'
;
import
{
Part
}
from
'
vs/workbench/browser/part
'
;
export
function
createFileInput
(
instantiationService
:
IInstantiationService
,
resource
:
URI
):
FileEditorInput
{
return
instantiationService
.
createInstance
(
FileEditorInput
,
resource
,
undefined
);
...
...
@@ -542,6 +543,8 @@ export class TestLayoutService implements IWorkbenchLayoutService {
public
resizePart
(
_part
:
Parts
,
_sizeChange
:
number
):
void
{
}
public
registerPart
(
part
:
Part
):
void
{
}
}
export
class
TestStorageService
extends
InMemoryStorageService
{
}
...
...
src/vs/workbench/workbench.main.ts
浏览文件 @
b329bf4c
...
...
@@ -78,6 +78,7 @@ import 'vs/workbench/services/backup/node/backupFileService';
import
'
vs/workbench/services/history/browser/history
'
;
import
'
vs/workbench/browser/parts/quickinput/quickInput
'
;
import
'
vs/workbench/browser/parts/quickopen/quickOpenController
'
;
import
'
vs/workbench/browser/parts/titlebar/titlebarPart
'
;
registerSingleton
(
IMenuService
,
MenuService
,
true
);
registerSingleton
(
IListService
,
ListService
,
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录