@codingame/monaco-vscode-view-common-service-override 4.5.0-improve-code-splitting.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/fake.html +10 -0
- package/assets/index-no-csp.html +1230 -0
- package/assets/index.html +1231 -0
- package/assets/service-worker.js +457 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/override/vs/workbench/browser/parts/editor/textEditor.js +5 -0
- package/override/vs/workbench/browser/parts/editor/textEditor.weak.js +11 -0
- package/package.json +32 -0
- package/tools/editorAssets.js +4 -0
- package/tools/url.js +10 -0
- package/viewCommon.d.ts +5 -0
- package/viewCommon.js +105 -0
- package/vscode/src/vs/base/browser/deviceAccess.js +61 -0
- package/vscode/src/vs/base/browser/ui/centered/centeredViewLayout.js +180 -0
- package/vscode/src/vs/base/browser/ui/grid/grid.js +494 -0
- package/vscode/src/vs/base/browser/ui/grid/gridview.css.js +6 -0
- package/vscode/src/vs/base/browser/ui/grid/gridview.js +1113 -0
- package/vscode/src/vs/platform/languagePacks/common/localizedStrings.js +12 -0
- package/vscode/src/vs/platform/webview/common/mimeTypes.js +24 -0
- package/vscode/src/vs/platform/webview/common/webviewPortMapping.js +64 -0
- package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +907 -0
- package/vscode/src/vs/workbench/browser/actions/listCommands.js +764 -0
- package/vscode/src/vs/workbench/browser/actions/navigationActions.js +301 -0
- package/vscode/src/vs/workbench/browser/media/style.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/activitybar/activitybarPart.js +671 -0
- package/vscode/src/vs/workbench/browser/parts/activitybar/media/activityaction.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/activitybar/media/activitybarpart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/auxiliarybar/auxiliaryBarPart.js +229 -0
- package/vscode/src/vs/workbench/browser/parts/auxiliarybar/media/auxiliaryBarPart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/compositeBar.js +606 -0
- package/vscode/src/vs/workbench/browser/parts/compositePart.js +346 -0
- package/vscode/src/vs/workbench/browser/parts/editor/auxiliaryEditorPart.js +246 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +1403 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +188 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorDropTarget.js +523 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorPart.js +1030 -0
- package/vscode/src/vs/workbench/browser/parts/editor/editorParts.js +391 -0
- package/vscode/src/vs/workbench/browser/parts/editor/media/editordroptarget.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/media/compositepart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/media/paneCompositePart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositeBar.js +643 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositePart.js +472 -0
- package/vscode/src/vs/workbench/browser/parts/paneCompositePartService.js +68 -0
- package/vscode/src/vs/workbench/browser/parts/panel/panelPart.js +160 -0
- package/vscode/src/vs/workbench/browser/parts/sidebar/media/sidebarpart.css.js +6 -0
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarActions.js +39 -0
- package/vscode/src/vs/workbench/browser/parts/sidebar/sidebarPart.js +238 -0
- package/vscode/src/vs/workbench/browser/style.js +54 -0
- package/vscode/src/vs/workbench/browser/window.js +381 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +300 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +367 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +135 -0
- package/vscode/src/vs/workbench/contrib/callHierarchy/browser/media/callHierarchy.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +18 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +146 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +215 -0
- package/vscode/src/vs/workbench/contrib/customEditor/browser/media/customEditor.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +78 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/customEditor.js +56 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/customEditorModelManager.js +63 -0
- package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +183 -0
- package/vscode/src/vs/workbench/contrib/externalUriOpener/common/externalUriOpener.contribution.js +8 -0
- package/vscode/src/vs/workbench/contrib/languageStatus/browser/languageStatus.contribution.js +408 -0
- package/vscode/src/vs/workbench/contrib/languageStatus/browser/media/languageStatus.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/limitIndicator/browser/limitIndicator.contribution.js +147 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +635 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +230 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +75 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorSerializer.js +42 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +81 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +350 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +100 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +148 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/codeEditorView.js +106 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +403 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +199 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/fixedZoneWidget.js +41 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/lineAlignment.js +128 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/media/mergeEditor.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +619 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/scrollSynchronizer.js +161 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +266 -0
- package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewZones.js +173 -0
- package/vscode/src/vs/workbench/contrib/preferences/browser/keyboardLayoutPicker.js +195 -0
- package/vscode/src/vs/workbench/contrib/sash/browser/sash.contribution.js +38 -0
- package/vscode/src/vs/workbench/contrib/sash/browser/sash.js +41 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/media/typeHierarchy.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +283 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +362 -0
- package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +133 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.js +314 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +96 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/themeing.js +98 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +656 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewFindWidget.js +65 -0
- package/vscode/src/vs/workbench/contrib/webview/browser/webviewService.js +59 -0
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +143 -0
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.js +121 -0
- package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +67 -0
- package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +234 -0
- package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewService.js +45 -0
- package/vscode/src/vs/workbench/services/activity/browser/activityService.js +145 -0
- package/vscode/src/vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService.js +341 -0
- package/vscode/src/vs/workbench/services/driver/browser/driver.js +186 -0
- package/vscode/src/vs/workbench/services/editor/browser/editorPaneService.js +13 -0
- package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +676 -0
- package/vscode/src/vs/workbench/services/history/browser/historyService.js +1516 -0
- package/vscode/src/vs/workbench/services/progress/browser/media/progressService.css.js +6 -0
- package/vscode/src/vs/workbench/services/progress/browser/progressService.js +527 -0
- package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +102 -0
- package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorService.js +133 -0
- package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +711 -0
- package/vscode/src/vs/workbench/services/views/common/viewContainerModel.js +603 -0
|
@@ -0,0 +1,711 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { VIEWS_LOG_ID, VIEWS_LOG_NAME, Extensions, ViewVisibilityState, defaultViewIcon, ViewContainerLocationToString } from 'vscode/vscode/vs/workbench/common/views';
|
|
3
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
4
|
+
import { ContextKeyExpr, RawContextKey } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
5
|
+
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
6
|
+
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
7
|
+
import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
|
|
8
|
+
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
9
|
+
import { Disposable, DisposableMap, DisposableStore, toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
10
|
+
import { ViewPaneContainer, ViewPaneContainerAction, ViewsSubMenu } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPaneContainer';
|
|
11
|
+
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
12
|
+
import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
|
|
13
|
+
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
14
|
+
import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
|
|
15
|
+
import { getViewsStateStorageId, ViewContainerModel } from '../common/viewContainerModel.js';
|
|
16
|
+
import { registerAction2, MenuId, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
17
|
+
import { localizeWithPath, localize2WithPath } from 'vscode/vscode/vs/nls';
|
|
18
|
+
import { ILoggerService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
19
|
+
|
|
20
|
+
var ViewDescriptorService_1;
|
|
21
|
+
function getViewContainerStorageId(viewContainerId) { return `${viewContainerId}.state`; }
|
|
22
|
+
let ViewDescriptorService = class ViewDescriptorService extends Disposable {
|
|
23
|
+
static { ViewDescriptorService_1 = this; }
|
|
24
|
+
static { this.VIEWS_CUSTOMIZATIONS = 'views.customizations'; }
|
|
25
|
+
static { this.COMMON_CONTAINER_ID_PREFIX = 'workbench.views.service'; }
|
|
26
|
+
get viewContainers() { return this.viewContainersRegistry.all; }
|
|
27
|
+
constructor(instantiationService, contextKeyService, storageService, extensionService, telemetryService, loggerService) {
|
|
28
|
+
super();
|
|
29
|
+
this.instantiationService = instantiationService;
|
|
30
|
+
this.contextKeyService = contextKeyService;
|
|
31
|
+
this.storageService = storageService;
|
|
32
|
+
this.extensionService = extensionService;
|
|
33
|
+
this.telemetryService = telemetryService;
|
|
34
|
+
this._onDidChangeContainer = this._register(( new Emitter()));
|
|
35
|
+
this.onDidChangeContainer = this._onDidChangeContainer.event;
|
|
36
|
+
this._onDidChangeLocation = this._register(( new Emitter()));
|
|
37
|
+
this.onDidChangeLocation = this._onDidChangeLocation.event;
|
|
38
|
+
this._onDidChangeContainerLocation = this._register(( new Emitter()));
|
|
39
|
+
this.onDidChangeContainerLocation = this._onDidChangeContainerLocation.event;
|
|
40
|
+
this.viewContainerModels = this._register(( new DisposableMap()));
|
|
41
|
+
this.viewsVisibilityActionDisposables = this._register(( new DisposableMap()));
|
|
42
|
+
this.canRegisterViewsVisibilityActions = false;
|
|
43
|
+
this._onDidChangeViewContainers = this._register(( new Emitter()));
|
|
44
|
+
this.onDidChangeViewContainers = this._onDidChangeViewContainers.event;
|
|
45
|
+
this.logger = loggerService.createLogger(VIEWS_LOG_ID, { name: VIEWS_LOG_NAME, hidden: true });
|
|
46
|
+
this.activeViewContextKeys = ( new Map());
|
|
47
|
+
this.movableViewContextKeys = ( new Map());
|
|
48
|
+
this.defaultViewLocationContextKeys = ( new Map());
|
|
49
|
+
this.defaultViewContainerLocationContextKeys = ( new Map());
|
|
50
|
+
this.viewContainersRegistry = ( Registry.as(Extensions.ViewContainersRegistry));
|
|
51
|
+
this.viewsRegistry = ( Registry.as(Extensions.ViewsRegistry));
|
|
52
|
+
this.migrateToViewsCustomizationsStorage();
|
|
53
|
+
this.viewContainersCustomLocations = ( new Map(Object.entries(this.viewCustomizations.viewContainerLocations)));
|
|
54
|
+
this.viewDescriptorsCustomLocations = ( new Map(Object.entries(this.viewCustomizations.viewLocations)));
|
|
55
|
+
this.viewContainerBadgeEnablementStates = ( new Map(Object.entries(this.viewCustomizations.viewContainerBadgeEnablementStates)));
|
|
56
|
+
this.viewContainers.forEach(viewContainer => this.onDidRegisterViewContainer(viewContainer));
|
|
57
|
+
this._register(this.viewsRegistry.onViewsRegistered(views => this.onDidRegisterViews(views)));
|
|
58
|
+
this._register(this.viewsRegistry.onViewsDeregistered(({ views, viewContainer }) => this.onDidDeregisterViews(views, viewContainer)));
|
|
59
|
+
this._register(this.viewsRegistry.onDidChangeContainer(({ views, from, to }) => this.onDidChangeDefaultContainer(views, from, to)));
|
|
60
|
+
this._register(this.viewContainersRegistry.onDidRegister(({ viewContainer }) => {
|
|
61
|
+
this.onDidRegisterViewContainer(viewContainer);
|
|
62
|
+
this._onDidChangeViewContainers.fire({ added: [{ container: viewContainer, location: this.getViewContainerLocation(viewContainer) }], removed: [] });
|
|
63
|
+
}));
|
|
64
|
+
this._register(this.viewContainersRegistry.onDidDeregister(({ viewContainer, viewContainerLocation }) => {
|
|
65
|
+
this.onDidDeregisterViewContainer(viewContainer);
|
|
66
|
+
this._onDidChangeViewContainers.fire({ removed: [{ container: viewContainer, location: viewContainerLocation }], added: [] });
|
|
67
|
+
}));
|
|
68
|
+
this._register(this.storageService.onDidChangeValue(0 , ViewDescriptorService_1.VIEWS_CUSTOMIZATIONS, this._register(( new DisposableStore())))(() => this.onDidStorageChange()));
|
|
69
|
+
this.extensionService.whenInstalledExtensionsRegistered().then(() => this.whenExtensionsRegistered());
|
|
70
|
+
}
|
|
71
|
+
migrateToViewsCustomizationsStorage() {
|
|
72
|
+
if (this.storageService.get(ViewDescriptorService_1.VIEWS_CUSTOMIZATIONS, 0 )) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const viewContainerLocationsValue = this.storageService.get('views.cachedViewContainerLocations', 0 );
|
|
76
|
+
const viewDescriptorLocationsValue = this.storageService.get('views.cachedViewPositions', 0 );
|
|
77
|
+
if (!viewContainerLocationsValue && !viewDescriptorLocationsValue) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const viewContainerLocations = viewContainerLocationsValue ? JSON.parse(viewContainerLocationsValue) : [];
|
|
81
|
+
const viewDescriptorLocations = viewDescriptorLocationsValue ? JSON.parse(viewDescriptorLocationsValue) : [];
|
|
82
|
+
const viewsCustomizations = {
|
|
83
|
+
viewContainerLocations: viewContainerLocations.reduce((result, [id, location]) => { result[id] = location; return result; }, {}),
|
|
84
|
+
viewLocations: viewDescriptorLocations.reduce((result, [id, { containerId }]) => { result[id] = containerId; return result; }, {}),
|
|
85
|
+
viewContainerBadgeEnablementStates: {}
|
|
86
|
+
};
|
|
87
|
+
this.storageService.store(ViewDescriptorService_1.VIEWS_CUSTOMIZATIONS, JSON.stringify(viewsCustomizations), 0 , 0 );
|
|
88
|
+
this.storageService.remove('views.cachedViewContainerLocations', 0 );
|
|
89
|
+
this.storageService.remove('views.cachedViewPositions', 0 );
|
|
90
|
+
}
|
|
91
|
+
registerGroupedViews(groupedViews) {
|
|
92
|
+
for (const [containerId, views] of groupedViews.entries()) {
|
|
93
|
+
const viewContainer = this.viewContainersRegistry.get(containerId);
|
|
94
|
+
if (!viewContainer || !( this.viewContainerModels.has(viewContainer))) {
|
|
95
|
+
if (this.isGeneratedContainerId(containerId)) {
|
|
96
|
+
const viewContainerLocation = this.viewContainersCustomLocations.get(containerId);
|
|
97
|
+
if (viewContainerLocation !== undefined) {
|
|
98
|
+
this.registerGeneratedViewContainer(viewContainerLocation, containerId);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const viewsToAdd = views.filter(view => this.getViewContainerModel(viewContainer).allViewDescriptors.filter(vd => vd.id === view.id).length === 0);
|
|
104
|
+
this.addViews(viewContainer, viewsToAdd);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
deregisterGroupedViews(groupedViews) {
|
|
108
|
+
for (const [viewContainerId, views] of groupedViews.entries()) {
|
|
109
|
+
const viewContainer = this.viewContainersRegistry.get(viewContainerId);
|
|
110
|
+
if (!viewContainer || !( this.viewContainerModels.has(viewContainer))) {
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
this.removeViews(viewContainer, views);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
moveOrphanViewsToDefaultLocation() {
|
|
117
|
+
for (const [viewId, containerId] of this.viewDescriptorsCustomLocations.entries()) {
|
|
118
|
+
if (this.viewContainersRegistry.get(containerId)) {
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
const viewContainer = this.viewsRegistry.getViewContainer(viewId);
|
|
122
|
+
const viewDescriptor = this.getViewDescriptorById(viewId);
|
|
123
|
+
if (viewContainer && viewDescriptor) {
|
|
124
|
+
this.addViews(viewContainer, [viewDescriptor]);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
whenExtensionsRegistered() {
|
|
129
|
+
this.moveOrphanViewsToDefaultLocation();
|
|
130
|
+
for (const viewContainerId of [...( this.viewContainersCustomLocations.keys())]) {
|
|
131
|
+
this.cleanUpGeneratedViewContainer(viewContainerId);
|
|
132
|
+
}
|
|
133
|
+
this.saveViewCustomizations();
|
|
134
|
+
for (const [key, value] of this.viewContainerModels) {
|
|
135
|
+
this.registerViewsVisibilityActions(key, value);
|
|
136
|
+
}
|
|
137
|
+
this.canRegisterViewsVisibilityActions = true;
|
|
138
|
+
}
|
|
139
|
+
onDidRegisterViews(views) {
|
|
140
|
+
this.contextKeyService.bufferChangeEvents(() => {
|
|
141
|
+
views.forEach(({ views, viewContainer }) => {
|
|
142
|
+
const regroupedViews = this.regroupViews(viewContainer.id, views);
|
|
143
|
+
this.registerGroupedViews(regroupedViews);
|
|
144
|
+
views.forEach(viewDescriptor => this.getOrCreateMovableViewContextKey(viewDescriptor).set(!!viewDescriptor.canMoveView));
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
isGeneratedContainerId(id) {
|
|
149
|
+
return id.startsWith(ViewDescriptorService_1.COMMON_CONTAINER_ID_PREFIX);
|
|
150
|
+
}
|
|
151
|
+
onDidDeregisterViews(views, viewContainer) {
|
|
152
|
+
const regroupedViews = this.regroupViews(viewContainer.id, views);
|
|
153
|
+
this.deregisterGroupedViews(regroupedViews);
|
|
154
|
+
this.contextKeyService.bufferChangeEvents(() => {
|
|
155
|
+
views.forEach(viewDescriptor => this.getOrCreateMovableViewContextKey(viewDescriptor).set(false));
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
regroupViews(containerId, views) {
|
|
159
|
+
const viewsByContainer = ( new Map());
|
|
160
|
+
for (const viewDescriptor of views) {
|
|
161
|
+
const correctContainerId = this.viewDescriptorsCustomLocations.get(viewDescriptor.id) ?? containerId;
|
|
162
|
+
let containerViews = viewsByContainer.get(correctContainerId);
|
|
163
|
+
if (!containerViews) {
|
|
164
|
+
viewsByContainer.set(correctContainerId, containerViews = []);
|
|
165
|
+
}
|
|
166
|
+
containerViews.push(viewDescriptor);
|
|
167
|
+
}
|
|
168
|
+
return viewsByContainer;
|
|
169
|
+
}
|
|
170
|
+
getViewDescriptorById(viewId) {
|
|
171
|
+
return this.viewsRegistry.getView(viewId);
|
|
172
|
+
}
|
|
173
|
+
getViewLocationById(viewId) {
|
|
174
|
+
const container = this.getViewContainerByViewId(viewId);
|
|
175
|
+
if (container === null) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
return this.getViewContainerLocation(container);
|
|
179
|
+
}
|
|
180
|
+
getViewContainerByViewId(viewId) {
|
|
181
|
+
const containerId = this.viewDescriptorsCustomLocations.get(viewId);
|
|
182
|
+
return containerId ?
|
|
183
|
+
this.viewContainersRegistry.get(containerId) ?? null :
|
|
184
|
+
this.getDefaultContainerById(viewId);
|
|
185
|
+
}
|
|
186
|
+
getViewContainerLocation(viewContainer) {
|
|
187
|
+
return this.viewContainersCustomLocations.get(viewContainer.id) ?? this.getDefaultViewContainerLocation(viewContainer);
|
|
188
|
+
}
|
|
189
|
+
getDefaultViewContainerLocation(viewContainer) {
|
|
190
|
+
return this.viewContainersRegistry.getViewContainerLocation(viewContainer);
|
|
191
|
+
}
|
|
192
|
+
getDefaultContainerById(viewId) {
|
|
193
|
+
return this.viewsRegistry.getViewContainer(viewId) ?? null;
|
|
194
|
+
}
|
|
195
|
+
getViewContainerModel(container) {
|
|
196
|
+
return this.getOrRegisterViewContainerModel(container);
|
|
197
|
+
}
|
|
198
|
+
getViewContainerById(id) {
|
|
199
|
+
return this.viewContainersRegistry.get(id) || null;
|
|
200
|
+
}
|
|
201
|
+
getViewContainersByLocation(location) {
|
|
202
|
+
return this.viewContainers.filter(v => this.getViewContainerLocation(v) === location);
|
|
203
|
+
}
|
|
204
|
+
getDefaultViewContainer(location) {
|
|
205
|
+
return this.viewContainersRegistry.getDefaultViewContainer(location);
|
|
206
|
+
}
|
|
207
|
+
moveViewContainerToLocation(viewContainer, location, requestedIndex, reason) {
|
|
208
|
+
this.logger.info(`moveViewContainerToLocation: viewContainer:${viewContainer.id} location:${location} reason:${reason}`);
|
|
209
|
+
this.moveViewContainerToLocationWithoutSaving(viewContainer, location, requestedIndex);
|
|
210
|
+
this.saveViewCustomizations();
|
|
211
|
+
}
|
|
212
|
+
getViewContainerBadgeEnablementState(id) {
|
|
213
|
+
return this.viewContainerBadgeEnablementStates.get(id) ?? true;
|
|
214
|
+
}
|
|
215
|
+
setViewContainerBadgeEnablementState(id, badgesEnabled) {
|
|
216
|
+
this.viewContainerBadgeEnablementStates.set(id, badgesEnabled);
|
|
217
|
+
this.saveViewCustomizations();
|
|
218
|
+
}
|
|
219
|
+
moveViewToLocation(view, location, reason) {
|
|
220
|
+
this.logger.info(`moveViewToLocation: view:${view.id} location:${location} reason:${reason}`);
|
|
221
|
+
const container = this.registerGeneratedViewContainer(location);
|
|
222
|
+
this.moveViewsToContainer([view], container);
|
|
223
|
+
}
|
|
224
|
+
moveViewsToContainer(views, viewContainer, visibilityState, reason) {
|
|
225
|
+
if (!views.length) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
this.logger.info(`moveViewsToContainer: views:${( views.map(view => view.id)).join(',')} viewContainer:${viewContainer.id} reason:${reason}`);
|
|
229
|
+
const from = this.getViewContainerByViewId(views[0].id);
|
|
230
|
+
const to = viewContainer;
|
|
231
|
+
if (from && to && from !== to) {
|
|
232
|
+
this.moveViewsWithoutSaving(views, from, to, visibilityState);
|
|
233
|
+
this.cleanUpGeneratedViewContainer(from.id);
|
|
234
|
+
this.saveViewCustomizations();
|
|
235
|
+
this.reportMovedViews(views, from, to);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
reset() {
|
|
239
|
+
for (const viewContainer of this.viewContainers) {
|
|
240
|
+
const viewContainerModel = this.getViewContainerModel(viewContainer);
|
|
241
|
+
for (const viewDescriptor of viewContainerModel.allViewDescriptors) {
|
|
242
|
+
const defaultContainer = this.getDefaultContainerById(viewDescriptor.id);
|
|
243
|
+
const currentContainer = this.getViewContainerByViewId(viewDescriptor.id);
|
|
244
|
+
if (currentContainer && defaultContainer && currentContainer !== defaultContainer) {
|
|
245
|
+
this.moveViewsWithoutSaving([viewDescriptor], currentContainer, defaultContainer);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const defaultContainerLocation = this.getDefaultViewContainerLocation(viewContainer);
|
|
249
|
+
const currentContainerLocation = this.getViewContainerLocation(viewContainer);
|
|
250
|
+
if (defaultContainerLocation !== null && currentContainerLocation !== defaultContainerLocation) {
|
|
251
|
+
this.moveViewContainerToLocationWithoutSaving(viewContainer, defaultContainerLocation);
|
|
252
|
+
}
|
|
253
|
+
this.cleanUpGeneratedViewContainer(viewContainer.id);
|
|
254
|
+
}
|
|
255
|
+
this.viewContainersCustomLocations.clear();
|
|
256
|
+
this.viewDescriptorsCustomLocations.clear();
|
|
257
|
+
this.saveViewCustomizations();
|
|
258
|
+
}
|
|
259
|
+
isViewContainerRemovedPermanently(viewContainerId) {
|
|
260
|
+
return this.isGeneratedContainerId(viewContainerId) && !( this.viewContainersCustomLocations.has(viewContainerId));
|
|
261
|
+
}
|
|
262
|
+
onDidChangeDefaultContainer(views, from, to) {
|
|
263
|
+
const viewsToMove = views.filter(view => !( this.viewDescriptorsCustomLocations.has(view.id))
|
|
264
|
+
|| (!this.viewContainers.includes(from) && this.viewDescriptorsCustomLocations.get(view.id) === from.id)
|
|
265
|
+
);
|
|
266
|
+
if (viewsToMove.length) {
|
|
267
|
+
this.moveViewsWithoutSaving(viewsToMove, from, to);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
reportMovedViews(views, from, to) {
|
|
271
|
+
const containerToString = (container) => {
|
|
272
|
+
if (container.id.startsWith(ViewDescriptorService_1.COMMON_CONTAINER_ID_PREFIX)) {
|
|
273
|
+
return 'custom';
|
|
274
|
+
}
|
|
275
|
+
if (!container.extensionId) {
|
|
276
|
+
return container.id;
|
|
277
|
+
}
|
|
278
|
+
return 'extension';
|
|
279
|
+
};
|
|
280
|
+
const oldLocation = this.getViewContainerLocation(from);
|
|
281
|
+
const newLocation = this.getViewContainerLocation(to);
|
|
282
|
+
const viewCount = views.length;
|
|
283
|
+
const fromContainer = containerToString(from);
|
|
284
|
+
const toContainer = containerToString(to);
|
|
285
|
+
const fromLocation = oldLocation === 1 ? 'panel' : 'sidebar';
|
|
286
|
+
const toLocation = newLocation === 1 ? 'panel' : 'sidebar';
|
|
287
|
+
this.telemetryService.publicLog2('viewDescriptorService.moveViews', { viewCount, fromContainer, toContainer, fromLocation, toLocation });
|
|
288
|
+
}
|
|
289
|
+
moveViewsWithoutSaving(views, from, to, visibilityState = ViewVisibilityState.Expand) {
|
|
290
|
+
this.removeViews(from, views);
|
|
291
|
+
this.addViews(to, views, visibilityState);
|
|
292
|
+
const oldLocation = this.getViewContainerLocation(from);
|
|
293
|
+
const newLocation = this.getViewContainerLocation(to);
|
|
294
|
+
if (oldLocation !== newLocation) {
|
|
295
|
+
this._onDidChangeLocation.fire({ views, from: oldLocation, to: newLocation });
|
|
296
|
+
}
|
|
297
|
+
this._onDidChangeContainer.fire({ views, from, to });
|
|
298
|
+
}
|
|
299
|
+
moveViewContainerToLocationWithoutSaving(viewContainer, location, requestedIndex) {
|
|
300
|
+
const from = this.getViewContainerLocation(viewContainer);
|
|
301
|
+
const to = location;
|
|
302
|
+
if (from !== to) {
|
|
303
|
+
const isGeneratedViewContainer = this.isGeneratedContainerId(viewContainer.id);
|
|
304
|
+
const isDefaultViewContainerLocation = to === this.getDefaultViewContainerLocation(viewContainer);
|
|
305
|
+
if (isGeneratedViewContainer || !isDefaultViewContainerLocation) {
|
|
306
|
+
this.viewContainersCustomLocations.set(viewContainer.id, to);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
this.viewContainersCustomLocations.delete(viewContainer.id);
|
|
310
|
+
}
|
|
311
|
+
this.getOrCreateDefaultViewContainerLocationContextKey(viewContainer).set(isGeneratedViewContainer || isDefaultViewContainerLocation);
|
|
312
|
+
viewContainer.requestedIndex = requestedIndex;
|
|
313
|
+
this._onDidChangeContainerLocation.fire({ viewContainer, from, to });
|
|
314
|
+
const views = this.getViewsByContainer(viewContainer);
|
|
315
|
+
this._onDidChangeLocation.fire({ views, from, to });
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
cleanUpGeneratedViewContainer(viewContainerId) {
|
|
319
|
+
if (!this.isGeneratedContainerId(viewContainerId)) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const viewContainer = this.getViewContainerById(viewContainerId);
|
|
323
|
+
if (viewContainer && this.getViewContainerModel(viewContainer)?.allViewDescriptors.length) {
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
if ([...( this.viewDescriptorsCustomLocations.values())].includes(viewContainerId)) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
if (viewContainer) {
|
|
330
|
+
this.viewContainersRegistry.deregisterViewContainer(viewContainer);
|
|
331
|
+
}
|
|
332
|
+
this.viewContainersCustomLocations.delete(viewContainerId);
|
|
333
|
+
this.viewContainerBadgeEnablementStates.delete(viewContainerId);
|
|
334
|
+
this.storageService.remove(getViewsStateStorageId(viewContainer?.storageId || getViewContainerStorageId(viewContainerId)), 0 );
|
|
335
|
+
}
|
|
336
|
+
registerGeneratedViewContainer(location, existingId) {
|
|
337
|
+
const id = existingId || this.generateContainerId(location);
|
|
338
|
+
const container = this.viewContainersRegistry.registerViewContainer({
|
|
339
|
+
id,
|
|
340
|
+
ctorDescriptor: ( new SyncDescriptor(ViewPaneContainer, [id, { mergeViewWithContainerWhenSingleView: true }])),
|
|
341
|
+
title: { value: id, original: id },
|
|
342
|
+
icon: location === 0 ? defaultViewIcon : undefined,
|
|
343
|
+
storageId: getViewContainerStorageId(id),
|
|
344
|
+
hideIfEmpty: true
|
|
345
|
+
}, location, { doNotRegisterOpenCommand: true });
|
|
346
|
+
if (this.viewContainersCustomLocations.get(container.id) !== location) {
|
|
347
|
+
this.viewContainersCustomLocations.set(container.id, location);
|
|
348
|
+
}
|
|
349
|
+
this.getOrCreateDefaultViewContainerLocationContextKey(container).set(true);
|
|
350
|
+
return container;
|
|
351
|
+
}
|
|
352
|
+
onDidStorageChange() {
|
|
353
|
+
if (JSON.stringify(this.viewCustomizations) !== this.getStoredViewCustomizationsValue() ) {
|
|
354
|
+
this.onDidViewCustomizationsStorageChange();
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
onDidViewCustomizationsStorageChange() {
|
|
358
|
+
this._viewCustomizations = undefined;
|
|
359
|
+
const newViewContainerCustomizations = ( new Map(Object.entries(this.viewCustomizations.viewContainerLocations)));
|
|
360
|
+
const newViewDescriptorCustomizations = ( new Map(Object.entries(this.viewCustomizations.viewLocations)));
|
|
361
|
+
const viewContainersToMove = [];
|
|
362
|
+
const viewsToMove = [];
|
|
363
|
+
for (const [containerId, location] of newViewContainerCustomizations.entries()) {
|
|
364
|
+
const container = this.getViewContainerById(containerId);
|
|
365
|
+
if (container) {
|
|
366
|
+
if (location !== this.getViewContainerLocation(container)) {
|
|
367
|
+
viewContainersToMove.push([container, location]);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
else if (this.isGeneratedContainerId(containerId)) {
|
|
371
|
+
this.registerGeneratedViewContainer(location, containerId);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
for (const viewContainer of this.viewContainers) {
|
|
375
|
+
if (!( newViewContainerCustomizations.has(viewContainer.id))) {
|
|
376
|
+
const currentLocation = this.getViewContainerLocation(viewContainer);
|
|
377
|
+
const defaultLocation = this.getDefaultViewContainerLocation(viewContainer);
|
|
378
|
+
if (currentLocation !== defaultLocation) {
|
|
379
|
+
viewContainersToMove.push([viewContainer, defaultLocation]);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
for (const [viewId, viewContainerId] of newViewDescriptorCustomizations.entries()) {
|
|
384
|
+
const viewDescriptor = this.getViewDescriptorById(viewId);
|
|
385
|
+
if (viewDescriptor) {
|
|
386
|
+
const prevViewContainer = this.getViewContainerByViewId(viewId);
|
|
387
|
+
const newViewContainer = this.viewContainersRegistry.get(viewContainerId);
|
|
388
|
+
if (prevViewContainer && newViewContainer && newViewContainer !== prevViewContainer) {
|
|
389
|
+
viewsToMove.push({ views: [viewDescriptor], from: prevViewContainer, to: newViewContainer });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
for (const viewContainer of this.viewContainers) {
|
|
394
|
+
const viewContainerModel = this.getViewContainerModel(viewContainer);
|
|
395
|
+
for (const viewDescriptor of viewContainerModel.allViewDescriptors) {
|
|
396
|
+
if (!( newViewDescriptorCustomizations.has(viewDescriptor.id))) {
|
|
397
|
+
const currentContainer = this.getViewContainerByViewId(viewDescriptor.id);
|
|
398
|
+
const defaultContainer = this.getDefaultContainerById(viewDescriptor.id);
|
|
399
|
+
if (currentContainer && defaultContainer && currentContainer !== defaultContainer) {
|
|
400
|
+
viewsToMove.push({ views: [viewDescriptor], from: currentContainer, to: defaultContainer });
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
for (const [container, location] of viewContainersToMove) {
|
|
406
|
+
this.moveViewContainerToLocationWithoutSaving(container, location);
|
|
407
|
+
}
|
|
408
|
+
for (const { views, from, to } of viewsToMove) {
|
|
409
|
+
this.moveViewsWithoutSaving(views, from, to, ViewVisibilityState.Default);
|
|
410
|
+
}
|
|
411
|
+
this.viewContainersCustomLocations = newViewContainerCustomizations;
|
|
412
|
+
this.viewDescriptorsCustomLocations = newViewDescriptorCustomizations;
|
|
413
|
+
}
|
|
414
|
+
generateContainerId(location) {
|
|
415
|
+
return `${ViewDescriptorService_1.COMMON_CONTAINER_ID_PREFIX}.${ViewContainerLocationToString(location)}.${generateUuid()}`;
|
|
416
|
+
}
|
|
417
|
+
saveViewCustomizations() {
|
|
418
|
+
const viewCustomizations = { viewContainerLocations: {}, viewLocations: {}, viewContainerBadgeEnablementStates: {} };
|
|
419
|
+
for (const [containerId, location] of this.viewContainersCustomLocations) {
|
|
420
|
+
const container = this.getViewContainerById(containerId);
|
|
421
|
+
if (container && !this.isGeneratedContainerId(containerId) && location === this.getDefaultViewContainerLocation(container)) {
|
|
422
|
+
continue;
|
|
423
|
+
}
|
|
424
|
+
viewCustomizations.viewContainerLocations[containerId] = location;
|
|
425
|
+
}
|
|
426
|
+
for (const [viewId, viewContainerId] of this.viewDescriptorsCustomLocations) {
|
|
427
|
+
const viewContainer = this.getViewContainerById(viewContainerId);
|
|
428
|
+
if (viewContainer) {
|
|
429
|
+
const defaultContainer = this.getDefaultContainerById(viewId);
|
|
430
|
+
if (defaultContainer?.id === viewContainer.id) {
|
|
431
|
+
continue;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
viewCustomizations.viewLocations[viewId] = viewContainerId;
|
|
435
|
+
}
|
|
436
|
+
for (const [viewContainerId, badgeEnablementState] of this.viewContainerBadgeEnablementStates) {
|
|
437
|
+
if (badgeEnablementState === false) {
|
|
438
|
+
viewCustomizations.viewContainerBadgeEnablementStates[viewContainerId] = badgeEnablementState;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
this.viewCustomizations = viewCustomizations;
|
|
442
|
+
}
|
|
443
|
+
get viewCustomizations() {
|
|
444
|
+
if (!this._viewCustomizations) {
|
|
445
|
+
this._viewCustomizations = JSON.parse(this.getStoredViewCustomizationsValue());
|
|
446
|
+
this._viewCustomizations.viewContainerLocations = this._viewCustomizations.viewContainerLocations ?? {};
|
|
447
|
+
this._viewCustomizations.viewLocations = this._viewCustomizations.viewLocations ?? {};
|
|
448
|
+
this._viewCustomizations.viewContainerBadgeEnablementStates = this._viewCustomizations.viewContainerBadgeEnablementStates ?? {};
|
|
449
|
+
}
|
|
450
|
+
return this._viewCustomizations;
|
|
451
|
+
}
|
|
452
|
+
set viewCustomizations(viewCustomizations) {
|
|
453
|
+
const value = JSON.stringify(viewCustomizations);
|
|
454
|
+
if (JSON.stringify(this.viewCustomizations) !== value) {
|
|
455
|
+
this._viewCustomizations = viewCustomizations;
|
|
456
|
+
this.setStoredViewCustomizationsValue(value);
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
getStoredViewCustomizationsValue() {
|
|
460
|
+
return this.storageService.get(ViewDescriptorService_1.VIEWS_CUSTOMIZATIONS, 0 , '{}');
|
|
461
|
+
}
|
|
462
|
+
setStoredViewCustomizationsValue(value) {
|
|
463
|
+
this.storageService.store(ViewDescriptorService_1.VIEWS_CUSTOMIZATIONS, value, 0 , 0 );
|
|
464
|
+
}
|
|
465
|
+
getViewsByContainer(viewContainer) {
|
|
466
|
+
const result = this.viewsRegistry.getViews(viewContainer).filter(viewDescriptor => {
|
|
467
|
+
const viewDescriptorViewContainerId = this.viewDescriptorsCustomLocations.get(viewDescriptor.id) ?? viewContainer.id;
|
|
468
|
+
return viewDescriptorViewContainerId === viewContainer.id;
|
|
469
|
+
});
|
|
470
|
+
for (const [viewId, viewContainerId] of this.viewDescriptorsCustomLocations.entries()) {
|
|
471
|
+
if (viewContainerId !== viewContainer.id) {
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
if (this.viewsRegistry.getViewContainer(viewId) === viewContainer) {
|
|
475
|
+
continue;
|
|
476
|
+
}
|
|
477
|
+
const viewDescriptor = this.getViewDescriptorById(viewId);
|
|
478
|
+
if (viewDescriptor) {
|
|
479
|
+
result.push(viewDescriptor);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return result;
|
|
483
|
+
}
|
|
484
|
+
onDidRegisterViewContainer(viewContainer) {
|
|
485
|
+
const defaultLocation = this.isGeneratedContainerId(viewContainer.id) ? true : this.getViewContainerLocation(viewContainer) === this.getDefaultViewContainerLocation(viewContainer);
|
|
486
|
+
this.getOrCreateDefaultViewContainerLocationContextKey(viewContainer).set(defaultLocation);
|
|
487
|
+
this.getOrRegisterViewContainerModel(viewContainer);
|
|
488
|
+
}
|
|
489
|
+
getOrRegisterViewContainerModel(viewContainer) {
|
|
490
|
+
let viewContainerModel = this.viewContainerModels.get(viewContainer)?.viewContainerModel;
|
|
491
|
+
if (!viewContainerModel) {
|
|
492
|
+
const disposables = ( new DisposableStore());
|
|
493
|
+
viewContainerModel = disposables.add(this.instantiationService.createInstance(ViewContainerModel, viewContainer));
|
|
494
|
+
this.onDidChangeActiveViews({ added: viewContainerModel.activeViewDescriptors, removed: [] });
|
|
495
|
+
viewContainerModel.onDidChangeActiveViewDescriptors(changed => this.onDidChangeActiveViews(changed), this, disposables);
|
|
496
|
+
this.onDidChangeVisibleViews({ added: [...viewContainerModel.visibleViewDescriptors], removed: [] });
|
|
497
|
+
viewContainerModel.onDidAddVisibleViewDescriptors(added => this.onDidChangeVisibleViews({ added: ( added.map(({ viewDescriptor }) => viewDescriptor)), removed: [] }), this, disposables);
|
|
498
|
+
viewContainerModel.onDidRemoveVisibleViewDescriptors(removed => this.onDidChangeVisibleViews({ added: [], removed: ( removed.map(({ viewDescriptor }) => viewDescriptor)) }), this, disposables);
|
|
499
|
+
disposables.add(toDisposable(() => this.viewsVisibilityActionDisposables.deleteAndDispose(viewContainer)));
|
|
500
|
+
disposables.add(this.registerResetViewContainerAction(viewContainer));
|
|
501
|
+
const value = { viewContainerModel: viewContainerModel, disposables, dispose: () => disposables.dispose() };
|
|
502
|
+
this.viewContainerModels.set(viewContainer, value);
|
|
503
|
+
this.onDidRegisterViews([{ views: this.viewsRegistry.getViews(viewContainer), viewContainer }]);
|
|
504
|
+
const viewsToRegister = this.getViewsByContainer(viewContainer).filter(view => this.getDefaultContainerById(view.id) !== viewContainer);
|
|
505
|
+
if (viewsToRegister.length) {
|
|
506
|
+
this.addViews(viewContainer, viewsToRegister);
|
|
507
|
+
this.contextKeyService.bufferChangeEvents(() => {
|
|
508
|
+
viewsToRegister.forEach(viewDescriptor => this.getOrCreateMovableViewContextKey(viewDescriptor).set(!!viewDescriptor.canMoveView));
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
if (this.canRegisterViewsVisibilityActions) {
|
|
512
|
+
this.registerViewsVisibilityActions(viewContainer, value);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return viewContainerModel;
|
|
516
|
+
}
|
|
517
|
+
onDidDeregisterViewContainer(viewContainer) {
|
|
518
|
+
this.viewContainerModels.deleteAndDispose(viewContainer);
|
|
519
|
+
this.viewsVisibilityActionDisposables.deleteAndDispose(viewContainer);
|
|
520
|
+
}
|
|
521
|
+
onDidChangeActiveViews({ added, removed }) {
|
|
522
|
+
this.contextKeyService.bufferChangeEvents(() => {
|
|
523
|
+
added.forEach(viewDescriptor => this.getOrCreateActiveViewContextKey(viewDescriptor).set(true));
|
|
524
|
+
removed.forEach(viewDescriptor => this.getOrCreateActiveViewContextKey(viewDescriptor).set(false));
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
onDidChangeVisibleViews({ added, removed }) {
|
|
528
|
+
this.contextKeyService.bufferChangeEvents(() => {
|
|
529
|
+
added.forEach(viewDescriptor => this.getOrCreateVisibleViewContextKey(viewDescriptor).set(true));
|
|
530
|
+
removed.forEach(viewDescriptor => this.getOrCreateVisibleViewContextKey(viewDescriptor).set(false));
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
registerViewsVisibilityActions(viewContainer, { viewContainerModel, disposables }) {
|
|
534
|
+
this.viewsVisibilityActionDisposables.deleteAndDispose(viewContainer);
|
|
535
|
+
this.viewsVisibilityActionDisposables.set(viewContainer, this.registerViewsVisibilityActionsForContainer(viewContainerModel));
|
|
536
|
+
disposables.add(Event.any(viewContainerModel.onDidChangeActiveViewDescriptors, viewContainerModel.onDidAddVisibleViewDescriptors, viewContainerModel.onDidRemoveVisibleViewDescriptors, viewContainerModel.onDidMoveVisibleViewDescriptors)(e => {
|
|
537
|
+
this.viewsVisibilityActionDisposables.deleteAndDispose(viewContainer);
|
|
538
|
+
this.viewsVisibilityActionDisposables.set(viewContainer, this.registerViewsVisibilityActionsForContainer(viewContainerModel));
|
|
539
|
+
}));
|
|
540
|
+
}
|
|
541
|
+
registerViewsVisibilityActionsForContainer(viewContainerModel) {
|
|
542
|
+
const disposables = ( new DisposableStore());
|
|
543
|
+
viewContainerModel.activeViewDescriptors.forEach((viewDescriptor, index) => {
|
|
544
|
+
if (!viewDescriptor.remoteAuthority) {
|
|
545
|
+
disposables.add(registerAction2(class extends ViewPaneContainerAction {
|
|
546
|
+
constructor() {
|
|
547
|
+
super({
|
|
548
|
+
id: `${viewDescriptor.id}.toggleVisibility`,
|
|
549
|
+
viewPaneContainerId: viewContainerModel.viewContainer.id,
|
|
550
|
+
precondition: viewDescriptor.canToggleVisibility && (!viewContainerModel.isVisible(viewDescriptor.id) || viewContainerModel.visibleViewDescriptors.length > 1) ? ContextKeyExpr.true() : ( ContextKeyExpr.false()),
|
|
551
|
+
toggled: ( ContextKeyExpr.has(`${viewDescriptor.id}.visible`)),
|
|
552
|
+
title: viewDescriptor.name,
|
|
553
|
+
menu: [{
|
|
554
|
+
id: ViewsSubMenu,
|
|
555
|
+
when: ( ContextKeyExpr.equals('viewContainer', viewContainerModel.viewContainer.id)),
|
|
556
|
+
order: index,
|
|
557
|
+
}, {
|
|
558
|
+
id: MenuId.ViewContainerTitleContext,
|
|
559
|
+
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('viewContainer', viewContainerModel.viewContainer.id)))),
|
|
560
|
+
order: index,
|
|
561
|
+
group: '1_toggleVisibility'
|
|
562
|
+
}, {
|
|
563
|
+
id: MenuId.ViewTitleContext,
|
|
564
|
+
when: ( ContextKeyExpr.and(( ContextKeyExpr.or(...( viewContainerModel.visibleViewDescriptors.map(v => ( ContextKeyExpr.equals('view', v.id)))))))),
|
|
565
|
+
order: index,
|
|
566
|
+
group: '2_toggleVisibility'
|
|
567
|
+
}]
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
async runInViewPaneContainer(serviceAccessor, viewPaneContainer) {
|
|
571
|
+
viewPaneContainer.toggleViewVisibility(viewDescriptor.id);
|
|
572
|
+
}
|
|
573
|
+
}));
|
|
574
|
+
disposables.add(registerAction2(class extends ViewPaneContainerAction {
|
|
575
|
+
constructor() {
|
|
576
|
+
super({
|
|
577
|
+
id: `${viewDescriptor.id}.removeView`,
|
|
578
|
+
viewPaneContainerId: viewContainerModel.viewContainer.id,
|
|
579
|
+
title: ( localizeWithPath(
|
|
580
|
+
'vs/workbench/services/views/browser/viewDescriptorService',
|
|
581
|
+
'hideView',
|
|
582
|
+
"Hide '{0}'",
|
|
583
|
+
viewDescriptor.name.value
|
|
584
|
+
)),
|
|
585
|
+
precondition: viewDescriptor.canToggleVisibility && (!viewContainerModel.isVisible(viewDescriptor.id) || viewContainerModel.visibleViewDescriptors.length > 1) ? ContextKeyExpr.true() : ( ContextKeyExpr.false()),
|
|
586
|
+
menu: [{
|
|
587
|
+
id: MenuId.ViewTitleContext,
|
|
588
|
+
when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', viewDescriptor.id)), ( ContextKeyExpr.has(`${viewDescriptor.id}.visible`)))),
|
|
589
|
+
group: '1_hide',
|
|
590
|
+
order: 1
|
|
591
|
+
}]
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
async runInViewPaneContainer(serviceAccessor, viewPaneContainer) {
|
|
595
|
+
viewPaneContainer.toggleViewVisibility(viewDescriptor.id);
|
|
596
|
+
}
|
|
597
|
+
}));
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
return disposables;
|
|
601
|
+
}
|
|
602
|
+
registerResetViewContainerAction(viewContainer) {
|
|
603
|
+
const that = this;
|
|
604
|
+
return registerAction2(class ResetViewLocationAction extends Action2 {
|
|
605
|
+
constructor() {
|
|
606
|
+
super({
|
|
607
|
+
id: `${viewContainer.id}.resetViewContainerLocation`,
|
|
608
|
+
title: ( localize2WithPath(
|
|
609
|
+
'vs/workbench/services/views/browser/viewDescriptorService',
|
|
610
|
+
'resetViewLocation',
|
|
611
|
+
"Reset Location"
|
|
612
|
+
)),
|
|
613
|
+
menu: [{
|
|
614
|
+
id: MenuId.ViewContainerTitleContext,
|
|
615
|
+
when: ( ContextKeyExpr.or(( ContextKeyExpr.and(( ContextKeyExpr.equals('viewContainer', viewContainer.id)), ( ContextKeyExpr.equals(`${viewContainer.id}.defaultViewContainerLocation`, false))))))
|
|
616
|
+
}],
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
run() {
|
|
620
|
+
that.moveViewContainerToLocation(viewContainer, that.getDefaultViewContainerLocation(viewContainer), undefined, this.desc.id);
|
|
621
|
+
}
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
addViews(container, views, visibilityState = ViewVisibilityState.Default) {
|
|
625
|
+
this.contextKeyService.bufferChangeEvents(() => {
|
|
626
|
+
views.forEach(view => {
|
|
627
|
+
const isDefaultContainer = this.getDefaultContainerById(view.id) === container;
|
|
628
|
+
this.getOrCreateDefaultViewLocationContextKey(view).set(isDefaultContainer);
|
|
629
|
+
if (isDefaultContainer) {
|
|
630
|
+
this.viewDescriptorsCustomLocations.delete(view.id);
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
this.viewDescriptorsCustomLocations.set(view.id, container.id);
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
});
|
|
637
|
+
this.getViewContainerModel(container).add(( views.map(view => {
|
|
638
|
+
return {
|
|
639
|
+
viewDescriptor: view,
|
|
640
|
+
collapsed: visibilityState === ViewVisibilityState.Default ? undefined : false,
|
|
641
|
+
visible: visibilityState === ViewVisibilityState.Default ? undefined : true
|
|
642
|
+
};
|
|
643
|
+
})));
|
|
644
|
+
}
|
|
645
|
+
removeViews(container, views) {
|
|
646
|
+
this.contextKeyService.bufferChangeEvents(() => {
|
|
647
|
+
views.forEach(view => {
|
|
648
|
+
if (this.viewDescriptorsCustomLocations.get(view.id) === container.id) {
|
|
649
|
+
this.viewDescriptorsCustomLocations.delete(view.id);
|
|
650
|
+
}
|
|
651
|
+
this.getOrCreateDefaultViewLocationContextKey(view).set(false);
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
this.getViewContainerModel(container).remove(views);
|
|
655
|
+
}
|
|
656
|
+
getOrCreateActiveViewContextKey(viewDescriptor) {
|
|
657
|
+
const activeContextKeyId = `${viewDescriptor.id}.active`;
|
|
658
|
+
let contextKey = this.activeViewContextKeys.get(activeContextKeyId);
|
|
659
|
+
if (!contextKey) {
|
|
660
|
+
contextKey = ( new RawContextKey(activeContextKeyId, false)).bindTo(this.contextKeyService);
|
|
661
|
+
this.activeViewContextKeys.set(activeContextKeyId, contextKey);
|
|
662
|
+
}
|
|
663
|
+
return contextKey;
|
|
664
|
+
}
|
|
665
|
+
getOrCreateVisibleViewContextKey(viewDescriptor) {
|
|
666
|
+
const activeContextKeyId = `${viewDescriptor.id}.visible`;
|
|
667
|
+
let contextKey = this.activeViewContextKeys.get(activeContextKeyId);
|
|
668
|
+
if (!contextKey) {
|
|
669
|
+
contextKey = ( new RawContextKey(activeContextKeyId, false)).bindTo(this.contextKeyService);
|
|
670
|
+
this.activeViewContextKeys.set(activeContextKeyId, contextKey);
|
|
671
|
+
}
|
|
672
|
+
return contextKey;
|
|
673
|
+
}
|
|
674
|
+
getOrCreateMovableViewContextKey(viewDescriptor) {
|
|
675
|
+
const movableViewContextKeyId = `${viewDescriptor.id}.canMove`;
|
|
676
|
+
let contextKey = this.movableViewContextKeys.get(movableViewContextKeyId);
|
|
677
|
+
if (!contextKey) {
|
|
678
|
+
contextKey = ( new RawContextKey(movableViewContextKeyId, false)).bindTo(this.contextKeyService);
|
|
679
|
+
this.movableViewContextKeys.set(movableViewContextKeyId, contextKey);
|
|
680
|
+
}
|
|
681
|
+
return contextKey;
|
|
682
|
+
}
|
|
683
|
+
getOrCreateDefaultViewLocationContextKey(viewDescriptor) {
|
|
684
|
+
const defaultViewLocationContextKeyId = `${viewDescriptor.id}.defaultViewLocation`;
|
|
685
|
+
let contextKey = this.defaultViewLocationContextKeys.get(defaultViewLocationContextKeyId);
|
|
686
|
+
if (!contextKey) {
|
|
687
|
+
contextKey = ( new RawContextKey(defaultViewLocationContextKeyId, false)).bindTo(this.contextKeyService);
|
|
688
|
+
this.defaultViewLocationContextKeys.set(defaultViewLocationContextKeyId, contextKey);
|
|
689
|
+
}
|
|
690
|
+
return contextKey;
|
|
691
|
+
}
|
|
692
|
+
getOrCreateDefaultViewContainerLocationContextKey(viewContainer) {
|
|
693
|
+
const defaultViewContainerLocationContextKeyId = `${viewContainer.id}.defaultViewContainerLocation`;
|
|
694
|
+
let contextKey = this.defaultViewContainerLocationContextKeys.get(defaultViewContainerLocationContextKeyId);
|
|
695
|
+
if (!contextKey) {
|
|
696
|
+
contextKey = ( new RawContextKey(defaultViewContainerLocationContextKeyId, false)).bindTo(this.contextKeyService);
|
|
697
|
+
this.defaultViewContainerLocationContextKeys.set(defaultViewContainerLocationContextKeyId, contextKey);
|
|
698
|
+
}
|
|
699
|
+
return contextKey;
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
ViewDescriptorService = ViewDescriptorService_1 = ( __decorate([
|
|
703
|
+
( __param(0, IInstantiationService)),
|
|
704
|
+
( __param(1, IContextKeyService)),
|
|
705
|
+
( __param(2, IStorageService)),
|
|
706
|
+
( __param(3, IExtensionService)),
|
|
707
|
+
( __param(4, ITelemetryService)),
|
|
708
|
+
( __param(5, ILoggerService))
|
|
709
|
+
], ViewDescriptorService));
|
|
710
|
+
|
|
711
|
+
export { ViewDescriptorService };
|