@codingame/monaco-vscode-user-data-profile-service-override 5.3.0 → 6.0.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/package.json +2 -2
- package/vscode/src/vs/platform/userDataProfile/common/userDataProfileStorageService.js +7 -9
- package/vscode/src/vs/platform/userDataSync/common/extensionsSync.js +21 -20
- package/vscode/src/vs/platform/userDataSync/common/globalStateSync.js +26 -25
- package/vscode/src/vs/platform/userDataSync/common/keybindingsSync.js +26 -25
- package/vscode/src/vs/platform/userDataSync/common/settingsSync.js +20 -18
- package/vscode/src/vs/platform/userDataSync/common/snippetsSync.js +40 -40
- package/vscode/src/vs/platform/userDataSync/common/tasksSync.js +14 -14
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/media/userDataProfilesEditor.css.js +6 -0
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.contribution.js +4 -3
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfile.js +91 -25
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfilesEditor.js +943 -0
- package/vscode/src/vs/workbench/contrib/userDataProfile/browser/userDataProfilesEditorModel.js +481 -0
- package/vscode/src/vs/workbench/services/userData/browser/userDataInit.js +2 -1
- package/vscode/src/vs/workbench/services/userDataProfile/browser/extensionsResource.js +14 -8
- package/vscode/src/vs/workbench/services/userDataProfile/browser/globalStateResource.js +10 -8
- package/vscode/src/vs/workbench/services/userDataProfile/browser/keybindingsResource.js +5 -4
- package/vscode/src/vs/workbench/services/userDataProfile/browser/settingsResource.js +7 -6
- package/vscode/src/vs/workbench/services/userDataProfile/browser/snippetsResource.js +4 -3
- package/vscode/src/vs/workbench/services/userDataProfile/browser/tasksResource.js +5 -4
- package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileImportExportService.js +119 -70
- package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileInit.js +9 -7
- package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileManagement.js +1 -0
- package/vscode/src/vs/workbench/services/userDataProfile/browser/userDataProfileStorageService.js +4 -3
- package/vscode/src/vs/workbench/services/userDataSync/browser/userDataSyncInit.js +15 -13
|
@@ -0,0 +1,943 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import './media/userDataProfilesEditor.css.js';
|
|
3
|
+
import { append, $, Dimension, trackFocus, addDisposableListener, EventType, EventHelper } from 'vscode/vscode/vs/base/browser/dom';
|
|
4
|
+
import { SubmenuAction, Action, Separator } from 'vscode/vscode/vs/base/common/actions';
|
|
5
|
+
import { Event } from 'vscode/vscode/vs/base/common/event';
|
|
6
|
+
import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
|
|
7
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
8
|
+
import { IContextMenuService, IContextViewService } from 'vscode/vscode/vs/platform/contextview/browser/contextView.service';
|
|
9
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
10
|
+
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
11
|
+
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
12
|
+
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService.service';
|
|
13
|
+
import { ProfileResourceType } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile';
|
|
14
|
+
import { IUserDataProfilesService } from 'vscode/vscode/vs/platform/userDataProfile/common/userDataProfile.service';
|
|
15
|
+
import { EditorPane } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorPane';
|
|
16
|
+
import { EditorInput } from 'vscode/vscode/vs/workbench/common/editor/editorInput';
|
|
17
|
+
import { PROFILE_FILTER, defaultUserDataProfileIcon } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile';
|
|
18
|
+
import { IUserDataProfileManagementService } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfile.service';
|
|
19
|
+
import { SplitView, Sizing } from 'vscode/vscode/vs/base/browser/ui/splitview/splitview';
|
|
20
|
+
import { ButtonWithDropdown, Button } from 'vscode/vscode/vs/base/browser/ui/button/button';
|
|
21
|
+
import { defaultButtonStyles, defaultInputBoxStyles, defaultSelectBoxStyles, defaultCheckboxStyles } from 'vscode/vscode/vs/platform/theme/browser/defaultStyles';
|
|
22
|
+
import { registerColor } from 'vscode/vscode/vs/platform/theme/common/colorUtils';
|
|
23
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/baseColors';
|
|
24
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/chartsColors';
|
|
25
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/editorColors';
|
|
26
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/inputColors';
|
|
27
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/listColors';
|
|
28
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/menuColors';
|
|
29
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/minimapColors';
|
|
30
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/miscColors';
|
|
31
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/quickpickColors';
|
|
32
|
+
import 'vscode/vscode/vs/platform/theme/common/colors/searchColors';
|
|
33
|
+
import { PANEL_BORDER } from 'vscode/vscode/vs/workbench/common/theme';
|
|
34
|
+
import { WorkbenchObjectTree, WorkbenchAsyncDataTree } from 'vscode/vscode/vs/platform/list/browser/listService';
|
|
35
|
+
import { ObjectTreeElementCollapseState } from 'vscode/vscode/vs/base/browser/ui/tree/tree';
|
|
36
|
+
import { DisposableStore, Disposable, MutableDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
37
|
+
import { InputBox, MessageType } from 'vscode/vscode/vs/base/browser/ui/inputbox/inputBox';
|
|
38
|
+
import { Checkbox } from 'vscode/vscode/vs/base/browser/ui/toggle/toggle';
|
|
39
|
+
import { DEFAULT_ICON, ICONS } from 'vscode/vscode/vs/workbench/services/userDataProfile/common/userDataProfileIcons';
|
|
40
|
+
import { WorkbenchIconSelectBox } from 'vscode/vscode/vs/workbench/services/userDataProfile/browser/iconSelectBox';
|
|
41
|
+
import { StandardKeyboardEvent } from 'vscode/vscode/vs/base/browser/keyboardEvent';
|
|
42
|
+
import { KeyCode } from 'vscode/vscode/vs/base/common/keyCodes';
|
|
43
|
+
import { WorkbenchHoverDelegate } from 'vscode/vscode/vs/platform/hover/browser/hover';
|
|
44
|
+
import { IHoverService } from 'vscode/vscode/vs/platform/hover/browser/hover.service';
|
|
45
|
+
import { HoverPosition } from 'vscode/vscode/vs/base/browser/ui/hover/hoverWidget';
|
|
46
|
+
import { SelectBox } from 'vscode/vscode/vs/base/browser/ui/selectBox/selectBox';
|
|
47
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
48
|
+
import { IEditorProgressService } from 'vscode/vscode/vs/platform/progress/common/progress.service';
|
|
49
|
+
import { ExtensionsResourceTreeItem } from '../../../services/userDataProfile/browser/extensionsResource.js';
|
|
50
|
+
import { isString, isUndefined } from 'vscode/vscode/vs/base/common/types';
|
|
51
|
+
import { basename } from 'vscode/vscode/vs/base/common/resources';
|
|
52
|
+
import { RenderIndentGuides } from 'vscode/vscode/vs/base/browser/ui/tree/abstractTree';
|
|
53
|
+
import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
|
|
54
|
+
import { API_OPEN_EDITOR_COMMAND_ID } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorCommands';
|
|
55
|
+
import { SIDE_GROUP } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
56
|
+
import { ResourceLabels, DEFAULT_LABELS_CONTAINER } from 'vscode/vscode/vs/workbench/browser/labels';
|
|
57
|
+
import { IDialogService, IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
|
|
58
|
+
import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
|
|
59
|
+
import { UserDataProfileElement, AbstractUserDataProfileElement, NewProfileElement, UserDataProfilesEditorModel } from './userDataProfilesEditorModel.js';
|
|
60
|
+
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
61
|
+
import { WorkbenchToolBar } from 'vscode/vscode/vs/platform/actions/browser/toolbar';
|
|
62
|
+
import { createInstantHoverDelegate } from 'vscode/vscode/vs/base/browser/ui/hover/hoverDelegateFactory';
|
|
63
|
+
import { Orientation } from 'vscode/vscode/vs/base/browser/ui/sash/sash';
|
|
64
|
+
|
|
65
|
+
var UserDataProfilesEditor_1, NewProfileResourceTreeRenderer_1, ProfileResourceChildTreeItemRenderer_1, UserDataProfilesEditorInput_1;
|
|
66
|
+
const _moduleId = "vs/workbench/contrib/userDataProfile/browser/userDataProfilesEditor";
|
|
67
|
+
const profilesSashBorder = registerColor('profiles.sashBorder', { dark: PANEL_BORDER, light: PANEL_BORDER, hcDark: PANEL_BORDER, hcLight: PANEL_BORDER }, ( localizeWithPath(_moduleId, 0, "The color of the Profiles editor splitview sash border.")));
|
|
68
|
+
let UserDataProfilesEditor = class UserDataProfilesEditor extends EditorPane {
|
|
69
|
+
static { UserDataProfilesEditor_1 = this; }
|
|
70
|
+
static { this.ID = 'workbench.editor.userDataProfiles'; }
|
|
71
|
+
constructor(group, telemetryService, themeService, storageService, userDataProfileManagementService, quickInputService, dialogService, fileDialogService, contextMenuService, instantiationService) {
|
|
72
|
+
super(UserDataProfilesEditor_1.ID, group, telemetryService, themeService, storageService);
|
|
73
|
+
this.userDataProfileManagementService = userDataProfileManagementService;
|
|
74
|
+
this.quickInputService = quickInputService;
|
|
75
|
+
this.dialogService = dialogService;
|
|
76
|
+
this.fileDialogService = fileDialogService;
|
|
77
|
+
this.contextMenuService = contextMenuService;
|
|
78
|
+
this.instantiationService = instantiationService;
|
|
79
|
+
this.templates = [];
|
|
80
|
+
}
|
|
81
|
+
layout(dimension, position) {
|
|
82
|
+
if (this.container && this.splitView) {
|
|
83
|
+
const height = dimension.height - 20;
|
|
84
|
+
this.splitView.layout(this.container?.clientWidth, height);
|
|
85
|
+
this.splitView.el.style.height = `${height}px`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
createEditor(parent) {
|
|
89
|
+
this.container = append(parent, $('.profiles-editor'));
|
|
90
|
+
const sidebarView = append(this.container, $('.sidebar-view'));
|
|
91
|
+
const sidebarContainer = append(sidebarView, $('.sidebar-container'));
|
|
92
|
+
const contentsView = append(this.container, $('.contents-view'));
|
|
93
|
+
const contentsContainer = append(contentsView, $('.contents-container'));
|
|
94
|
+
this.profileWidget = this._register(this.instantiationService.createInstance(ProfileWidget, contentsContainer));
|
|
95
|
+
this.splitView = ( (new SplitView(this.container, {
|
|
96
|
+
orientation: Orientation.HORIZONTAL,
|
|
97
|
+
proportionalLayout: true
|
|
98
|
+
})));
|
|
99
|
+
this.renderSidebar(sidebarContainer);
|
|
100
|
+
this.splitView.addView({
|
|
101
|
+
onDidChange: Event.None,
|
|
102
|
+
element: sidebarView,
|
|
103
|
+
minimumSize: 175,
|
|
104
|
+
maximumSize: 350,
|
|
105
|
+
layout: (width, _, height) => {
|
|
106
|
+
sidebarView.style.width = `${width}px`;
|
|
107
|
+
if (height && this.profilesTree) {
|
|
108
|
+
this.profilesTree.getHTMLElement().style.height = `${height - 38}px`;
|
|
109
|
+
this.profilesTree.layout(height - 38, width);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, 300, undefined, true);
|
|
113
|
+
this.splitView.addView({
|
|
114
|
+
onDidChange: Event.None,
|
|
115
|
+
element: contentsView,
|
|
116
|
+
minimumSize: 500,
|
|
117
|
+
maximumSize: Number.POSITIVE_INFINITY,
|
|
118
|
+
layout: (width, _, height) => {
|
|
119
|
+
contentsView.style.width = `${width}px`;
|
|
120
|
+
if (height) {
|
|
121
|
+
this.profileWidget?.layout(( (new Dimension(width, height))));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, Sizing.Distribute, undefined, true);
|
|
125
|
+
const borderColor = this.theme.getColor(profilesSashBorder);
|
|
126
|
+
this.splitView.style({ separatorBorder: borderColor });
|
|
127
|
+
this.registerListeners();
|
|
128
|
+
this.userDataProfileManagementService.getBuiltinProfileTemplates().then(templates => {
|
|
129
|
+
this.templates = templates;
|
|
130
|
+
this.profileWidget.templates = templates;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
renderSidebar(parent) {
|
|
134
|
+
this.renderNewProfileButton(append(parent, $('.new-profile-button')));
|
|
135
|
+
const renderer = this.instantiationService.createInstance(ProfileTreeElementRenderer);
|
|
136
|
+
const delegate = ( (new ProfileTreeElementDelegate()));
|
|
137
|
+
this.profilesTree = this._register(this.instantiationService.createInstance((WorkbenchObjectTree), 'ProfilesTree', append(parent, $('.profiles-tree')), delegate, [renderer], {
|
|
138
|
+
multipleSelectionSupport: false,
|
|
139
|
+
setRowLineHeight: false,
|
|
140
|
+
horizontalScrolling: false,
|
|
141
|
+
accessibilityProvider: {
|
|
142
|
+
getAriaLabel(extensionFeature) {
|
|
143
|
+
return extensionFeature?.name ?? '';
|
|
144
|
+
},
|
|
145
|
+
getWidgetAriaLabel() {
|
|
146
|
+
return ( localizeWithPath(_moduleId, 1, "Profiles"));
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
openOnSingleClick: true,
|
|
150
|
+
enableStickyScroll: false,
|
|
151
|
+
identityProvider: {
|
|
152
|
+
getId(e) {
|
|
153
|
+
if (e instanceof UserDataProfileElement) {
|
|
154
|
+
return e.profile.id;
|
|
155
|
+
}
|
|
156
|
+
return e.name;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
161
|
+
renderNewProfileButton(parent) {
|
|
162
|
+
const button = this._register(( (new ButtonWithDropdown(parent, {
|
|
163
|
+
actions: {
|
|
164
|
+
getActions: () => {
|
|
165
|
+
const actions = [];
|
|
166
|
+
if (this.templates.length) {
|
|
167
|
+
actions.push(( (new SubmenuAction('from.template', ( localizeWithPath(_moduleId, 2, "From Template")), (this.templates.map(
|
|
168
|
+
template => ( (new Action(`template:${template.url}`, template.name, undefined, true, async () => {
|
|
169
|
+
this.createNewProfile(( (URI.parse(template.url))));
|
|
170
|
+
})))
|
|
171
|
+
))))));
|
|
172
|
+
actions.push(( (new Separator())));
|
|
173
|
+
}
|
|
174
|
+
actions.push(( (new Action('importProfile', ( localizeWithPath(_moduleId, 3, "Import Profile...")), undefined, true, () => this.importProfile()))));
|
|
175
|
+
return actions;
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
addPrimaryActionToDropdown: false,
|
|
179
|
+
contextMenuProvider: this.contextMenuService,
|
|
180
|
+
supportIcons: true,
|
|
181
|
+
...defaultButtonStyles
|
|
182
|
+
}))));
|
|
183
|
+
button.label = `$(add) ${( localizeWithPath(_moduleId, 4, "New Profile"))}`;
|
|
184
|
+
this._register(button.onDidClick(e => this.createNewProfile()));
|
|
185
|
+
}
|
|
186
|
+
registerListeners() {
|
|
187
|
+
if (this.profilesTree) {
|
|
188
|
+
this._register(this.profilesTree.onDidChangeSelection(e => {
|
|
189
|
+
const [element] = e.elements;
|
|
190
|
+
if (element instanceof AbstractUserDataProfileElement) {
|
|
191
|
+
this.profileWidget?.render(element);
|
|
192
|
+
}
|
|
193
|
+
}));
|
|
194
|
+
this._register(this.profilesTree.onContextMenu(e => {
|
|
195
|
+
if (e.element instanceof AbstractUserDataProfileElement) {
|
|
196
|
+
this.contextMenuService.showContextMenu({
|
|
197
|
+
getAnchor: () => e.anchor,
|
|
198
|
+
getActions: () => e.element instanceof AbstractUserDataProfileElement ? e.element.contextMenuActions.slice(0) : [],
|
|
199
|
+
getActionsContext: () => e.element
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async importProfile() {
|
|
206
|
+
const disposables = ( (new DisposableStore()));
|
|
207
|
+
const quickPick = disposables.add(this.quickInputService.createQuickPick());
|
|
208
|
+
const updateQuickPickItems = (value) => {
|
|
209
|
+
const quickPickItems = [];
|
|
210
|
+
if (value) {
|
|
211
|
+
quickPickItems.push({ label: quickPick.value, description: ( localizeWithPath(_moduleId, 5, "Import from URL")) });
|
|
212
|
+
}
|
|
213
|
+
quickPickItems.push({ label: ( localizeWithPath(_moduleId, 6, "Select File...")) });
|
|
214
|
+
quickPick.items = quickPickItems;
|
|
215
|
+
};
|
|
216
|
+
quickPick.title = ( localizeWithPath(_moduleId, 7, "Import from Profile Template..."));
|
|
217
|
+
quickPick.placeholder = ( localizeWithPath(_moduleId, 8, "Provide Profile Template URL"));
|
|
218
|
+
quickPick.ignoreFocusOut = true;
|
|
219
|
+
disposables.add(quickPick.onDidChangeValue(updateQuickPickItems));
|
|
220
|
+
updateQuickPickItems();
|
|
221
|
+
quickPick.matchOnLabel = false;
|
|
222
|
+
quickPick.matchOnDescription = false;
|
|
223
|
+
disposables.add(quickPick.onDidAccept(async () => {
|
|
224
|
+
quickPick.hide();
|
|
225
|
+
const selectedItem = quickPick.selectedItems[0];
|
|
226
|
+
if (!selectedItem) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const url = selectedItem.label === quickPick.value ? ( (URI.parse(quickPick.value))) : await this.getProfileUriFromFileSystem();
|
|
230
|
+
if (url) {
|
|
231
|
+
this.createNewProfile(url);
|
|
232
|
+
}
|
|
233
|
+
}));
|
|
234
|
+
disposables.add(quickPick.onDidHide(() => disposables.dispose()));
|
|
235
|
+
quickPick.show();
|
|
236
|
+
}
|
|
237
|
+
async createNewProfile(copyFrom) {
|
|
238
|
+
if (this.model?.profiles.some(p => p instanceof NewProfileElement)) {
|
|
239
|
+
const result = await this.dialogService.confirm({
|
|
240
|
+
type: 'info',
|
|
241
|
+
message: ( localizeWithPath(
|
|
242
|
+
_moduleId,
|
|
243
|
+
9,
|
|
244
|
+
"A new profile is already being created. Do you want to discard it and create a new one?"
|
|
245
|
+
)),
|
|
246
|
+
primaryButton: ( localizeWithPath(_moduleId, 10, "Discard & Create")),
|
|
247
|
+
cancelButton: ( localizeWithPath(_moduleId, 11, "Cancel"))
|
|
248
|
+
});
|
|
249
|
+
if (!result.confirmed) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
this.model.revert();
|
|
253
|
+
}
|
|
254
|
+
this.model?.createNewProfile(copyFrom);
|
|
255
|
+
}
|
|
256
|
+
async getProfileUriFromFileSystem() {
|
|
257
|
+
const profileLocation = await this.fileDialogService.showOpenDialog({
|
|
258
|
+
canSelectFolders: false,
|
|
259
|
+
canSelectFiles: true,
|
|
260
|
+
canSelectMany: false,
|
|
261
|
+
filters: PROFILE_FILTER,
|
|
262
|
+
title: ( localizeWithPath(_moduleId, 12, "Select Profile Template File")),
|
|
263
|
+
});
|
|
264
|
+
if (!profileLocation) {
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
return profileLocation[0];
|
|
268
|
+
}
|
|
269
|
+
async setInput(input, options, context, token) {
|
|
270
|
+
await super.setInput(input, options, context, token);
|
|
271
|
+
this.model = await input.resolve();
|
|
272
|
+
this.updateProfilesTree();
|
|
273
|
+
this._register(this.model.onDidChange((element) => {
|
|
274
|
+
this.updateProfilesTree(element);
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
focus() {
|
|
278
|
+
super.focus();
|
|
279
|
+
this.profilesTree?.domFocus();
|
|
280
|
+
}
|
|
281
|
+
updateProfilesTree(elementToSelect) {
|
|
282
|
+
if (!this.model) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const profileElements = ( (this.model.profiles.map(element => ({ element }))));
|
|
286
|
+
const currentSelection = this.profilesTree?.getSelection()?.[0];
|
|
287
|
+
this.profilesTree?.setChildren(null, [
|
|
288
|
+
{
|
|
289
|
+
element: { name: ( localizeWithPath(_moduleId, 1, "Profiles")) },
|
|
290
|
+
children: profileElements,
|
|
291
|
+
collapsible: false,
|
|
292
|
+
collapsed: ObjectTreeElementCollapseState.Expanded
|
|
293
|
+
}
|
|
294
|
+
]);
|
|
295
|
+
if (elementToSelect) {
|
|
296
|
+
this.profilesTree?.setSelection([elementToSelect]);
|
|
297
|
+
}
|
|
298
|
+
else if (currentSelection) {
|
|
299
|
+
if (currentSelection instanceof AbstractUserDataProfileElement) {
|
|
300
|
+
if (!this.model.profiles.includes(currentSelection)) {
|
|
301
|
+
const elementToSelect = this.model.profiles.find(profile => profile.name === currentSelection.name) ?? this.model.profiles[0];
|
|
302
|
+
if (elementToSelect) {
|
|
303
|
+
this.profilesTree?.setSelection([elementToSelect]);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
const elementToSelect = this.model.profiles.find(profile => profile.active) ?? this.model.profiles[0];
|
|
310
|
+
if (elementToSelect) {
|
|
311
|
+
this.profilesTree?.setSelection([elementToSelect]);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
UserDataProfilesEditor = UserDataProfilesEditor_1 = ( (__decorate([
|
|
317
|
+
( (__param(1, ITelemetryService))),
|
|
318
|
+
( (__param(2, IThemeService))),
|
|
319
|
+
( (__param(3, IStorageService))),
|
|
320
|
+
( (__param(4, IUserDataProfileManagementService))),
|
|
321
|
+
( (__param(5, IQuickInputService))),
|
|
322
|
+
( (__param(6, IDialogService))),
|
|
323
|
+
( (__param(7, IFileDialogService))),
|
|
324
|
+
( (__param(8, IContextMenuService))),
|
|
325
|
+
( (__param(9, IInstantiationService)))
|
|
326
|
+
], UserDataProfilesEditor)));
|
|
327
|
+
class ProfileTreeElementDelegate {
|
|
328
|
+
getHeight(element) {
|
|
329
|
+
return 30;
|
|
330
|
+
}
|
|
331
|
+
getTemplateId() { return 'profileTreeElement'; }
|
|
332
|
+
}
|
|
333
|
+
class ProfileTreeElementRenderer {
|
|
334
|
+
constructor() {
|
|
335
|
+
this.templateId = 'profileTreeElement';
|
|
336
|
+
}
|
|
337
|
+
renderTemplate(container) {
|
|
338
|
+
container.classList.add('profile-tree-item');
|
|
339
|
+
const icon = append(container, $('.profile-tree-item-icon'));
|
|
340
|
+
const label = append(container, $('.profile-tree-item-label'));
|
|
341
|
+
const description = append(container, $('.profile-tree-item-description'));
|
|
342
|
+
append(description, $(`span${ThemeIcon.asCSSSelector(Codicon.check)}`));
|
|
343
|
+
append(description, $('span', undefined, ( localizeWithPath(_moduleId, 13, "Active"))));
|
|
344
|
+
return { label, icon, description, disposables: ( (new DisposableStore())) };
|
|
345
|
+
}
|
|
346
|
+
renderElement({ element }, index, templateData, height) {
|
|
347
|
+
templateData.disposables.clear();
|
|
348
|
+
templateData.label.textContent = element.name;
|
|
349
|
+
if (element.icon) {
|
|
350
|
+
templateData.icon.className = ThemeIcon.asClassName(ThemeIcon.fromId(element.icon));
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
templateData.icon.className = 'hide';
|
|
354
|
+
}
|
|
355
|
+
templateData.description.classList.toggle('hide', !element.active);
|
|
356
|
+
if (element.onDidChange) {
|
|
357
|
+
templateData.disposables.add(element.onDidChange(e => {
|
|
358
|
+
if (e.name) {
|
|
359
|
+
templateData.label.textContent = element.name;
|
|
360
|
+
}
|
|
361
|
+
if (e.icon) {
|
|
362
|
+
if (element.icon) {
|
|
363
|
+
templateData.icon.className = ThemeIcon.asClassName(ThemeIcon.fromId(element.icon));
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
templateData.icon.className = 'hide';
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (e.active) {
|
|
370
|
+
templateData.description.classList.toggle('hide', !element.active);
|
|
371
|
+
}
|
|
372
|
+
}));
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
disposeTemplate(templateData) {
|
|
376
|
+
templateData.disposables.dispose();
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
let ProfileWidget = class ProfileWidget extends Disposable {
|
|
380
|
+
set templates(templates) {
|
|
381
|
+
this._templates = templates;
|
|
382
|
+
this.renderSelectBox();
|
|
383
|
+
}
|
|
384
|
+
constructor(parent, hoverService, userDataProfilesService, contextViewService, editorProgressService, commandService, instantiationService) {
|
|
385
|
+
super();
|
|
386
|
+
this.hoverService = hoverService;
|
|
387
|
+
this.userDataProfilesService = userDataProfilesService;
|
|
388
|
+
this.contextViewService = contextViewService;
|
|
389
|
+
this.editorProgressService = editorProgressService;
|
|
390
|
+
this.commandService = commandService;
|
|
391
|
+
this.instantiationService = instantiationService;
|
|
392
|
+
this.copyFromOptions = [];
|
|
393
|
+
this._templates = [];
|
|
394
|
+
this._profileElement = this._register(( (new MutableDisposable())));
|
|
395
|
+
const header = append(parent, $('.profile-header'));
|
|
396
|
+
const title = append(header, $('.profile-title'));
|
|
397
|
+
append(title, $('span', undefined, ( localizeWithPath(_moduleId, 14, "Profile: "))));
|
|
398
|
+
this.profileTitle = append(title, $('span'));
|
|
399
|
+
const actionsContainer = append(header, $('.profile-actions-container'));
|
|
400
|
+
this.buttonContainer = append(actionsContainer, $('.profile-button-container'));
|
|
401
|
+
this.toolbar = this._register(instantiationService.createInstance(WorkbenchToolBar, actionsContainer, {
|
|
402
|
+
hoverDelegate: this._register(createInstantHoverDelegate()),
|
|
403
|
+
}));
|
|
404
|
+
const body = append(parent, $('.profile-body'));
|
|
405
|
+
this.nameContainer = append(body, $('.profile-name-container'));
|
|
406
|
+
this.iconElement = append(this.nameContainer, $(`${ThemeIcon.asCSSSelector(DEFAULT_ICON)}`, { 'tabindex': '0', 'role': 'button', 'aria-label': ( localizeWithPath(_moduleId, 15, "Profile Icon")) }));
|
|
407
|
+
this.renderIconSelectBox(this.iconElement);
|
|
408
|
+
this.nameInput = this._register(( (new InputBox(this.nameContainer, undefined, {
|
|
409
|
+
inputBoxStyles: defaultInputBoxStyles,
|
|
410
|
+
ariaLabel: ( localizeWithPath(_moduleId, 16, "Profile Name")),
|
|
411
|
+
placeholder: ( localizeWithPath(_moduleId, 16, "Profile Name")),
|
|
412
|
+
validationOptions: {
|
|
413
|
+
validation: (value) => {
|
|
414
|
+
if (!value) {
|
|
415
|
+
return {
|
|
416
|
+
content: ( localizeWithPath(_moduleId, 17, "Profile name is required and must be a non-empty value.")),
|
|
417
|
+
type: MessageType.ERROR
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
const initialName = this._profileElement.value?.element instanceof UserDataProfileElement ? this._profileElement.value.element.profile.name : undefined;
|
|
421
|
+
if (initialName !== value && ( (this.userDataProfilesService.profiles.some(p => p.name === value)))) {
|
|
422
|
+
return {
|
|
423
|
+
content: ( localizeWithPath(_moduleId, 18, "Profile with name {0} already exists.", value)),
|
|
424
|
+
type: MessageType.ERROR
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}))));
|
|
431
|
+
this.nameInput.onDidChange(value => {
|
|
432
|
+
if (this._profileElement.value && value) {
|
|
433
|
+
this._profileElement.value.element.name = value;
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
const focusTracker = this._register(trackFocus(this.nameInput.inputElement));
|
|
437
|
+
this._register(focusTracker.onDidBlur(() => {
|
|
438
|
+
if (this._profileElement.value && !this.nameInput.value) {
|
|
439
|
+
this.nameInput.value = this._profileElement.value.element.name;
|
|
440
|
+
}
|
|
441
|
+
}));
|
|
442
|
+
this.copyFromContainer = append(body, $('.profile-copy-from-container'));
|
|
443
|
+
append(this.copyFromContainer, $('.profile-copy-from-label', undefined, ( localizeWithPath(_moduleId, 19, "Copy from:"))));
|
|
444
|
+
this.copyFromSelectBox = this._register(this.instantiationService.createInstance(SelectBox, [], 0, this.contextViewService, defaultSelectBoxStyles, {
|
|
445
|
+
useCustomDrawn: true,
|
|
446
|
+
ariaLabel: ( localizeWithPath(_moduleId, 20, "Copy profile from")),
|
|
447
|
+
}));
|
|
448
|
+
this.copyFromSelectBox.render(append(this.copyFromContainer, $('.profile-select-container')));
|
|
449
|
+
const contentsContainer = append(body, $('.profile-contents-container'));
|
|
450
|
+
append(contentsContainer, $('.profile-contents-label', undefined, ( localizeWithPath(_moduleId, 21, "Contents"))));
|
|
451
|
+
const delegate = ( (new ProfileResourceTreeElementDelegate()));
|
|
452
|
+
this.resourcesTree = this._register(this.instantiationService.createInstance((WorkbenchAsyncDataTree), 'ProfileEditor-ResourcesTree', append(body, $('.profile-content-tree.file-icon-themable-tree.show-file-icons')), delegate, [
|
|
453
|
+
this.instantiationService.createInstance(ExistingProfileResourceTreeRenderer),
|
|
454
|
+
this.instantiationService.createInstance(NewProfileResourceTreeRenderer),
|
|
455
|
+
this.instantiationService.createInstance(ProfileResourceChildTreeItemRenderer),
|
|
456
|
+
], this.instantiationService.createInstance(ProfileResourceTreeDataSource), {
|
|
457
|
+
multipleSelectionSupport: false,
|
|
458
|
+
horizontalScrolling: false,
|
|
459
|
+
accessibilityProvider: {
|
|
460
|
+
getAriaLabel(element) {
|
|
461
|
+
if (isString(element?.element)) {
|
|
462
|
+
return element.element;
|
|
463
|
+
}
|
|
464
|
+
if (element?.element) {
|
|
465
|
+
return element.element.label?.label ?? '';
|
|
466
|
+
}
|
|
467
|
+
return '';
|
|
468
|
+
},
|
|
469
|
+
getWidgetAriaLabel() {
|
|
470
|
+
return '';
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
identityProvider: {
|
|
474
|
+
getId(element) {
|
|
475
|
+
if (isString(element?.element)) {
|
|
476
|
+
return element.element;
|
|
477
|
+
}
|
|
478
|
+
if (element?.element) {
|
|
479
|
+
return element.element.handle;
|
|
480
|
+
}
|
|
481
|
+
return '';
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
expandOnlyOnTwistieClick: true,
|
|
485
|
+
renderIndentGuides: RenderIndentGuides.None,
|
|
486
|
+
openOnSingleClick: true,
|
|
487
|
+
enableStickyScroll: false,
|
|
488
|
+
}));
|
|
489
|
+
this._register(this.resourcesTree.onDidOpen(async (e) => {
|
|
490
|
+
if (!e.browserEvent) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
if (e.browserEvent.target && e.browserEvent.target.classList.contains(Checkbox.CLASS_NAME)) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
if (e.element && !isString(e.element.element)) {
|
|
497
|
+
if (e.element.element.resourceUri) {
|
|
498
|
+
await this.commandService.executeCommand(API_OPEN_EDITOR_COMMAND_ID, e.element.element.resourceUri, [SIDE_GROUP], undefined, e);
|
|
499
|
+
}
|
|
500
|
+
else if (e.element.element.parent instanceof ExtensionsResourceTreeItem) {
|
|
501
|
+
await this.commandService.executeCommand('extension.open', e.element.element.handle, undefined, true, undefined, true);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}));
|
|
505
|
+
}
|
|
506
|
+
renderIconSelectBox(iconContainer) {
|
|
507
|
+
const iconSelectBox = this._register(this.instantiationService.createInstance(WorkbenchIconSelectBox, { icons: ICONS, inputBoxStyles: defaultInputBoxStyles }));
|
|
508
|
+
let hoverWidget;
|
|
509
|
+
const showIconSelectBox = () => {
|
|
510
|
+
if (this._profileElement.value?.element instanceof UserDataProfileElement && this._profileElement.value.element.profile.isDefault) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
iconSelectBox.clearInput();
|
|
514
|
+
hoverWidget = this.hoverService.showHover({
|
|
515
|
+
content: iconSelectBox.domNode,
|
|
516
|
+
target: iconContainer,
|
|
517
|
+
position: {
|
|
518
|
+
hoverPosition: HoverPosition.BELOW,
|
|
519
|
+
},
|
|
520
|
+
persistence: {
|
|
521
|
+
sticky: true,
|
|
522
|
+
},
|
|
523
|
+
appearance: {
|
|
524
|
+
showPointer: true,
|
|
525
|
+
},
|
|
526
|
+
}, true);
|
|
527
|
+
if (hoverWidget) {
|
|
528
|
+
iconSelectBox.layout(( (new Dimension(486, 260))));
|
|
529
|
+
iconSelectBox.focus();
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
this._register(addDisposableListener(iconContainer, EventType.CLICK, (e) => {
|
|
533
|
+
EventHelper.stop(e, true);
|
|
534
|
+
showIconSelectBox();
|
|
535
|
+
}));
|
|
536
|
+
this._register(addDisposableListener(iconContainer, EventType.KEY_DOWN, e => {
|
|
537
|
+
const event = ( (new StandardKeyboardEvent(e)));
|
|
538
|
+
if (event.equals(KeyCode.Enter) || event.equals(KeyCode.Space)) {
|
|
539
|
+
EventHelper.stop(event, true);
|
|
540
|
+
showIconSelectBox();
|
|
541
|
+
}
|
|
542
|
+
}));
|
|
543
|
+
this._register(addDisposableListener(iconSelectBox.domNode, EventType.KEY_DOWN, e => {
|
|
544
|
+
const event = ( (new StandardKeyboardEvent(e)));
|
|
545
|
+
if (event.equals(KeyCode.Escape)) {
|
|
546
|
+
EventHelper.stop(event, true);
|
|
547
|
+
hoverWidget?.dispose();
|
|
548
|
+
iconContainer.focus();
|
|
549
|
+
}
|
|
550
|
+
}));
|
|
551
|
+
this._register(iconSelectBox.onDidSelect(selectedIcon => {
|
|
552
|
+
hoverWidget?.dispose();
|
|
553
|
+
iconContainer.focus();
|
|
554
|
+
if (this._profileElement.value) {
|
|
555
|
+
this._profileElement.value.element.icon = selectedIcon.id;
|
|
556
|
+
}
|
|
557
|
+
}));
|
|
558
|
+
}
|
|
559
|
+
renderSelectBox() {
|
|
560
|
+
const separator = { text: '\u2500\u2500\u2500\u2500\u2500\u2500', isDisabled: true };
|
|
561
|
+
this.copyFromOptions.push({ text: ( localizeWithPath(_moduleId, 22, "None")) });
|
|
562
|
+
if (this._templates.length) {
|
|
563
|
+
this.copyFromOptions.push({ ...separator, decoratorRight: ( localizeWithPath(_moduleId, 23, "Profile Templates")) });
|
|
564
|
+
for (const template of this._templates) {
|
|
565
|
+
this.copyFromOptions.push({ text: template.name, id: template.url, source: ( (URI.parse(template.url))) });
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
this.copyFromOptions.push({ ...separator, decoratorRight: ( localizeWithPath(_moduleId, 24, "Existing Profiles")) });
|
|
569
|
+
for (const profile of this.userDataProfilesService.profiles) {
|
|
570
|
+
this.copyFromOptions.push({ text: profile.name, id: profile.id, source: profile });
|
|
571
|
+
}
|
|
572
|
+
this.copyFromSelectBox.setOptions(this.copyFromOptions);
|
|
573
|
+
this._register(this.copyFromSelectBox.onDidSelect(option => {
|
|
574
|
+
if (this._profileElement.value?.element instanceof NewProfileElement) {
|
|
575
|
+
this._profileElement.value.element.copyFrom = this.copyFromOptions[option.index].source;
|
|
576
|
+
}
|
|
577
|
+
}));
|
|
578
|
+
}
|
|
579
|
+
layout(dimension) {
|
|
580
|
+
this.resourcesTree.layout(dimension.height - 34 - 20 - 25 - 20, dimension.width);
|
|
581
|
+
}
|
|
582
|
+
render(profileElement) {
|
|
583
|
+
const disposables = ( (new DisposableStore()));
|
|
584
|
+
this._profileElement.value = { element: profileElement, dispose: () => disposables.dispose() };
|
|
585
|
+
this.renderProfileElement(profileElement);
|
|
586
|
+
disposables.add(profileElement.onDidChange(e => this.renderProfileElement(profileElement)));
|
|
587
|
+
const profile = profileElement instanceof UserDataProfileElement ? profileElement.profile : undefined;
|
|
588
|
+
this.nameInput.setEnabled(!profile?.isDefault);
|
|
589
|
+
this.resourcesTree.setInput(profileElement);
|
|
590
|
+
disposables.add(profileElement.onDidChange(e => {
|
|
591
|
+
if (e.flags || e.copyFrom) {
|
|
592
|
+
const viewState = this.resourcesTree.getViewState();
|
|
593
|
+
this.resourcesTree.setInput(profileElement, {
|
|
594
|
+
...viewState,
|
|
595
|
+
expanded: viewState.expanded?.map(e => e)
|
|
596
|
+
});
|
|
597
|
+
}
|
|
598
|
+
}));
|
|
599
|
+
if (profileElement.primaryAction) {
|
|
600
|
+
this.buttonContainer.classList.remove('hide');
|
|
601
|
+
const button = disposables.add(( (new Button(this.buttonContainer, {
|
|
602
|
+
supportIcons: true,
|
|
603
|
+
...defaultButtonStyles
|
|
604
|
+
}))));
|
|
605
|
+
button.label = profileElement.primaryAction.label;
|
|
606
|
+
button.enabled = profileElement.primaryAction.enabled;
|
|
607
|
+
disposables.add(button.onDidClick(() => this.editorProgressService.showWhile(profileElement.primaryAction.run())));
|
|
608
|
+
disposables.add(profileElement.primaryAction.onDidChange((e) => {
|
|
609
|
+
if (!isUndefined(e.enabled)) {
|
|
610
|
+
button.enabled = profileElement.primaryAction.enabled;
|
|
611
|
+
}
|
|
612
|
+
}));
|
|
613
|
+
disposables.add(profileElement.onDidChange(e => {
|
|
614
|
+
if (e.message) {
|
|
615
|
+
button.setTitle(profileElement.message ?? profileElement.primaryAction.label);
|
|
616
|
+
button.element.classList.toggle('error', !!profileElement.message);
|
|
617
|
+
}
|
|
618
|
+
}));
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
this.buttonContainer.classList.add('hide');
|
|
622
|
+
}
|
|
623
|
+
this.toolbar.setActions(profileElement.titleActions[0].slice(0), profileElement.titleActions[1].slice(0));
|
|
624
|
+
this.nameInput.focus();
|
|
625
|
+
if (profileElement instanceof NewProfileElement) {
|
|
626
|
+
this.nameInput.select();
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
renderProfileElement(profileElement) {
|
|
630
|
+
this.profileTitle.textContent = profileElement.name;
|
|
631
|
+
this.nameInput.value = profileElement.name;
|
|
632
|
+
if (profileElement.icon) {
|
|
633
|
+
this.iconElement.className = ThemeIcon.asClassName(ThemeIcon.fromId(profileElement.icon));
|
|
634
|
+
}
|
|
635
|
+
else {
|
|
636
|
+
this.iconElement.className = ThemeIcon.asClassName(ThemeIcon.fromId(DEFAULT_ICON.id));
|
|
637
|
+
}
|
|
638
|
+
if (profileElement instanceof NewProfileElement) {
|
|
639
|
+
this.copyFromContainer.classList.remove('hide');
|
|
640
|
+
const id = profileElement.copyFrom instanceof URI ? ( (profileElement.copyFrom.toString())) : profileElement.copyFrom?.id;
|
|
641
|
+
const index = id
|
|
642
|
+
? this.copyFromOptions.findIndex(option => option.id === id)
|
|
643
|
+
: 0;
|
|
644
|
+
if (index !== -1) {
|
|
645
|
+
this.copyFromSelectBox.setOptions(this.copyFromOptions);
|
|
646
|
+
this.copyFromSelectBox.setEnabled(true);
|
|
647
|
+
this.copyFromSelectBox.select(index);
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
this.copyFromSelectBox.setOptions([{ text: basename(profileElement.copyFrom) }]);
|
|
651
|
+
this.copyFromSelectBox.setEnabled(false);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
this.copyFromContainer.classList.add('hide');
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
ProfileWidget = ( (__decorate([
|
|
660
|
+
( (__param(1, IHoverService))),
|
|
661
|
+
( (__param(2, IUserDataProfilesService))),
|
|
662
|
+
( (__param(3, IContextViewService))),
|
|
663
|
+
( (__param(4, IEditorProgressService))),
|
|
664
|
+
( (__param(5, ICommandService))),
|
|
665
|
+
( (__param(6, IInstantiationService)))
|
|
666
|
+
], ProfileWidget)));
|
|
667
|
+
class ProfileResourceTreeElementDelegate {
|
|
668
|
+
getTemplateId(element) {
|
|
669
|
+
if (!isString(element.element)) {
|
|
670
|
+
return ProfileResourceChildTreeItemRenderer.TEMPLATE_ID;
|
|
671
|
+
}
|
|
672
|
+
if (element.root instanceof NewProfileElement) {
|
|
673
|
+
return NewProfileResourceTreeRenderer.TEMPLATE_ID;
|
|
674
|
+
}
|
|
675
|
+
return ExistingProfileResourceTreeRenderer.TEMPLATE_ID;
|
|
676
|
+
}
|
|
677
|
+
getHeight(element) {
|
|
678
|
+
return 30;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
let ProfileResourceTreeDataSource = class ProfileResourceTreeDataSource {
|
|
682
|
+
constructor(editorProgressService) {
|
|
683
|
+
this.editorProgressService = editorProgressService;
|
|
684
|
+
}
|
|
685
|
+
hasChildren(element) {
|
|
686
|
+
if (element instanceof AbstractUserDataProfileElement) {
|
|
687
|
+
return true;
|
|
688
|
+
}
|
|
689
|
+
if (isString(element.element)) {
|
|
690
|
+
if (element.root.getFlag(element.element)) {
|
|
691
|
+
return false;
|
|
692
|
+
}
|
|
693
|
+
if (element.root instanceof NewProfileElement) {
|
|
694
|
+
return element.root.copyFrom !== undefined;
|
|
695
|
+
}
|
|
696
|
+
return true;
|
|
697
|
+
}
|
|
698
|
+
return false;
|
|
699
|
+
}
|
|
700
|
+
async getChildren(element) {
|
|
701
|
+
if (element instanceof AbstractUserDataProfileElement) {
|
|
702
|
+
const resourceTypes = [
|
|
703
|
+
ProfileResourceType.Settings,
|
|
704
|
+
ProfileResourceType.Keybindings,
|
|
705
|
+
ProfileResourceType.Snippets,
|
|
706
|
+
ProfileResourceType.Tasks,
|
|
707
|
+
ProfileResourceType.Extensions
|
|
708
|
+
];
|
|
709
|
+
return (
|
|
710
|
+
(resourceTypes.map(resourceType => ({ element: resourceType, root: element })))
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
if (isString(element.element)) {
|
|
714
|
+
const progressRunner = this.editorProgressService.show(true);
|
|
715
|
+
try {
|
|
716
|
+
const extensions = await element.root.getChildren(element.element);
|
|
717
|
+
return (
|
|
718
|
+
(extensions.map(extension => ({ element: extension, root: element.root })))
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
finally {
|
|
722
|
+
progressRunner.done();
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
return [];
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
ProfileResourceTreeDataSource = ( (__decorate([
|
|
729
|
+
( (__param(0, IEditorProgressService)))
|
|
730
|
+
], ProfileResourceTreeDataSource)));
|
|
731
|
+
class AbstractProfileResourceTreeRenderer extends Disposable {
|
|
732
|
+
getResourceTypeTitle(resourceType) {
|
|
733
|
+
switch (resourceType) {
|
|
734
|
+
case ProfileResourceType.Settings:
|
|
735
|
+
return ( localizeWithPath(_moduleId, 25, "Settings"));
|
|
736
|
+
case ProfileResourceType.Keybindings:
|
|
737
|
+
return ( localizeWithPath(_moduleId, 26, "Keyboard Shortcuts"));
|
|
738
|
+
case ProfileResourceType.Snippets:
|
|
739
|
+
return ( localizeWithPath(_moduleId, 27, "User Snippets"));
|
|
740
|
+
case ProfileResourceType.Tasks:
|
|
741
|
+
return ( localizeWithPath(_moduleId, 28, "User Tasks"));
|
|
742
|
+
case ProfileResourceType.Extensions:
|
|
743
|
+
return ( localizeWithPath(_moduleId, 29, "Extensions"));
|
|
744
|
+
}
|
|
745
|
+
return '';
|
|
746
|
+
}
|
|
747
|
+
disposeElement(element, index, templateData, height) {
|
|
748
|
+
templateData.elementDisposables.clear();
|
|
749
|
+
}
|
|
750
|
+
disposeTemplate(templateData) {
|
|
751
|
+
templateData.disposables.dispose();
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
class ExistingProfileResourceTreeRenderer extends AbstractProfileResourceTreeRenderer {
|
|
755
|
+
constructor() {
|
|
756
|
+
super(...arguments);
|
|
757
|
+
this.templateId = ExistingProfileResourceTreeRenderer.TEMPLATE_ID;
|
|
758
|
+
}
|
|
759
|
+
static { this.TEMPLATE_ID = 'ExistingProfileResourceTemplate'; }
|
|
760
|
+
renderTemplate(parent) {
|
|
761
|
+
const disposables = ( (new DisposableStore()));
|
|
762
|
+
const container = append(parent, $('.profile-tree-item-container.existing-profile-resource-type-container'));
|
|
763
|
+
const checkbox = disposables.add(( (new Checkbox('', false, defaultCheckboxStyles))));
|
|
764
|
+
append(container, checkbox.domNode);
|
|
765
|
+
const label = append(container, $('.profile-resource-type-label'));
|
|
766
|
+
const description = append(container, $('.profile-resource-type-description', undefined, ( localizeWithPath(_moduleId, 30, "Using Default Profile"))));
|
|
767
|
+
return { checkbox, label, description, disposables, elementDisposables: disposables.add(( (new DisposableStore()))) };
|
|
768
|
+
}
|
|
769
|
+
renderElement({ element: profileResourceTreeElement }, index, templateData, height) {
|
|
770
|
+
templateData.elementDisposables.clear();
|
|
771
|
+
const { element, root } = profileResourceTreeElement;
|
|
772
|
+
if (!(root instanceof UserDataProfileElement)) {
|
|
773
|
+
throw ( (new Error(
|
|
774
|
+
'ExistingProfileResourceTreeRenderer can only render existing profile element'
|
|
775
|
+
)));
|
|
776
|
+
}
|
|
777
|
+
if (!isString(element)) {
|
|
778
|
+
throw ( (new Error(
|
|
779
|
+
'ExistingProfileResourceTreeRenderer can only render profile resource types'
|
|
780
|
+
)));
|
|
781
|
+
}
|
|
782
|
+
templateData.label.textContent = this.getResourceTypeTitle(element);
|
|
783
|
+
if (root instanceof UserDataProfileElement && root.profile.isDefault) {
|
|
784
|
+
templateData.checkbox.checked = true;
|
|
785
|
+
templateData.checkbox.disable();
|
|
786
|
+
templateData.description.classList.add('hide');
|
|
787
|
+
}
|
|
788
|
+
else {
|
|
789
|
+
templateData.checkbox.enable();
|
|
790
|
+
const checked = !root.getFlag(element);
|
|
791
|
+
templateData.checkbox.checked = checked;
|
|
792
|
+
templateData.description.classList.toggle('hide', checked);
|
|
793
|
+
templateData.elementDisposables.add(templateData.checkbox.onChange(() => root.setFlag(element, !templateData.checkbox.checked)));
|
|
794
|
+
templateData.elementDisposables.add(root.onDidChange(e => {
|
|
795
|
+
if (e.flags) {
|
|
796
|
+
templateData.description.classList.toggle('hide', !root.getFlag(element));
|
|
797
|
+
}
|
|
798
|
+
}));
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
let NewProfileResourceTreeRenderer = class NewProfileResourceTreeRenderer extends AbstractProfileResourceTreeRenderer {
|
|
803
|
+
static { NewProfileResourceTreeRenderer_1 = this; }
|
|
804
|
+
static { this.TEMPLATE_ID = 'NewProfileResourceTemplate'; }
|
|
805
|
+
constructor(contextViewService, instantiationService) {
|
|
806
|
+
super();
|
|
807
|
+
this.contextViewService = contextViewService;
|
|
808
|
+
this.instantiationService = instantiationService;
|
|
809
|
+
this.templateId = NewProfileResourceTreeRenderer_1.TEMPLATE_ID;
|
|
810
|
+
}
|
|
811
|
+
renderTemplate(parent) {
|
|
812
|
+
const disposables = ( (new DisposableStore()));
|
|
813
|
+
const container = append(parent, $('.profile-tree-item-container.new-profile-resource-type-container'));
|
|
814
|
+
const labelContainer = append(container, $('.profile-resource-type-label-container'));
|
|
815
|
+
const label = append(labelContainer, $('span.profile-resource-type-label'));
|
|
816
|
+
const selectBox = this._register(this.instantiationService.createInstance(SelectBox, [
|
|
817
|
+
{ text: ( localizeWithPath(_moduleId, 31, "Empty")) },
|
|
818
|
+
{ text: ( localizeWithPath(_moduleId, 32, "Copy")) },
|
|
819
|
+
{ text: ( localizeWithPath(_moduleId, 33, "Use Default Profile")) }
|
|
820
|
+
], 0, this.contextViewService, defaultSelectBoxStyles, {
|
|
821
|
+
useCustomDrawn: true,
|
|
822
|
+
}));
|
|
823
|
+
const selectContainer = append(container, $('.profile-select-container'));
|
|
824
|
+
selectBox.render(selectContainer);
|
|
825
|
+
return { label, selectContainer, selectBox, disposables, elementDisposables: disposables.add(( (new DisposableStore()))) };
|
|
826
|
+
}
|
|
827
|
+
renderElement({ element: profileResourceTreeElement }, index, templateData, height) {
|
|
828
|
+
templateData.elementDisposables.clear();
|
|
829
|
+
const { element, root } = profileResourceTreeElement;
|
|
830
|
+
if (!(root instanceof NewProfileElement)) {
|
|
831
|
+
throw ( (new Error('NewProfileResourceTreeRenderer can only render new profile element')));
|
|
832
|
+
}
|
|
833
|
+
if (!isString(element)) {
|
|
834
|
+
throw ( (new Error('NewProfileResourceTreeRenderer can only profile resoyrce types')));
|
|
835
|
+
}
|
|
836
|
+
templateData.label.textContent = this.getResourceTypeTitle(element);
|
|
837
|
+
templateData.selectBox.select(root.getCopyFlag(element) ? 1 : root.getFlag(element) ? 2 : 0);
|
|
838
|
+
templateData.elementDisposables.add(templateData.selectBox.onDidSelect(option => {
|
|
839
|
+
root.setFlag(element, option.index === 2);
|
|
840
|
+
root.setCopyFlag(element, option.index === 1);
|
|
841
|
+
}));
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
NewProfileResourceTreeRenderer = NewProfileResourceTreeRenderer_1 = ( (__decorate([
|
|
845
|
+
( (__param(0, IContextViewService))),
|
|
846
|
+
( (__param(1, IInstantiationService)))
|
|
847
|
+
], NewProfileResourceTreeRenderer)));
|
|
848
|
+
let ProfileResourceChildTreeItemRenderer = class ProfileResourceChildTreeItemRenderer extends AbstractProfileResourceTreeRenderer {
|
|
849
|
+
static { ProfileResourceChildTreeItemRenderer_1 = this; }
|
|
850
|
+
static { this.TEMPLATE_ID = 'ProfileResourceChildTreeItemTemplate'; }
|
|
851
|
+
constructor(instantiationService) {
|
|
852
|
+
super();
|
|
853
|
+
this.templateId = ProfileResourceChildTreeItemRenderer_1.TEMPLATE_ID;
|
|
854
|
+
this.labels = instantiationService.createInstance(ResourceLabels, DEFAULT_LABELS_CONTAINER);
|
|
855
|
+
this.hoverDelegate = this._register(instantiationService.createInstance(WorkbenchHoverDelegate, 'mouse', false, {}));
|
|
856
|
+
}
|
|
857
|
+
renderTemplate(parent) {
|
|
858
|
+
const disposables = ( (new DisposableStore()));
|
|
859
|
+
const container = append(parent, $('.profile-tree-item-container.profile-resource-child-container'));
|
|
860
|
+
const checkbox = disposables.add(( (new Checkbox('', false, defaultCheckboxStyles))));
|
|
861
|
+
append(container, checkbox.domNode);
|
|
862
|
+
const resourceLabel = disposables.add(this.labels.create(container, { hoverDelegate: this.hoverDelegate }));
|
|
863
|
+
return { checkbox, resourceLabel, disposables, elementDisposables: disposables.add(( (new DisposableStore()))) };
|
|
864
|
+
}
|
|
865
|
+
renderElement({ element: profileResourceTreeElement }, index, templateData, height) {
|
|
866
|
+
templateData.elementDisposables.clear();
|
|
867
|
+
const { element } = profileResourceTreeElement;
|
|
868
|
+
if (isString(element)) {
|
|
869
|
+
throw ( (new Error(
|
|
870
|
+
'NewProfileResourceTreeRenderer can only render profile resource child tree items'
|
|
871
|
+
)));
|
|
872
|
+
}
|
|
873
|
+
if (element.checkbox) {
|
|
874
|
+
templateData.checkbox.domNode.classList.remove('hide');
|
|
875
|
+
templateData.checkbox.checked = element.checkbox.isChecked;
|
|
876
|
+
templateData.checkbox.domNode.ariaLabel = element.checkbox.accessibilityInformation?.label ?? '';
|
|
877
|
+
if (element.checkbox.accessibilityInformation?.role) {
|
|
878
|
+
templateData.checkbox.domNode.role = element.checkbox.accessibilityInformation.role;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
else {
|
|
882
|
+
templateData.checkbox.domNode.classList.add('hide');
|
|
883
|
+
}
|
|
884
|
+
const resource = URI.revive(element.resourceUri);
|
|
885
|
+
templateData.resourceLabel.setResource({
|
|
886
|
+
name: resource ? basename(resource) : element.label?.label,
|
|
887
|
+
description: isString(element.description) ? element.description : undefined,
|
|
888
|
+
resource
|
|
889
|
+
}, {
|
|
890
|
+
forceLabel: true,
|
|
891
|
+
hideIcon: !resource,
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
};
|
|
895
|
+
ProfileResourceChildTreeItemRenderer = ProfileResourceChildTreeItemRenderer_1 = ( (__decorate([
|
|
896
|
+
( (__param(0, IInstantiationService)))
|
|
897
|
+
], ProfileResourceChildTreeItemRenderer)));
|
|
898
|
+
let UserDataProfilesEditorInput = class UserDataProfilesEditorInput extends EditorInput {
|
|
899
|
+
static { UserDataProfilesEditorInput_1 = this; }
|
|
900
|
+
static { this.ID = 'workbench.input.userDataProfiles'; }
|
|
901
|
+
get dirty() { return this._dirty; }
|
|
902
|
+
set dirty(dirty) {
|
|
903
|
+
if (this._dirty !== dirty) {
|
|
904
|
+
this._dirty = dirty;
|
|
905
|
+
this._onDidChangeDirty.fire();
|
|
906
|
+
}
|
|
907
|
+
}
|
|
908
|
+
constructor(instantiationService) {
|
|
909
|
+
super();
|
|
910
|
+
this.instantiationService = instantiationService;
|
|
911
|
+
this.resource = undefined;
|
|
912
|
+
this._dirty = false;
|
|
913
|
+
this.model = UserDataProfilesEditorModel.getInstance(this.instantiationService);
|
|
914
|
+
this._register(this.model.onDidChange(e => this.dirty = ( (this.model.profiles.some(profile => profile instanceof NewProfileElement)))));
|
|
915
|
+
}
|
|
916
|
+
get typeId() { return UserDataProfilesEditorInput_1.ID; }
|
|
917
|
+
getName() { return ( localizeWithPath(_moduleId, 34, "Profiles")); }
|
|
918
|
+
getIcon() { return defaultUserDataProfileIcon; }
|
|
919
|
+
async resolve() {
|
|
920
|
+
return this.model;
|
|
921
|
+
}
|
|
922
|
+
isDirty() {
|
|
923
|
+
return this.dirty;
|
|
924
|
+
}
|
|
925
|
+
async save() {
|
|
926
|
+
await this.model.saveNewProfile();
|
|
927
|
+
return this;
|
|
928
|
+
}
|
|
929
|
+
async revert() {
|
|
930
|
+
this.model.revert();
|
|
931
|
+
}
|
|
932
|
+
matches(otherInput) { return otherInput instanceof UserDataProfilesEditorInput_1; }
|
|
933
|
+
};
|
|
934
|
+
UserDataProfilesEditorInput = UserDataProfilesEditorInput_1 = ( (__decorate([
|
|
935
|
+
( (__param(0, IInstantiationService)))
|
|
936
|
+
], UserDataProfilesEditorInput)));
|
|
937
|
+
class UserDataProfilesEditorInputSerializer {
|
|
938
|
+
canSerialize(editorInput) { return true; }
|
|
939
|
+
serialize(editorInput) { return ''; }
|
|
940
|
+
deserialize(instantiationService) { return instantiationService.createInstance(UserDataProfilesEditorInput); }
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
export { UserDataProfilesEditor, UserDataProfilesEditorInput, UserDataProfilesEditorInputSerializer, profilesSashBorder };
|