Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
116a3de4
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,发现更多精彩内容 >>
提交
116a3de4
编写于
4月 20, 2020
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Unify into single ViewContainerModel
上级
9275e7ed
变更
15
展开全部
隐藏空白更改
内联
并排
Showing
15 changed file
with
945 addition
and
1005 deletion
+945
-1005
src/vs/workbench/browser/actions/layoutActions.ts
src/vs/workbench/browser/actions/layoutActions.ts
+3
-3
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
...vs/workbench/browser/parts/activitybar/activitybarPart.ts
+13
-18
src/vs/workbench/browser/parts/compositeBar.ts
src/vs/workbench/browser/parts/compositeBar.ts
+2
-2
src/vs/workbench/browser/parts/panel/panelPart.ts
src/vs/workbench/browser/parts/panel/panelPart.ts
+20
-19
src/vs/workbench/browser/parts/views/viewPaneContainer.ts
src/vs/workbench/browser/parts/views/viewPaneContainer.ts
+27
-27
src/vs/workbench/browser/parts/views/views.ts
src/vs/workbench/browser/parts/views/views.ts
+5
-5
src/vs/workbench/browser/parts/views/viewsViewlet.ts
src/vs/workbench/browser/parts/views/viewsViewlet.ts
+8
-8
src/vs/workbench/common/views.ts
src/vs/workbench/common/views.ts
+14
-13
src/vs/workbench/contrib/quickaccess/browser/viewQuickAccess.ts
.../workbench/contrib/quickaccess/browser/viewQuickAccess.ts
+3
-3
src/vs/workbench/contrib/scm/browser/scmViewlet.ts
src/vs/workbench/contrib/scm/browser/scmViewlet.ts
+10
-10
src/vs/workbench/contrib/terminal/browser/terminalService.ts
src/vs/workbench/contrib/terminal/browser/terminalService.ts
+1
-1
src/vs/workbench/services/views/browser/viewDescriptorService.ts
...workbench/services/views/browser/viewDescriptorService.ts
+642
-64
src/vs/workbench/services/views/common/viewsModel.ts
src/vs/workbench/services/views/common/viewsModel.ts
+0
-648
src/vs/workbench/services/views/test/browser/viewDescriptorService.test.ts
...services/views/test/browser/viewDescriptorService.test.ts
+15
-12
src/vs/workbench/services/views/test/browser/viewsModel.test.ts
.../workbench/services/views/test/browser/viewsModel.test.ts
+182
-172
未找到文件。
src/vs/workbench/browser/actions/layoutActions.ts
浏览文件 @
116a3de4
...
...
@@ -488,9 +488,9 @@ export class ResetViewLocationsAction extends Action {
async
run
():
Promise
<
void
>
{
const
viewContainerRegistry
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewContainerExtensions
.
ViewContainersRegistry
);
viewContainerRegistry
.
all
.
forEach
(
viewContainer
=>
{
const
view
Descriptors
=
this
.
viewDescriptorService
.
getViewDescriptors
(
viewContainer
);
const
view
ContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
view
Descriptors
.
allViewDescriptors
.
forEach
(
viewDescriptor
=>
{
view
ContainerModel
.
allViewDescriptors
.
forEach
(
viewDescriptor
=>
{
const
defaultContainer
=
this
.
viewDescriptorService
.
getDefaultContainer
(
viewDescriptor
.
id
);
const
currentContainer
=
this
.
viewDescriptorService
.
getViewContainer
(
viewDescriptor
.
id
);
...
...
@@ -583,7 +583,7 @@ export class MoveFocusedViewAction extends Action {
const
currentContainer
=
this
.
viewDescriptorService
.
getViewContainer
(
focusedViewId
)
!
;
const
currentLocation
=
this
.
viewDescriptorService
.
getViewLocation
(
focusedViewId
)
!
;
const
isViewSolo
=
this
.
viewDescriptorService
.
getView
Descriptors
(
currentContainer
).
allViewDescriptors
.
length
===
1
;
const
isViewSolo
=
this
.
viewDescriptorService
.
getView
ContainerModel
(
currentContainer
).
allViewDescriptors
.
length
===
1
;
if
(
!
(
isViewSolo
&&
currentLocation
===
ViewContainerLocation
.
Sidebar
))
{
items
.
push
({
...
...
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
浏览文件 @
116a3de4
...
...
@@ -26,7 +26,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
ToggleCompositePinnedAction
,
ICompositeBarColors
,
ActivityAction
,
ICompositeActivity
}
from
'
vs/workbench/browser/parts/compositeBarActions
'
;
import
{
ViewletDescriptor
}
from
'
vs/workbench/browser/viewlet
'
;
import
{
IViewDescriptorService
,
IViewContainersRegistry
,
Extensions
as
ViewContainerExtensions
,
ViewContainer
,
TEST_VIEW_CONTAINER_ID
,
IView
DescriptorCollection
,
ViewContainerLocation
}
from
'
vs/workbench/common/views
'
;
import
{
IViewDescriptorService
,
IViewContainersRegistry
,
Extensions
as
ViewContainerExtensions
,
ViewContainer
,
TEST_VIEW_CONTAINER_ID
,
IView
ContainerModel
,
ViewContainerLocation
}
from
'
vs/workbench/common/views
'
;
import
{
IContextKeyService
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IViewlet
}
from
'
vs/workbench/common/viewlet
'
;
import
{
isUndefinedOrNull
,
assertIsDefined
,
isString
}
from
'
vs/base/common/types
'
;
...
...
@@ -218,8 +218,8 @@ export class ActivitybarPart extends Part implements IActivityBarService {
if
(
viewletDescriptor
)
{
const
viewContainer
=
this
.
getViewContainer
(
viewletDescriptor
.
id
);
if
(
viewContainer
?.
hideIfEmpty
)
{
const
view
Descriptors
=
this
.
viewDescriptorService
.
getViewDescriptors
(
viewContainer
);
if
(
view
Descriptors
.
activeViewDescriptors
.
length
===
0
)
{
const
view
ContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
if
(
view
ContainerModel
.
activeViewDescriptors
.
length
===
0
)
{
this
.
hideComposite
(
viewletDescriptor
.
id
);
// Update the composite bar by hiding
}
}
...
...
@@ -490,13 +490,12 @@ export class ActivitybarPart extends Part implements IActivityBarService {
for
(
const
viewlet
of
viewlets
)
{
this
.
enableCompositeActions
(
viewlet
);
const
viewContainer
=
this
.
getViewContainer
(
viewlet
.
id
)
!
;
const
view
Descriptors
=
this
.
viewDescriptorService
.
getViewDescriptors
(
viewContainer
);
this
.
onDidChangeActiveViews
(
viewlet
,
view
Descriptors
,
viewContainer
.
hideIfEmpty
);
const
view
ContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
this
.
onDidChangeActiveViews
(
viewlet
,
view
ContainerModel
,
viewContainer
.
hideIfEmpty
);
const
disposables
=
new
DisposableStore
();
disposables
.
add
(
viewDescriptors
.
onDidChangeActiveViews
(()
=>
this
.
onDidChangeActiveViews
(
viewlet
,
viewDescriptors
,
viewContainer
.
hideIfEmpty
)));
disposables
.
add
(
viewDescriptors
.
onDidChangeViews
(()
=>
this
.
onDidUpdateViews
(
viewlet
,
viewDescriptors
)));
disposables
.
add
(
viewDescriptors
.
onDidMove
(()
=>
this
.
onDidUpdateViews
(
viewlet
,
viewDescriptors
)));
disposables
.
add
(
viewContainerModel
.
onDidChangeActiveViewDescriptors
(()
=>
this
.
onDidChangeActiveViews
(
viewlet
,
viewContainerModel
,
viewContainer
.
hideIfEmpty
)));
disposables
.
add
(
viewContainerModel
.
onDidChangeContainerInfo
(()
=>
this
.
updateActivity
(
viewlet
,
viewContainerModel
)));
this
.
viewletDisposables
.
set
(
viewlet
.
id
,
disposables
);
}
...
...
@@ -512,12 +511,12 @@ export class ActivitybarPart extends Part implements IActivityBarService {
this
.
hideComposite
(
viewletId
);
}
private
updateActivity
(
viewlet
:
ViewletDescriptor
,
view
Descriptors
:
IViewDescriptorCollection
):
void
{
const
icon
=
view
Descriptors
.
getIcon
()
;
private
updateActivity
(
viewlet
:
ViewletDescriptor
,
view
ContainerModel
:
IViewContainerModel
):
void
{
const
icon
=
view
ContainerModel
.
icon
;
const
activity
:
IActivity
=
{
id
:
viewlet
.
id
,
name
:
view
Descriptors
.
getTitle
()
,
name
:
view
ContainerModel
.
title
,
cssClass
:
isString
(
icon
)
?
icon
:
undefined
,
iconUrl
:
icon
instanceof
URI
?
icon
:
undefined
,
keybindingId
:
viewlet
.
keybindingId
...
...
@@ -531,11 +530,7 @@ export class ActivitybarPart extends Part implements IActivityBarService {
}
}
private
onDidUpdateViews
(
viewlet
:
ViewletDescriptor
,
viewDescriptors
:
IViewDescriptorCollection
):
void
{
this
.
updateActivity
(
viewlet
,
viewDescriptors
);
}
private
onDidChangeActiveViews
(
viewlet
:
ViewletDescriptor
,
viewDescriptors
:
IViewDescriptorCollection
,
hideIfEmpty
?:
boolean
):
void
{
private
onDidChangeActiveViews
(
viewlet
:
ViewletDescriptor
,
viewDescriptors
:
IViewContainerModel
,
hideIfEmpty
?:
boolean
):
void
{
if
(
viewDescriptors
.
activeViewDescriptors
.
length
)
{
this
.
updateActivity
(
viewlet
,
viewDescriptors
);
this
.
compositeBar
.
addComposite
(
viewlet
);
...
...
@@ -663,8 +658,8 @@ export class ActivitybarPart extends Part implements IActivityBarService {
if
(
viewlet
)
{
const
views
:
{
when
:
string
|
undefined
}[]
=
[];
if
(
viewContainer
)
{
const
view
Descriptors
=
this
.
viewDescriptorService
.
getViewDescriptors
(
viewContainer
);
for
(
const
{
when
}
of
view
Descriptors
.
allViewDescriptors
)
{
const
view
ContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
for
(
const
{
when
}
of
view
ContainerModel
.
allViewDescriptors
)
{
views
.
push
({
when
:
when
?
when
.
serialize
()
:
undefined
});
}
}
...
...
src/vs/workbench/browser/parts/compositeBar.ts
浏览文件 @
116a3de4
...
...
@@ -56,7 +56,7 @@ export class CompositeDragAndDrop implements ICompositeDragAndDrop {
}
// ... on a different composite bar
else
{
const
viewsToMove
=
this
.
viewDescriptorService
.
getView
Descriptors
(
currentContainer
)
!
.
allViewDescriptors
;
const
viewsToMove
=
this
.
viewDescriptorService
.
getView
ContainerModel
(
currentContainer
)
!
.
allViewDescriptors
;
if
(
viewsToMove
.
some
(
v
=>
!
v
.
canMoveView
))
{
return
;
}
...
...
@@ -119,7 +119,7 @@ export class CompositeDragAndDrop implements ICompositeDragAndDrop {
}
// ... to another composite location
const
draggedViews
=
this
.
viewDescriptorService
.
getView
Descriptors
(
currentContainer
)
!
.
allViewDescriptors
;
const
draggedViews
=
this
.
viewDescriptorService
.
getView
ContainerModel
(
currentContainer
)
!
.
allViewDescriptors
;
// ... all views must be movable
return
!
draggedViews
.
some
(
v
=>
!
v
.
canMoveView
);
...
...
src/vs/workbench/browser/parts/panel/panelPart.ts
浏览文件 @
116a3de4
...
...
@@ -33,7 +33,7 @@ import { IContextKey, IContextKeyService, ContextKeyExpr } from 'vs/platform/con
import
{
isUndefinedOrNull
,
assertIsDefined
}
from
'
vs/base/common/types
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
IExtensionService
}
from
'
vs/workbench/services/extensions/common/extensions
'
;
import
{
ViewContainer
,
IViewContainersRegistry
,
Extensions
as
ViewContainerExtensions
,
IViewDescriptorService
,
IView
DescriptorCollection
,
ViewContainerLocation
}
from
'
vs/workbench/common/views
'
;
import
{
ViewContainer
,
IViewContainersRegistry
,
Extensions
as
ViewContainerExtensions
,
IViewDescriptorService
,
IView
ContainerModel
,
ViewContainerLocation
}
from
'
vs/workbench/common/views
'
;
import
{
MenuId
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ViewMenuActions
}
from
'
vs/workbench/browser/parts/views/viewMenuActions
'
;
import
{
IPaneComposite
}
from
'
vs/workbench/common/panecomposite
'
;
...
...
@@ -178,9 +178,9 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
const
result
:
IAction
[]
=
[];
const
container
=
this
.
getViewContainer
(
compositeId
);
if
(
container
)
{
const
view
Descriptors
=
this
.
viewDescriptorService
.
getViewDescriptors
(
container
);
if
(
view
Descriptors
.
allViewDescriptors
.
length
===
1
)
{
const
viewMenuActions
=
this
.
instantiationService
.
createInstance
(
ViewMenuActions
,
view
Descriptors
.
allViewDescriptors
[
0
].
id
,
MenuId
.
ViewTitle
,
MenuId
.
ViewTitleContext
);
const
view
ContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
container
);
if
(
view
ContainerModel
.
allViewDescriptors
.
length
===
1
)
{
const
viewMenuActions
=
this
.
instantiationService
.
createInstance
(
ViewMenuActions
,
view
ContainerModel
.
allViewDescriptors
[
0
].
id
,
MenuId
.
ViewTitle
,
MenuId
.
ViewTitleContext
);
result
.
push
(...
viewMenuActions
.
getContextMenuActions
());
viewMenuActions
.
dispose
();
}
...
...
@@ -211,13 +211,13 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
for
(
const
panel
of
panels
)
{
this
.
enableCompositeActions
(
panel
);
const
viewContainer
=
this
.
getViewContainer
(
panel
.
id
)
!
;
const
view
Descriptors
=
this
.
viewDescriptorService
.
getViewDescriptors
(
viewContainer
);
this
.
onDidChangeActiveViews
(
panel
,
view
Descriptors
,
viewContainer
.
hideIfEmpty
);
const
view
ContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
this
.
onDidChangeActiveViews
(
panel
,
view
ContainerModel
,
viewContainer
.
hideIfEmpty
);
const
disposables
=
new
DisposableStore
();
disposables
.
add
(
view
Descriptors
.
onDidChangeActiveViews
(()
=>
this
.
onDidChangeActiveViews
(
panel
,
viewDescriptors
,
viewContainer
.
hideIfEmpty
)));
disposables
.
add
(
view
Descriptors
.
onDidChangeViews
(()
=>
this
.
onDidUpdateViews
(
panel
,
viewDescriptors
)));
disposables
.
add
(
view
Descriptors
.
onDidMove
(()
=>
this
.
onDidUpdateViews
(
panel
,
viewDescriptors
)));
disposables
.
add
(
view
ContainerModel
.
onDidChangeActiveViewDescriptors
(()
=>
this
.
onDidChangeActiveViews
(
panel
,
viewContainerModel
,
viewContainer
.
hideIfEmpty
)));
disposables
.
add
(
view
ContainerModel
.
onDidChangeAllViewDescriptors
(()
=>
this
.
onDidUpdateViews
(
panel
,
viewContainerModel
)));
disposables
.
add
(
view
ContainerModel
.
onDidMoveVisibleViewDescriptors
(()
=>
this
.
onDidUpdateViews
(
panel
,
viewContainerModel
)));
this
.
panelDisposables
.
set
(
panel
.
id
,
disposables
);
}
...
...
@@ -242,10 +242,10 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
}
private
updateActivity
(
panel
:
PanelDescriptor
,
view
Descriptors
:
IViewDescriptorCollection
):
void
{
private
updateActivity
(
panel
:
PanelDescriptor
,
view
ContainerModel
:
IViewContainerModel
):
void
{
const
activity
:
IActivity
=
{
id
:
panel
.
id
,
name
:
view
Descriptors
.
getTitle
()
,
name
:
view
ContainerModel
.
title
,
keybindingId
:
panel
.
keybindingId
};
...
...
@@ -257,11 +257,11 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
}
}
private
onDidUpdateViews
(
panel
:
PanelDescriptor
,
viewDescriptors
:
IView
DescriptorCollection
):
void
{
private
onDidUpdateViews
(
panel
:
PanelDescriptor
,
viewDescriptors
:
IView
ContainerModel
):
void
{
this
.
updateActivity
(
panel
,
viewDescriptors
);
}
private
onDidChangeActiveViews
(
panel
:
PanelDescriptor
,
viewDescriptors
:
IView
DescriptorCollection
,
hideIfEmpty
?:
boolean
):
void
{
private
onDidChangeActiveViews
(
panel
:
PanelDescriptor
,
viewDescriptors
:
IView
ContainerModel
,
hideIfEmpty
?:
boolean
):
void
{
if
(
viewDescriptors
.
activeViewDescriptors
.
length
)
{
this
.
updateActivity
(
panel
,
viewDescriptors
);
this
.
compositeBar
.
addComposite
(
panel
);
...
...
@@ -343,8 +343,8 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
if
(
panelDescriptor
)
{
const
viewContainer
=
this
.
getViewContainer
(
panelDescriptor
.
id
);
if
(
viewContainer
?.
hideIfEmpty
)
{
const
view
Descriptors
=
this
.
viewDescriptorService
.
getViewDescriptors
(
viewContainer
);
if
(
view
Descriptors
.
activeViewDescriptors
.
length
===
0
&&
this
.
compositeBar
.
getPinnedComposites
().
length
>
1
)
{
const
view
ContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
if
(
view
ContainerModel
.
activeViewDescriptors
.
length
===
0
&&
this
.
compositeBar
.
getPinnedComposites
().
length
>
1
)
{
this
.
hideComposite
(
panelDescriptor
.
id
);
// Update the composite bar by hiding
}
}
...
...
@@ -610,10 +610,11 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
const
compositeItems
=
this
.
compositeBar
.
getCompositeBarItems
();
for
(
const
compositeItem
of
compositeItems
)
{
const
viewContainer
=
this
.
getViewContainer
(
compositeItem
.
id
)
!
;
const
viewDescriptors
=
this
.
viewDescriptorService
.
getViewDescriptors
(
viewContainer
);
state
.
push
({
id
:
compositeItem
.
id
,
name
:
viewDescriptors
.
getTitle
(),
pinned
:
compositeItem
.
pinned
,
order
:
compositeItem
.
order
,
visible
:
compositeItem
.
visible
});
const
viewContainer
=
this
.
getViewContainer
(
compositeItem
.
id
);
if
(
viewContainer
)
{
const
viewContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
state
.
push
({
id
:
compositeItem
.
id
,
name
:
viewContainerModel
.
title
,
pinned
:
compositeItem
.
pinned
,
order
:
compositeItem
.
order
,
visible
:
compositeItem
.
visible
});
}
}
this
.
cachedPanelsValue
=
JSON
.
stringify
(
state
);
...
...
src/vs/workbench/browser/parts/views/viewPaneContainer.ts
浏览文件 @
116a3de4
...
...
@@ -24,7 +24,7 @@ import { PaneView, IPaneViewOptions, IPaneOptions, Pane } from 'vs/base/browser/
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IWorkbenchLayoutService
,
Position
}
from
'
vs/workbench/services/layout/browser/layoutService
'
;
import
{
StandardMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
{
Extensions
as
ViewContainerExtensions
,
IView
,
FocusedViewContext
,
IViewContainersRegistry
,
IViewDescriptor
,
ViewContainer
,
IViewDescriptorService
,
ViewContainerLocation
,
IViewPaneContainer
,
IViewsRegistry
,
IViewContentDescriptor
,
IAddedViewDescriptorRef
,
IViewDescriptorRef
,
IView
DescriptorCollection
}
from
'
vs/workbench/common/views
'
;
import
{
Extensions
as
ViewContainerExtensions
,
IView
,
FocusedViewContext
,
IViewContainersRegistry
,
IViewDescriptor
,
ViewContainer
,
IViewDescriptorService
,
ViewContainerLocation
,
IViewPaneContainer
,
IViewsRegistry
,
IViewContentDescriptor
,
IAddedViewDescriptorRef
,
IViewDescriptorRef
,
IView
ContainerModel
}
from
'
vs/workbench/common/views
'
;
import
{
IStorageService
,
StorageScope
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
assertIsDefined
}
from
'
vs/base/common/types
'
;
...
...
@@ -745,7 +745,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
private
readonly
visibleViewsCountFromCache
:
number
|
undefined
;
private
readonly
visibleViewsStorageId
:
string
;
protected
readonly
view
sDescriptors
:
IViewDescriptorCollection
;
protected
readonly
view
ContainerModel
:
IViewContainerModel
;
private
viewDisposables
:
IDisposable
[]
=
[];
private
readonly
_onTitleAreaUpdate
:
Emitter
<
void
>
=
this
.
_register
(
new
Emitter
<
void
>
());
...
...
@@ -806,7 +806,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
this
.
visibleViewsStorageId
=
`
${
id
}
.numberOfVisibleViews`
;
this
.
visibleViewsCountFromCache
=
this
.
storageService
.
getNumber
(
this
.
visibleViewsStorageId
,
StorageScope
.
WORKSPACE
,
undefined
);
this
.
_register
(
toDisposable
(()
=>
this
.
viewDisposables
=
dispose
(
this
.
viewDisposables
)));
this
.
view
sDescriptors
=
this
.
viewDescriptorService
.
getViewDescriptors
(
container
);
this
.
view
ContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
container
);
}
create
(
parent
:
HTMLElement
):
void
{
...
...
@@ -837,7 +837,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
const
viewContainerRegistry
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewContainerExtensions
.
ViewContainersRegistry
);
const
container
=
viewContainerRegistry
.
get
(
dropData
.
id
)
!
;
const
viewsToMove
=
this
.
viewDescriptorService
.
getView
Descriptors
(
container
).
allViewDescriptors
;
const
viewsToMove
=
this
.
viewDescriptorService
.
getView
ContainerModel
(
container
).
allViewDescriptors
;
if
(
!
viewsToMove
.
some
(
v
=>
!
v
.
canMoveView
))
{
overlay
=
new
ViewPaneDropOverlay
(
parent
,
undefined
,
this
.
themeService
);
...
...
@@ -859,7 +859,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
const
viewContainerRegistry
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewContainerExtensions
.
ViewContainersRegistry
);
const
container
=
viewContainerRegistry
.
get
(
dropData
.
id
)
!
;
const
allViews
=
this
.
viewDescriptorService
.
getView
Descriptors
(
container
).
allViewDescriptors
;
const
allViews
=
this
.
viewDescriptorService
.
getView
ContainerModel
(
container
).
allViewDescriptors
;
if
(
!
allViews
.
some
(
v
=>
!
v
.
canMoveView
))
{
viewsToMove
.
push
(...
allViews
);
}
...
...
@@ -882,11 +882,11 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
}));
this
.
_register
(
this
.
onDidSashChange
(()
=>
this
.
saveViewSizes
()));
this
.
view
sDescriptors
.
onDidAdd
(
added
=>
this
.
onDidAddViewDescriptors
(
added
));
this
.
view
sDescriptors
.
onDidRemove
(
removed
=>
this
.
onDidRemoveViewDescriptors
(
removed
));
const
addedViews
:
IAddedViewDescriptorRef
[]
=
this
.
view
sDescriptors
.
visibleViewDescriptors
.
map
((
viewDescriptor
,
index
)
=>
{
const
size
=
this
.
view
sDescriptors
.
getSize
(
viewDescriptor
.
id
);
const
collapsed
=
this
.
view
sDescriptors
.
isCollapsed
(
viewDescriptor
.
id
);
this
.
view
ContainerModel
.
onDidAddVisibleViewDescriptors
(
added
=>
this
.
onDidAddViewDescriptors
(
added
));
this
.
view
ContainerModel
.
onDidRemoveVisibleViewDescriptors
(
removed
=>
this
.
onDidRemoveViewDescriptors
(
removed
));
const
addedViews
:
IAddedViewDescriptorRef
[]
=
this
.
view
ContainerModel
.
visibleViewDescriptors
.
map
((
viewDescriptor
,
index
)
=>
{
const
size
=
this
.
view
ContainerModel
.
getSize
(
viewDescriptor
.
id
);
const
collapsed
=
this
.
view
ContainerModel
.
isCollapsed
(
viewDescriptor
.
id
);
return
({
viewDescriptor
,
index
,
size
,
collapsed
});
});
if
(
addedViews
.
length
)
{
...
...
@@ -904,7 +904,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
}
getTitle
():
string
{
const
containerTitle
=
this
.
view
sDescriptors
.
getTitle
()
;
const
containerTitle
=
this
.
view
ContainerModel
.
title
;
if
(
this
.
isViewMergedWithContainer
())
{
const
paneItemTitle
=
this
.
paneItems
[
0
].
pane
.
title
;
...
...
@@ -955,10 +955,10 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
}
}
const
viewToggleActions
=
this
.
view
sDescriptors
.
activeViewDescriptors
.
map
(
viewDescriptor
=>
(
<
IAction
>
{
const
viewToggleActions
=
this
.
view
ContainerModel
.
activeViewDescriptors
.
map
(
viewDescriptor
=>
(
<
IAction
>
{
id
:
`
${
viewDescriptor
.
id
}
.toggleVisibility`
,
label
:
viewDescriptor
.
name
,
checked
:
this
.
view
sDescriptors
.
isVisible
(
viewDescriptor
.
id
),
checked
:
this
.
view
ContainerModel
.
isVisible
(
viewDescriptor
.
id
),
enabled
:
viewDescriptor
.
canToggleVisibility
,
run
:
()
=>
this
.
toggleViewVisibility
(
viewDescriptor
.
id
)
}));
...
...
@@ -1087,7 +1087,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
// Save size only when the layout has happened
if
(
this
.
didLayout
)
{
for
(
const
view
of
this
.
panes
)
{
this
.
view
sDescriptors
.
setSize
(
view
.
id
,
this
.
getPaneSize
(
view
));
this
.
view
ContainerModel
.
setSize
(
view
.
id
,
this
.
getPaneSize
(
view
));
}
}
}
...
...
@@ -1096,10 +1096,10 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
// Restore sizes only when the layout has happened
if
(
this
.
didLayout
)
{
let
initialSizes
;
for
(
let
i
=
0
;
i
<
this
.
view
sDescriptors
.
visibleViewDescriptors
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
this
.
view
ContainerModel
.
visibleViewDescriptors
.
length
;
i
++
)
{
const
pane
=
this
.
panes
[
i
];
const
viewDescriptor
=
this
.
view
sDescriptors
.
visibleViewDescriptors
[
i
];
const
size
=
this
.
view
sDescriptors
.
getSize
(
viewDescriptor
.
id
);
const
viewDescriptor
=
this
.
view
ContainerModel
.
visibleViewDescriptors
[
i
];
const
size
=
this
.
view
ContainerModel
.
getSize
(
viewDescriptor
.
id
);
if
(
typeof
size
===
'
number
'
)
{
this
.
resizePane
(
pane
,
size
);
...
...
@@ -1114,8 +1114,8 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
private
computeInitialSizes
():
Map
<
string
,
number
>
{
const
sizes
:
Map
<
string
,
number
>
=
new
Map
<
string
,
number
>
();
if
(
this
.
dimension
)
{
const
totalWeight
=
this
.
view
sDescriptors
.
visibleViewDescriptors
.
reduce
((
totalWeight
,
{
weight
})
=>
totalWeight
+
(
weight
||
20
),
0
);
for
(
const
viewDescriptor
of
this
.
view
sDescriptors
.
visibleViewDescriptors
)
{
const
totalWeight
=
this
.
view
ContainerModel
.
visibleViewDescriptors
.
reduce
((
totalWeight
,
{
weight
})
=>
totalWeight
+
(
weight
||
20
),
0
);
for
(
const
viewDescriptor
of
this
.
view
ContainerModel
.
visibleViewDescriptors
)
{
if
(
this
.
orientation
===
Orientation
.
VERTICAL
)
{
sizes
.
set
(
viewDescriptor
.
id
,
this
.
dimension
.
height
*
(
viewDescriptor
.
weight
||
20
)
/
totalWeight
);
}
else
{
...
...
@@ -1176,7 +1176,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
});
const
collapseDisposable
=
Event
.
latch
(
Event
.
map
(
pane
.
onDidChange
,
()
=>
!
pane
.
isExpanded
()))(
collapsed
=>
{
this
.
view
sDescriptors
.
setCollapsed
(
viewDescriptor
.
id
,
collapsed
);
this
.
view
ContainerModel
.
setCollapsed
(
viewDescriptor
.
id
,
collapsed
);
});
this
.
viewDisposables
.
splice
(
index
,
0
,
combinedDisposable
(
contextMenuDisposable
,
collapseDisposable
));
...
...
@@ -1207,13 +1207,13 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
}
protected
toggleViewVisibility
(
viewId
:
string
):
void
{
const
visible
=
!
this
.
view
sDescriptors
.
isVisible
(
viewId
);
const
visible
=
!
this
.
view
ContainerModel
.
isVisible
(
viewId
);
type
ViewsToggleVisibilityClassification
=
{
viewId
:
{
classification
:
'
SystemMetaData
'
,
purpose
:
'
FeatureInsight
'
};
visible
:
{
classification
:
'
SystemMetaData
'
,
purpose
:
'
FeatureInsight
'
};
};
this
.
telemetryService
.
publicLog2
<
{
viewId
:
String
,
visible
:
boolean
},
ViewsToggleVisibilityClassification
>
(
'
views.toggleVisibility
'
,
{
viewId
,
visible
});
this
.
view
sDescriptors
.
setVisible
(
viewId
,
visible
);
this
.
view
ContainerModel
.
setVisible
(
viewId
,
visible
);
}
private
addPane
(
pane
:
ViewPane
,
size
:
number
,
index
=
this
.
paneItems
.
length
-
1
):
void
{
...
...
@@ -1268,7 +1268,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
const
viewContainerRegistry
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewContainerExtensions
.
ViewContainersRegistry
);
const
container
=
viewContainerRegistry
.
get
(
dropData
.
id
)
!
;
const
viewsToMove
=
this
.
viewDescriptorService
.
getView
Descriptors
(
container
).
allViewDescriptors
;
const
viewsToMove
=
this
.
viewDescriptorService
.
getView
ContainerModel
(
container
).
allViewDescriptors
;
if
(
!
viewsToMove
.
some
(
v
=>
!
v
.
canMoveView
))
{
overlay
=
new
ViewPaneDropOverlay
(
pane
.
dropTargetElement
,
this
.
orientation
??
Orientation
.
VERTICAL
,
this
.
themeService
);
...
...
@@ -1290,7 +1290,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
const
viewContainerRegistry
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewContainerExtensions
.
ViewContainersRegistry
);
const
container
=
viewContainerRegistry
.
get
(
dropData
.
id
)
!
;
const
allViews
=
this
.
viewDescriptorService
.
getView
Descriptors
(
container
).
allViewDescriptors
;
const
allViews
=
this
.
viewDescriptorService
.
getView
ContainerModel
(
container
).
allViewDescriptors
;
if
(
allViews
.
length
>
0
&&
!
allViews
.
some
(
v
=>
!
v
.
canMoveView
))
{
viewsToMove
.
push
(...
allViews
);
...
...
@@ -1405,8 +1405,8 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
const
fromIndex
=
firstIndex
(
this
.
paneItems
,
item
=>
item
.
pane
===
from
);
const
toIndex
=
firstIndex
(
this
.
paneItems
,
item
=>
item
.
pane
===
to
);
const
fromViewDescriptor
=
this
.
view
sDescriptors
.
visibleViewDescriptors
[
fromIndex
];
const
toViewDescriptor
=
this
.
view
sDescriptors
.
visibleViewDescriptors
[
toIndex
];
const
fromViewDescriptor
=
this
.
view
ContainerModel
.
visibleViewDescriptors
[
fromIndex
];
const
toViewDescriptor
=
this
.
view
ContainerModel
.
visibleViewDescriptors
[
toIndex
];
if
(
fromIndex
<
0
||
fromIndex
>=
this
.
paneItems
.
length
)
{
return
;
...
...
@@ -1421,7 +1421,7 @@ export class ViewPaneContainer extends Component implements IViewPaneContainer {
assertIsDefined
(
this
.
paneview
).
movePane
(
from
,
to
);
this
.
view
sDescriptors
.
move
(
fromViewDescriptor
.
id
,
toViewDescriptor
.
id
);
this
.
view
ContainerModel
.
move
(
fromViewDescriptor
.
id
,
toViewDescriptor
.
id
);
this
.
updateTitleArea
();
}
...
...
src/vs/workbench/browser/parts/views/views.ts
浏览文件 @
116a3de4
...
...
@@ -109,15 +109,15 @@ export class ViewsService extends Disposable implements IViewsService {
private
onDidRegisterViewContainer
(
viewContainer
:
ViewContainer
,
viewContainerLocation
:
ViewContainerLocation
):
void
{
this
.
registerViewletOrPanel
(
viewContainer
,
viewContainerLocation
);
const
view
DescriptorCollection
=
this
.
viewDescriptorService
.
getViewDescriptors
(
viewContainer
);
this
.
onViewDescriptorsAdded
(
view
DescriptorCollection
.
allViewDescriptors
,
viewContainer
);
this
.
_register
(
view
DescriptorCollection
.
onDidChangeView
s
(({
added
,
removed
})
=>
{
const
view
ContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
this
.
onViewDescriptorsAdded
(
view
ContainerModel
.
allViewDescriptors
,
viewContainer
);
this
.
_register
(
view
ContainerModel
.
onDidChangeAllViewDescriptor
s
(({
added
,
removed
})
=>
{
this
.
onViewDescriptorsAdded
(
added
,
viewContainer
);
this
.
onViewDescriptorsRemoved
(
removed
);
}));
}
private
onViewDescriptorsAdded
(
views
:
IViewDescriptor
[]
,
container
:
ViewContainer
):
void
{
private
onViewDescriptorsAdded
(
views
:
ReadonlyArray
<
IViewDescriptor
>
,
container
:
ViewContainer
):
void
{
const
location
=
this
.
viewContainersRegistry
.
getViewContainerLocation
(
container
);
if
(
location
===
undefined
)
{
return
;
...
...
@@ -181,7 +181,7 @@ export class ViewsService extends Disposable implements IViewsService {
}
}
private
onViewDescriptorsRemoved
(
views
:
IViewDescriptor
[]
):
void
{
private
onViewDescriptorsRemoved
(
views
:
ReadonlyArray
<
IViewDescriptor
>
):
void
{
for
(
const
view
of
views
)
{
const
disposable
=
this
.
viewDisposable
.
get
(
view
);
if
(
disposable
)
{
...
...
src/vs/workbench/browser/parts/views/viewsViewlet.ts
浏览文件 @
116a3de4
...
...
@@ -46,8 +46,8 @@ export abstract class FilterViewPaneContainer extends ViewPaneContainer {
this
.
onFilterChanged
(
newFilterValue
);
}));
this
.
_register
(
this
.
view
sDescriptors
.
onDidChangeActiveViews
((
viewDescriptors
)
=>
{
this
.
updateAllViews
(
v
iewDescriptors
);
this
.
_register
(
this
.
view
ContainerModel
.
onDidChangeActiveViewDescriptors
((
)
=>
{
this
.
updateAllViews
(
this
.
viewContainerModel
.
activeV
iewDescriptors
);
}));
}
...
...
@@ -62,7 +62,7 @@ export abstract class FilterViewPaneContainer extends ViewPaneContainer {
}
this
.
allViews
.
get
(
filterOnValue
)
!
.
set
(
descriptor
.
id
,
descriptor
);
if
(
this
.
filterValue
&&
!
this
.
filterValue
.
includes
(
filterOnValue
))
{
this
.
view
sDescriptors
.
setVisible
(
descriptor
.
id
,
false
);
this
.
view
ContainerModel
.
setVisible
(
descriptor
.
id
,
false
);
}
});
}
...
...
@@ -75,17 +75,17 @@ export abstract class FilterViewPaneContainer extends ViewPaneContainer {
private
onFilterChanged
(
newFilterValue
:
string
[])
{
if
(
this
.
allViews
.
size
===
0
)
{
this
.
updateAllViews
(
this
.
view
sDescriptors
.
activeViewDescriptors
);
this
.
updateAllViews
(
this
.
view
ContainerModel
.
activeViewDescriptors
);
}
this
.
getViewsNotForTarget
(
newFilterValue
).
forEach
(
item
=>
this
.
view
sDescriptors
.
setVisible
(
item
.
id
,
false
));
this
.
getViewsForTarget
(
newFilterValue
).
forEach
(
item
=>
this
.
view
sDescriptors
.
setVisible
(
item
.
id
,
true
));
this
.
getViewsNotForTarget
(
newFilterValue
).
forEach
(
item
=>
this
.
view
ContainerModel
.
setVisible
(
item
.
id
,
false
));
this
.
getViewsForTarget
(
newFilterValue
).
forEach
(
item
=>
this
.
view
ContainerModel
.
setVisible
(
item
.
id
,
true
));
}
getContextMenuActions
():
IAction
[]
{
const
result
:
IAction
[]
=
Array
.
from
(
this
.
constantViewDescriptors
.
values
()).
map
(
viewDescriptor
=>
(
<
IAction
>
{
id
:
`
${
viewDescriptor
.
id
}
.toggleVisibility`
,
label
:
viewDescriptor
.
name
,
checked
:
this
.
view
sDescriptors
.
isVisible
(
viewDescriptor
.
id
),
checked
:
this
.
view
ContainerModel
.
isVisible
(
viewDescriptor
.
id
),
enabled
:
viewDescriptor
.
canToggleVisibility
,
run
:
()
=>
this
.
toggleViewVisibility
(
viewDescriptor
.
id
)
}));
...
...
@@ -133,7 +133,7 @@ export abstract class FilterViewPaneContainer extends ViewPaneContainer {
}
// Check that allViews is ready
if
(
this
.
allViews
.
size
===
0
)
{
this
.
updateAllViews
(
this
.
view
sDescriptors
.
activeViewDescriptors
);
this
.
updateAllViews
(
this
.
view
ContainerModel
.
activeViewDescriptors
);
}
return
panes
;
}
...
...
src/vs/workbench/common/views.ts
浏览文件 @
116a3de4
...
...
@@ -219,18 +219,22 @@ export interface IAddedViewDescriptorRef extends IViewDescriptorRef {
size
?:
number
;
}
export
interface
IView
DescriptorCollection
extends
IDisposable
{
export
interface
IView
ContainerModel
{
readonly
allViewDescriptors
:
IViewDescriptor
[];
readonly
onDidChangeViews
:
Event
<
{
added
:
IViewDescriptor
[],
removed
:
IViewDescriptor
[]
}
>
;
readonly
title
:
string
;
readonly
icon
:
string
|
URI
|
undefined
;
readonly
onDidChangeContainerInfo
:
Event
<
{
title
?:
boolean
,
icon
?:
boolean
}
>
;
readonly
a
ctiveViewDescriptors
:
IViewDescriptor
[]
;
readonly
onDidChangeA
ctiveViews
:
Event
<
ReadonlyArray
<
IViewDescriptor
>
>
;
readonly
a
llViewDescriptors
:
ReadonlyArray
<
IViewDescriptor
>
;
readonly
onDidChangeA
llViewDescriptors
:
Event
<
{
added
:
ReadonlyArray
<
IViewDescriptor
>
,
removed
:
ReadonlyArray
<
IViewDescriptor
>
}
>
;
readonly
visibleViewDescriptors
:
IViewDescriptor
[];
readonly
onDidAdd
:
Event
<
IAddedViewDescriptorRef
[]
>
;
readonly
onDidRemove
:
Event
<
IViewDescriptorRef
[]
>
readonly
onDidMove
:
Event
<
{
from
:
IViewDescriptorRef
;
to
:
IViewDescriptorRef
;
}
>
readonly
activeViewDescriptors
:
ReadonlyArray
<
IViewDescriptor
>
;
readonly
onDidChangeActiveViewDescriptors
:
Event
<
{
added
:
ReadonlyArray
<
IViewDescriptor
>
,
removed
:
ReadonlyArray
<
IViewDescriptor
>
}
>
;
readonly
visibleViewDescriptors
:
ReadonlyArray
<
IViewDescriptor
>
;
readonly
onDidAddVisibleViewDescriptors
:
Event
<
IAddedViewDescriptorRef
[]
>
;
readonly
onDidRemoveVisibleViewDescriptors
:
Event
<
IViewDescriptorRef
[]
>
readonly
onDidMoveVisibleViewDescriptors
:
Event
<
{
from
:
IViewDescriptorRef
;
to
:
IViewDescriptorRef
;
}
>
isVisible
(
id
:
string
):
boolean
;
setVisible
(
id
:
string
,
visible
:
boolean
,
size
?:
number
):
void
;
...
...
@@ -241,9 +245,6 @@ export interface IViewDescriptorCollection extends IDisposable {
getSize
(
id
:
string
):
number
|
undefined
;
setSize
(
id
:
string
,
size
:
number
):
void
getTitle
():
string
;
getIcon
():
URI
|
string
|
undefined
;
move
(
from
:
string
,
to
:
string
):
void
;
}
...
...
@@ -484,7 +485,7 @@ export interface IViewDescriptorService {
moveViewsToContainer
(
views
:
IViewDescriptor
[],
viewContainer
:
ViewContainer
):
void
;
getView
Descriptors
(
container
:
ViewContainer
):
IViewDescriptorCollection
;
getView
ContainerModel
(
container
:
ViewContainer
):
IViewContainerModel
;
getViewDescriptor
(
viewId
:
string
):
IViewDescriptor
|
null
;
...
...
src/vs/workbench/contrib/quickaccess/browser/viewQuickAccess.ts
浏览文件 @
116a3de4
...
...
@@ -96,9 +96,9 @@ export class ViewQuickAccessProvider extends PickerQuickAccessProvider<IViewQuic
const
viewEntries
:
Array
<
IViewQuickPickItem
>
=
[];
const
getViewEntriesForViewlet
=
(
viewlet
:
ViewletDescriptor
,
viewContainer
:
ViewContainer
):
IViewQuickPickItem
[]
=>
{
const
view
Descriptors
=
this
.
viewDescriptorService
.
getViewDescriptors
(
viewContainer
);
const
view
ContainerModel
=
this
.
viewDescriptorService
.
getViewContainerModel
(
viewContainer
);
const
result
:
IViewQuickPickItem
[]
=
[];
for
(
const
view
of
view
Descriptors
.
allViewDescriptors
)
{
for
(
const
view
of
view
ContainerModel
.
allViewDescriptors
)
{
if
(
this
.
contextKeyService
.
contextMatchesRules
(
view
.
when
))
{
result
.
push
({
label
:
view
.
name
,
...
...
@@ -176,7 +176,7 @@ export class ViewQuickAccessProvider extends PickerQuickAccessProvider<IViewQuic
private
includeViewContainer
(
container
:
ViewletDescriptor
|
IPanelIdentifier
):
boolean
{
const
viewContainer
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewExtensions
.
ViewContainersRegistry
).
get
(
container
.
id
);
if
(
viewContainer
?.
hideIfEmpty
)
{
return
this
.
viewDescriptorService
.
getView
Descriptors
(
viewContainer
).
activeViewDescriptors
.
length
>
0
;
return
this
.
viewDescriptorService
.
getView
ContainerModel
(
viewContainer
).
activeViewDescriptors
.
length
>
0
;
}
return
true
;
...
...
src/vs/workbench/contrib/scm/browser/scmViewlet.ts
浏览文件 @
116a3de4
...
...
@@ -101,7 +101,7 @@ export class SCMViewPaneContainer extends ViewPaneContainer implements IViewMode
}
get
onDidChangeVisibleRepositories
():
Event
<
ISCMRepository
[]
>
{
const
modificationEvent
=
Event
.
debounce
(
Event
.
any
(
this
.
view
sDescriptors
.
onDidAdd
,
this
.
viewsDescriptors
.
onDidRemove
),
()
=>
null
,
0
);
const
modificationEvent
=
Event
.
debounce
(
Event
.
any
(
this
.
view
ContainerModel
.
onDidAddVisibleViewDescriptors
,
this
.
viewContainerModel
.
onDidRemoveVisibleViewDescriptors
),
()
=>
null
,
0
);
return
Event
.
map
(
modificationEvent
,
()
=>
this
.
visibleRepositories
);
}
...
...
@@ -140,14 +140,14 @@ export class SCMViewPaneContainer extends ViewPaneContainer implements IViewMode
this
.
_register
(
configurationService
.
onDidChangeConfiguration
(
e
=>
{
if
(
e
.
affectsConfiguration
(
'
scm.alwaysShowProviders
'
)
&&
configurationService
.
getValue
<
boolean
>
(
'
scm.alwaysShowProviders
'
))
{
this
.
view
sDescriptors
.
setVisible
(
MainPane
.
ID
,
true
);
this
.
view
ContainerModel
.
setVisible
(
MainPane
.
ID
,
true
);
}
}));
this
.
repositoryCountKey
=
contextKeyService
.
createKey
(
'
scm.providerCount
'
,
0
);
this
.
_register
(
this
.
view
sDescriptors
.
onDidAdd
(
this
.
onDidShowView
,
this
));
this
.
_register
(
this
.
view
sDescriptors
.
onDidRemove
(
this
.
onDidHideView
,
this
));
this
.
_register
(
this
.
view
ContainerModel
.
onDidAddVisibleViewDescriptors
(
this
.
onDidShowView
,
this
));
this
.
_register
(
this
.
view
ContainerModel
.
onDidRemoveVisibleViewDescriptors
(
this
.
onDidHideView
,
this
));
}
create
(
parent
:
HTMLElement
):
void
{
...
...
@@ -214,8 +214,8 @@ export class SCMViewPaneContainer extends ViewPaneContainer implements IViewMode
@
debounce
(
0
)
private
afterOnDidHideView
():
void
{
if
(
this
.
repositoryCountKey
.
get
()
!
>
0
&&
this
.
viewDescriptors
.
every
(
d
=>
!
this
.
view
sDescriptors
.
isVisible
(
d
.
id
)))
{
this
.
view
sDescriptors
.
setVisible
(
this
.
viewDescriptors
[
0
].
id
,
true
);
if
(
this
.
repositoryCountKey
.
get
()
!
>
0
&&
this
.
viewDescriptors
.
every
(
d
=>
!
this
.
view
ContainerModel
.
isVisible
(
d
.
id
)))
{
this
.
view
ContainerModel
.
setVisible
(
this
.
viewDescriptors
[
0
].
id
,
true
);
}
}
...
...
@@ -282,9 +282,9 @@ export class SCMViewPaneContainer extends ViewPaneContainer implements IViewMode
}
setVisibleRepositories
(
repositories
:
ISCMRepository
[]):
void
{
const
visibleViewDescriptors
=
this
.
view
sDescriptors
.
visibleViewDescriptors
;
const
visibleViewDescriptors
=
this
.
view
ContainerModel
.
visibleViewDescriptors
;
const
toSetVisible
=
this
.
view
sDescriptors
.
activeViewDescriptors
const
toSetVisible
=
this
.
view
ContainerModel
.
activeViewDescriptors
.
filter
((
d
):
d
is
RepositoryViewDescriptor
=>
d
instanceof
RepositoryViewDescriptor
&&
repositories
.
indexOf
(
d
.
repository
)
>
-
1
&&
visibleViewDescriptors
.
indexOf
(
d
)
===
-
1
);
const
toSetInvisible
=
visibleViewDescriptors
...
...
@@ -302,11 +302,11 @@ export class SCMViewPaneContainer extends ViewPaneContainer implements IViewMode
}
}
this
.
view
sDescriptors
.
setVisible
(
viewDescriptor
.
id
,
false
);
this
.
view
ContainerModel
.
setVisible
(
viewDescriptor
.
id
,
false
);
}
for
(
const
viewDescriptor
of
toSetVisible
)
{
this
.
view
sDescriptors
.
setVisible
(
viewDescriptor
.
id
,
true
,
size
);
this
.
view
ContainerModel
.
setVisible
(
viewDescriptor
.
id
,
true
,
size
);
}
}
}
src/vs/workbench/contrib/terminal/browser/terminalService.ts
浏览文件 @
116a3de4
...
...
@@ -704,7 +704,7 @@ export class TerminalService implements ITerminalService {
const
location
=
this
.
_viewDescriptorService
.
getViewLocation
(
TERMINAL_VIEW_ID
);
if
(
location
===
ViewContainerLocation
.
Panel
)
{
const
panel
=
this
.
_viewDescriptorService
.
getViewContainer
(
TERMINAL_VIEW_ID
);
if
(
panel
&&
this
.
_viewDescriptorService
.
getView
Descriptors
(
panel
).
activeViewDescriptors
.
length
===
1
)
{
if
(
panel
&&
this
.
_viewDescriptorService
.
getView
ContainerModel
(
panel
).
activeViewDescriptors
.
length
===
1
)
{
this
.
_layoutService
.
setPanelHidden
(
true
);
}
}
...
...
src/vs/workbench/services/views/browser/viewDescriptorService.ts
浏览文件 @
116a3de4
此差异已折叠。
点击以展开。
src/vs/workbench/services/views/common/viewsModel.ts
已删除
100644 → 0
浏览文件 @
9275e7ed
此差异已折叠。
点击以展开。
src/vs/workbench/services/views/test/browser/viewDescriptorService.test.ts
浏览文件 @
116a3de4
...
...
@@ -11,6 +11,8 @@ import { TestInstantiationService } from 'vs/platform/instantiation/test/common/
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
ViewDescriptorService
}
from
'
vs/workbench/services/views/browser/viewDescriptorService
'
;
import
{
assertIsDefined
}
from
'
vs/base/common/types
'
;
import
{
ContextKeyService
}
from
'
vs/platform/contextkey/browser/contextKeyService
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
const
ViewsRegistry
=
Registry
.
as
<
IViewsRegistry
>
(
ViewContainerExtensions
.
ViewsRegistry
);
const
sidebarContainer
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewContainerExtensions
.
ViewContainersRegistry
).
registerViewContainer
({
id
:
'
testSidebar
'
,
name
:
'
test
'
,
ctorDescriptor
:
new
SyncDescriptor
(
<
any
>
{})
},
ViewContainerLocation
.
Sidebar
);
...
...
@@ -22,6 +24,7 @@ suite('ViewDescriptorService', () => {
setup
(()
=>
{
const
instantiationService
:
TestInstantiationService
=
<
TestInstantiationService
>
workbenchInstantiationService
();
instantiationService
.
stub
(
IContextKeyService
,
instantiationService
.
createInstance
(
ContextKeyService
));
viewDescriptorService
=
instantiationService
.
createInstance
(
ViewDescriptorService
);
});
...
...
@@ -31,8 +34,8 @@ suite('ViewDescriptorService', () => {
});
test
(
'
Empty Containers
'
,
function
()
{
const
sidebarViews
=
viewDescriptorService
.
getView
Descriptors
(
sidebarContainer
);
const
panelViews
=
viewDescriptorService
.
getView
Descriptors
(
panelContainer
);
const
sidebarViews
=
viewDescriptorService
.
getView
ContainerModel
(
sidebarContainer
);
const
panelViews
=
viewDescriptorService
.
getView
ContainerModel
(
panelContainer
);
assert
.
equal
(
sidebarViews
.
allViewDescriptors
.
length
,
0
,
'
The sidebar container should have no views yet.
'
);
assert
.
equal
(
panelViews
.
allViewDescriptors
.
length
,
0
,
'
The panel container should have no views yet.
'
);
});
...
...
@@ -64,8 +67,8 @@ suite('ViewDescriptorService', () => {
ViewsRegistry
.
registerViews
(
viewDescriptors
.
slice
(
2
),
panelContainer
);
let
sidebarViews
=
viewDescriptorService
.
getView
Descriptors
(
sidebarContainer
);
let
panelViews
=
viewDescriptorService
.
getView
Descriptors
(
panelContainer
);
let
sidebarViews
=
viewDescriptorService
.
getView
ContainerModel
(
sidebarContainer
);
let
panelViews
=
viewDescriptorService
.
getView
ContainerModel
(
panelContainer
);
assert
.
equal
(
sidebarViews
.
activeViewDescriptors
.
length
,
2
,
'
Sidebar should have 2 views
'
);
assert
.
equal
(
panelViews
.
activeViewDescriptors
.
length
,
1
,
'
Panel should have 1 view
'
);
...
...
@@ -74,8 +77,8 @@ suite('ViewDescriptorService', () => {
ViewsRegistry
.
deregisterViews
(
viewDescriptors
.
slice
(
2
),
panelContainer
);
sidebarViews
=
viewDescriptorService
.
getView
Descriptors
(
sidebarContainer
);
panelViews
=
viewDescriptorService
.
getView
Descriptors
(
panelContainer
);
sidebarViews
=
viewDescriptorService
.
getView
ContainerModel
(
sidebarContainer
);
panelViews
=
viewDescriptorService
.
getView
ContainerModel
(
panelContainer
);
assert
.
equal
(
sidebarViews
.
activeViewDescriptors
.
length
,
0
,
'
Sidebar should have no views
'
);
assert
.
equal
(
panelViews
.
activeViewDescriptors
.
length
,
0
,
'
Panel should have no views
'
);
...
...
@@ -109,8 +112,8 @@ suite('ViewDescriptorService', () => {
viewDescriptorService
.
moveViewsToContainer
(
viewDescriptors
.
slice
(
2
),
sidebarContainer
);
viewDescriptorService
.
moveViewsToContainer
(
viewDescriptors
.
slice
(
0
,
2
),
panelContainer
);
let
sidebarViews
=
viewDescriptorService
.
getView
Descriptors
(
sidebarContainer
);
let
panelViews
=
viewDescriptorService
.
getView
Descriptors
(
panelContainer
);
let
sidebarViews
=
viewDescriptorService
.
getView
ContainerModel
(
sidebarContainer
);
let
panelViews
=
viewDescriptorService
.
getView
ContainerModel
(
panelContainer
);
assert
.
equal
(
sidebarViews
.
activeViewDescriptors
.
length
,
1
,
'
Sidebar should have 2 views
'
);
assert
.
equal
(
panelViews
.
activeViewDescriptors
.
length
,
2
,
'
Panel should have 1 view
'
);
...
...
@@ -148,8 +151,8 @@ suite('ViewDescriptorService', () => {
viewDescriptorService
.
moveViewToLocation
(
viewDescriptors
[
0
],
ViewContainerLocation
.
Panel
);
viewDescriptorService
.
moveViewToLocation
(
viewDescriptors
[
2
],
ViewContainerLocation
.
Sidebar
);
let
sidebarViews
=
viewDescriptorService
.
getView
Descriptors
(
sidebarContainer
);
let
panelViews
=
viewDescriptorService
.
getView
Descriptors
(
panelContainer
);
let
sidebarViews
=
viewDescriptorService
.
getView
ContainerModel
(
sidebarContainer
);
let
panelViews
=
viewDescriptorService
.
getView
ContainerModel
(
panelContainer
);
assert
.
equal
(
sidebarViews
.
activeViewDescriptors
.
length
,
1
,
'
Sidebar container should have 1 view
'
);
assert
.
equal
(
panelViews
.
activeViewDescriptors
.
length
,
0
,
'
Panel container should have no views
'
);
...
...
@@ -169,8 +172,8 @@ suite('ViewDescriptorService', () => {
viewDescriptorService
.
moveViewToLocation
(
viewDescriptors
[
0
],
ViewContainerLocation
.
Sidebar
);
viewDescriptorService
.
moveViewToLocation
(
viewDescriptors
[
2
],
ViewContainerLocation
.
Panel
);
sidebarViews
=
viewDescriptorService
.
getView
Descriptors
(
sidebarContainer
);
panelViews
=
viewDescriptorService
.
getView
Descriptors
(
panelContainer
);
sidebarViews
=
viewDescriptorService
.
getView
ContainerModel
(
sidebarContainer
);
panelViews
=
viewDescriptorService
.
getView
ContainerModel
(
panelContainer
);
assert
.
equal
(
sidebarViews
.
activeViewDescriptors
.
length
,
1
,
'
Sidebar should have 2 views
'
);
assert
.
equal
(
panelViews
.
activeViewDescriptors
.
length
,
0
,
'
Panel should have 1 view
'
);
...
...
src/vs/workbench/services/views/test/browser/viewsModel.test.ts
浏览文件 @
116a3de4
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录