@theia/preferences 1.53.0-next.55 → 1.53.0-next.64

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.
Files changed (54) hide show
  1. package/README.md +81 -81
  2. package/package.json +8 -8
  3. package/src/browser/abstract-resource-preference-provider.spec.ts +95 -95
  4. package/src/browser/abstract-resource-preference-provider.ts +232 -232
  5. package/src/browser/folder-preference-provider.ts +58 -58
  6. package/src/browser/folders-preferences-provider.ts +244 -244
  7. package/src/browser/index.ts +23 -23
  8. package/src/browser/monaco-jsonc-editor.ts +67 -67
  9. package/src/browser/package.spec.ts +28 -28
  10. package/src/browser/preference-bindings.ts +65 -65
  11. package/src/browser/preference-frontend-contribution.ts +38 -38
  12. package/src/browser/preference-frontend-module.ts +66 -66
  13. package/src/browser/preference-open-handler.ts +53 -53
  14. package/src/browser/preference-transaction-manager.ts +287 -287
  15. package/src/browser/preference-tree-model.ts +260 -260
  16. package/src/browser/preferences-contribution.ts +263 -263
  17. package/src/browser/preferences-json-schema-contribution.ts +86 -86
  18. package/src/browser/preferences-monaco-contribution.ts +27 -27
  19. package/src/browser/section-preference-provider.ts +83 -83
  20. package/src/browser/style/index.css +506 -506
  21. package/src/browser/style/preference-array.css +94 -94
  22. package/src/browser/style/preference-context-menu.css +74 -74
  23. package/src/browser/style/preference-file.css +31 -31
  24. package/src/browser/style/preference-object.css +49 -49
  25. package/src/browser/style/search-input.css +66 -66
  26. package/src/browser/user-configs-preference-provider.ts +127 -127
  27. package/src/browser/user-preference-provider.ts +35 -35
  28. package/src/browser/util/preference-layout.ts +381 -381
  29. package/src/browser/util/preference-scope-command-manager.ts +75 -75
  30. package/src/browser/util/preference-tree-generator.ts +260 -260
  31. package/src/browser/util/preference-tree-label-provider.spec.ts +110 -110
  32. package/src/browser/util/preference-tree-label-provider.ts +72 -72
  33. package/src/browser/util/preference-types.ts +177 -177
  34. package/src/browser/views/components/preference-array-input.ts +174 -174
  35. package/src/browser/views/components/preference-boolean-input.ts +69 -69
  36. package/src/browser/views/components/preference-file-input.ts +104 -104
  37. package/src/browser/views/components/preference-json-input.ts +78 -78
  38. package/src/browser/views/components/preference-markdown-renderer.ts +68 -68
  39. package/src/browser/views/components/preference-node-renderer-creator.ts +141 -141
  40. package/src/browser/views/components/preference-node-renderer.ts +477 -477
  41. package/src/browser/views/components/preference-number-input.ts +147 -147
  42. package/src/browser/views/components/preference-select-input.ts +131 -131
  43. package/src/browser/views/components/preference-string-input.ts +76 -76
  44. package/src/browser/views/preference-editor-widget.ts +349 -349
  45. package/src/browser/views/preference-scope-tabbar-widget.tsx +344 -344
  46. package/src/browser/views/preference-searchbar-widget.tsx +183 -183
  47. package/src/browser/views/preference-tree-widget.tsx +102 -102
  48. package/src/browser/views/preference-widget-bindings.ts +102 -102
  49. package/src/browser/views/preference-widget.tsx +118 -118
  50. package/src/browser/workspace-file-preference-provider.ts +100 -100
  51. package/src/browser/workspace-preference-provider.ts +134 -134
  52. package/src/common/cli-preferences.ts +22 -22
  53. package/src/node/preference-backend-module.ts +33 -33
  54. package/src/node/preference-cli-contribution.ts +48 -48
@@ -1,260 +1,260 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 Ericsson and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
18
- import {
19
- TreeModelImpl,
20
- TreeWidget,
21
- CompositeTreeNode,
22
- TopDownTreeIterator,
23
- TreeNode,
24
- PreferenceSchemaProvider,
25
- PreferenceDataProperty,
26
- NodeProps,
27
- ExpandableTreeNode,
28
- SelectableTreeNode,
29
- PreferenceService,
30
- } from '@theia/core/lib/browser';
31
- import { Emitter } from '@theia/core';
32
- import { PreferencesSearchbarWidget } from './views/preference-searchbar-widget';
33
- import { PreferenceTreeGenerator } from './util/preference-tree-generator';
34
- import * as fuzzy from '@theia/core/shared/fuzzy';
35
- import { PreferencesScopeTabBar } from './views/preference-scope-tabbar-widget';
36
- import { Preference } from './util/preference-types';
37
- import { Event } from '@theia/core/lib/common';
38
- import { COMMONLY_USED_SECTION_PREFIX } from './util/preference-layout';
39
-
40
- export interface PreferenceTreeNodeProps extends NodeProps {
41
- visibleChildren: number;
42
- isExpansible?: boolean;
43
- }
44
-
45
- export interface PreferenceTreeNodeRow extends Readonly<TreeWidget.NodeRow>, PreferenceTreeNodeProps {
46
- node: Preference.TreeNode;
47
- }
48
- export enum PreferenceFilterChangeSource {
49
- Schema,
50
- Search,
51
- Scope,
52
- }
53
- export interface PreferenceFilterChangeEvent {
54
- source: PreferenceFilterChangeSource
55
- }
56
-
57
- @injectable()
58
- export class PreferenceTreeModel extends TreeModelImpl {
59
-
60
- @inject(PreferenceSchemaProvider) protected readonly schemaProvider: PreferenceSchemaProvider;
61
- @inject(PreferencesSearchbarWidget) protected readonly filterInput: PreferencesSearchbarWidget;
62
- @inject(PreferenceTreeGenerator) protected readonly treeGenerator: PreferenceTreeGenerator;
63
- @inject(PreferencesScopeTabBar) protected readonly scopeTracker: PreferencesScopeTabBar;
64
- @inject(PreferenceService) protected readonly preferenceService: PreferenceService;
65
-
66
- protected readonly onTreeFilterChangedEmitter = new Emitter<PreferenceFilterChangeEvent>();
67
- readonly onFilterChanged = this.onTreeFilterChangedEmitter.event;
68
-
69
- protected lastSearchedFuzzy: string = '';
70
- protected lastSearchedLiteral: string = '';
71
- protected lastSearchedTags: string[] = [];
72
- protected _currentScope: number = Number(Preference.DEFAULT_SCOPE.scope);
73
- protected _isFiltered: boolean = false;
74
- protected _currentRows: Map<string, PreferenceTreeNodeRow> = new Map();
75
- protected _totalVisibleLeaves = 0;
76
-
77
- get currentRows(): Readonly<Map<string, PreferenceTreeNodeRow>> {
78
- return this._currentRows;
79
- }
80
-
81
- get totalVisibleLeaves(): number {
82
- return this._totalVisibleLeaves;
83
- }
84
-
85
- get isFiltered(): boolean {
86
- return this._isFiltered;
87
- }
88
-
89
- get propertyList(): { [key: string]: PreferenceDataProperty; } {
90
- return this.schemaProvider.getCombinedSchema().properties;
91
- }
92
-
93
- get currentScope(): Preference.SelectedScopeDetails {
94
- return this.scopeTracker.currentScope;
95
- }
96
-
97
- get onSchemaChanged(): Event<CompositeTreeNode> {
98
- return this.treeGenerator.onSchemaChanged;
99
- }
100
-
101
- @postConstruct()
102
- protected override init(): void {
103
- this.doInit();
104
- }
105
-
106
- protected async doInit(): Promise<void> {
107
- super.init();
108
- this.toDispose.pushAll([
109
- this.treeGenerator.onSchemaChanged(newTree => this.handleNewSchema(newTree)),
110
- this.scopeTracker.onScopeChanged(scopeDetails => {
111
- this._currentScope = scopeDetails.scope;
112
- this.updateFilteredRows(PreferenceFilterChangeSource.Scope);
113
- }),
114
- this.filterInput.onFilterChanged(newSearchTerm => {
115
- this.lastSearchedTags = Array.from(newSearchTerm.matchAll(/@tag:([^\s]+)/g)).map(match => match[0].slice(5));
116
- const newSearchTermWithoutTags = newSearchTerm.replace(/@tag:[^\s]+/g, '');
117
- this.lastSearchedLiteral = newSearchTermWithoutTags;
118
- this.lastSearchedFuzzy = newSearchTermWithoutTags.replace(/\s/g, '');
119
- this._isFiltered = newSearchTerm.length > 2;
120
- if (this.isFiltered) {
121
- this.expandAll();
122
- } else if (CompositeTreeNode.is(this.root)) {
123
- this.collapseAll(this.root);
124
- }
125
- this.updateFilteredRows(PreferenceFilterChangeSource.Search);
126
- }),
127
- this.onFilterChanged(() => {
128
- this.filterInput.updateResultsCount(this._totalVisibleLeaves);
129
- }),
130
- this.onTreeFilterChangedEmitter,
131
- ]);
132
- await this.preferenceService.ready;
133
- this.handleNewSchema(this.treeGenerator.root);
134
- }
135
-
136
- private handleNewSchema(newRoot: CompositeTreeNode): void {
137
- this.root = newRoot;
138
- if (this.isFiltered) {
139
- this.expandAll();
140
- }
141
- this.updateFilteredRows(PreferenceFilterChangeSource.Schema);
142
- }
143
-
144
- protected updateRows(): void {
145
- const root = this.root;
146
- this._currentRows = new Map();
147
- if (root) {
148
- this._totalVisibleLeaves = 0;
149
- let index = 0;
150
-
151
- for (const node of new TopDownTreeIterator(root, {
152
- pruneCollapsed: false,
153
- pruneSiblings: true
154
- })) {
155
- if (TreeNode.isVisible(node) && Preference.TreeNode.is(node)) {
156
- const { id } = Preference.TreeNode.getGroupAndIdFromNodeId(node.id);
157
- if (CompositeTreeNode.is(node) || this.passesCurrentFilters(node, id)) {
158
- this.updateVisibleChildren(node);
159
-
160
- this._currentRows.set(node.id, {
161
- index: index++,
162
- node,
163
- depth: node.depth,
164
- visibleChildren: 0,
165
- });
166
- }
167
- }
168
- }
169
- }
170
- }
171
-
172
- protected updateFilteredRows(source: PreferenceFilterChangeSource): void {
173
- this.updateRows();
174
- this.onTreeFilterChangedEmitter.fire({ source });
175
- }
176
-
177
- protected passesCurrentFilters(node: Preference.LeafNode, prefID: string): boolean {
178
- if (!this.schemaProvider.isValidInScope(prefID, this._currentScope)) {
179
- return false;
180
- }
181
- if (!this._isFiltered) {
182
- return true;
183
- }
184
- // When filtering, VSCode will render an item that is present in the commonly used section only once but render both its possible parents in the left-hand tree.
185
- // E.g. searching for editor.renderWhitespace will show one item in the main panel, but both 'Commonly Used' and 'Text Editor' in the left tree.
186
- // That seems counterintuitive and introduces a number of special cases, so I prefer to remove the commonly used section entirely when the user searches.
187
- if (node.id.startsWith(COMMONLY_USED_SECTION_PREFIX)) {
188
- return false;
189
- }
190
- if (!this.lastSearchedTags.every(tag => node.preference.data.tags?.includes(tag))) {
191
- return false;
192
- }
193
- return fuzzy.test(this.lastSearchedFuzzy, prefID) // search matches preference name.
194
- // search matches description. Fuzzy isn't ideal here because the score depends on the order of discovery.
195
- || (node.preference.data.description ?? '').includes(this.lastSearchedLiteral);
196
- }
197
-
198
- protected override isVisibleSelectableNode(node: TreeNode): node is SelectableTreeNode {
199
- return CompositeTreeNode.is(node) && !!this._currentRows.get(node.id)?.visibleChildren;
200
- }
201
-
202
- protected updateVisibleChildren(node: TreeNode): void {
203
- if (!CompositeTreeNode.is(node)) {
204
- this._totalVisibleLeaves++;
205
- let nextParent = node.parent?.id && this._currentRows.get(node.parent?.id);
206
- while (nextParent && nextParent.node !== this.root) {
207
- if (nextParent) {
208
- nextParent.visibleChildren += 1;
209
- }
210
- nextParent = nextParent.node.parent?.id && this._currentRows.get(nextParent.node.parent?.id);
211
- if (nextParent) {
212
- nextParent.isExpansible = true;
213
- }
214
- }
215
- }
216
- }
217
-
218
- collapseAllExcept(openNode: TreeNode | undefined): void {
219
- const openNodes: TreeNode[] = [];
220
- while (ExpandableTreeNode.is(openNode)) {
221
- openNodes.push(openNode);
222
- this.expandNode(openNode);
223
- openNode = openNode.parent;
224
- }
225
- if (CompositeTreeNode.is(this.root)) {
226
- this.root.children.forEach(child => {
227
- if (!openNodes.includes(child) && ExpandableTreeNode.is(child)) {
228
- this.collapseNode(child);
229
- }
230
- });
231
- }
232
- }
233
-
234
- protected expandAll(): void {
235
- if (CompositeTreeNode.is(this.root)) {
236
- this.root.children.forEach(child => {
237
- if (ExpandableTreeNode.is(child)) {
238
- this.expandNode(child);
239
- }
240
- });
241
- }
242
- }
243
-
244
- getNodeFromPreferenceId(id: string): Preference.TreeNode | undefined {
245
- const node = this.getNode(this.treeGenerator.getNodeId(id));
246
- return node && Preference.TreeNode.is(node) ? node : undefined;
247
- }
248
-
249
- /**
250
- * @returns true if selection changed, false otherwise
251
- */
252
- selectIfNotSelected(node: SelectableTreeNode): boolean {
253
- const currentlySelected = this.selectedNodes[0];
254
- if (node !== currentlySelected) {
255
- this.selectNode(node);
256
- return true;
257
- }
258
- return false;
259
- }
260
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2020 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
18
+ import {
19
+ TreeModelImpl,
20
+ TreeWidget,
21
+ CompositeTreeNode,
22
+ TopDownTreeIterator,
23
+ TreeNode,
24
+ PreferenceSchemaProvider,
25
+ PreferenceDataProperty,
26
+ NodeProps,
27
+ ExpandableTreeNode,
28
+ SelectableTreeNode,
29
+ PreferenceService,
30
+ } from '@theia/core/lib/browser';
31
+ import { Emitter } from '@theia/core';
32
+ import { PreferencesSearchbarWidget } from './views/preference-searchbar-widget';
33
+ import { PreferenceTreeGenerator } from './util/preference-tree-generator';
34
+ import * as fuzzy from '@theia/core/shared/fuzzy';
35
+ import { PreferencesScopeTabBar } from './views/preference-scope-tabbar-widget';
36
+ import { Preference } from './util/preference-types';
37
+ import { Event } from '@theia/core/lib/common';
38
+ import { COMMONLY_USED_SECTION_PREFIX } from './util/preference-layout';
39
+
40
+ export interface PreferenceTreeNodeProps extends NodeProps {
41
+ visibleChildren: number;
42
+ isExpansible?: boolean;
43
+ }
44
+
45
+ export interface PreferenceTreeNodeRow extends Readonly<TreeWidget.NodeRow>, PreferenceTreeNodeProps {
46
+ node: Preference.TreeNode;
47
+ }
48
+ export enum PreferenceFilterChangeSource {
49
+ Schema,
50
+ Search,
51
+ Scope,
52
+ }
53
+ export interface PreferenceFilterChangeEvent {
54
+ source: PreferenceFilterChangeSource
55
+ }
56
+
57
+ @injectable()
58
+ export class PreferenceTreeModel extends TreeModelImpl {
59
+
60
+ @inject(PreferenceSchemaProvider) protected readonly schemaProvider: PreferenceSchemaProvider;
61
+ @inject(PreferencesSearchbarWidget) protected readonly filterInput: PreferencesSearchbarWidget;
62
+ @inject(PreferenceTreeGenerator) protected readonly treeGenerator: PreferenceTreeGenerator;
63
+ @inject(PreferencesScopeTabBar) protected readonly scopeTracker: PreferencesScopeTabBar;
64
+ @inject(PreferenceService) protected readonly preferenceService: PreferenceService;
65
+
66
+ protected readonly onTreeFilterChangedEmitter = new Emitter<PreferenceFilterChangeEvent>();
67
+ readonly onFilterChanged = this.onTreeFilterChangedEmitter.event;
68
+
69
+ protected lastSearchedFuzzy: string = '';
70
+ protected lastSearchedLiteral: string = '';
71
+ protected lastSearchedTags: string[] = [];
72
+ protected _currentScope: number = Number(Preference.DEFAULT_SCOPE.scope);
73
+ protected _isFiltered: boolean = false;
74
+ protected _currentRows: Map<string, PreferenceTreeNodeRow> = new Map();
75
+ protected _totalVisibleLeaves = 0;
76
+
77
+ get currentRows(): Readonly<Map<string, PreferenceTreeNodeRow>> {
78
+ return this._currentRows;
79
+ }
80
+
81
+ get totalVisibleLeaves(): number {
82
+ return this._totalVisibleLeaves;
83
+ }
84
+
85
+ get isFiltered(): boolean {
86
+ return this._isFiltered;
87
+ }
88
+
89
+ get propertyList(): { [key: string]: PreferenceDataProperty; } {
90
+ return this.schemaProvider.getCombinedSchema().properties;
91
+ }
92
+
93
+ get currentScope(): Preference.SelectedScopeDetails {
94
+ return this.scopeTracker.currentScope;
95
+ }
96
+
97
+ get onSchemaChanged(): Event<CompositeTreeNode> {
98
+ return this.treeGenerator.onSchemaChanged;
99
+ }
100
+
101
+ @postConstruct()
102
+ protected override init(): void {
103
+ this.doInit();
104
+ }
105
+
106
+ protected async doInit(): Promise<void> {
107
+ super.init();
108
+ this.toDispose.pushAll([
109
+ this.treeGenerator.onSchemaChanged(newTree => this.handleNewSchema(newTree)),
110
+ this.scopeTracker.onScopeChanged(scopeDetails => {
111
+ this._currentScope = scopeDetails.scope;
112
+ this.updateFilteredRows(PreferenceFilterChangeSource.Scope);
113
+ }),
114
+ this.filterInput.onFilterChanged(newSearchTerm => {
115
+ this.lastSearchedTags = Array.from(newSearchTerm.matchAll(/@tag:([^\s]+)/g)).map(match => match[0].slice(5));
116
+ const newSearchTermWithoutTags = newSearchTerm.replace(/@tag:[^\s]+/g, '');
117
+ this.lastSearchedLiteral = newSearchTermWithoutTags;
118
+ this.lastSearchedFuzzy = newSearchTermWithoutTags.replace(/\s/g, '');
119
+ this._isFiltered = newSearchTerm.length > 2;
120
+ if (this.isFiltered) {
121
+ this.expandAll();
122
+ } else if (CompositeTreeNode.is(this.root)) {
123
+ this.collapseAll(this.root);
124
+ }
125
+ this.updateFilteredRows(PreferenceFilterChangeSource.Search);
126
+ }),
127
+ this.onFilterChanged(() => {
128
+ this.filterInput.updateResultsCount(this._totalVisibleLeaves);
129
+ }),
130
+ this.onTreeFilterChangedEmitter,
131
+ ]);
132
+ await this.preferenceService.ready;
133
+ this.handleNewSchema(this.treeGenerator.root);
134
+ }
135
+
136
+ private handleNewSchema(newRoot: CompositeTreeNode): void {
137
+ this.root = newRoot;
138
+ if (this.isFiltered) {
139
+ this.expandAll();
140
+ }
141
+ this.updateFilteredRows(PreferenceFilterChangeSource.Schema);
142
+ }
143
+
144
+ protected updateRows(): void {
145
+ const root = this.root;
146
+ this._currentRows = new Map();
147
+ if (root) {
148
+ this._totalVisibleLeaves = 0;
149
+ let index = 0;
150
+
151
+ for (const node of new TopDownTreeIterator(root, {
152
+ pruneCollapsed: false,
153
+ pruneSiblings: true
154
+ })) {
155
+ if (TreeNode.isVisible(node) && Preference.TreeNode.is(node)) {
156
+ const { id } = Preference.TreeNode.getGroupAndIdFromNodeId(node.id);
157
+ if (CompositeTreeNode.is(node) || this.passesCurrentFilters(node, id)) {
158
+ this.updateVisibleChildren(node);
159
+
160
+ this._currentRows.set(node.id, {
161
+ index: index++,
162
+ node,
163
+ depth: node.depth,
164
+ visibleChildren: 0,
165
+ });
166
+ }
167
+ }
168
+ }
169
+ }
170
+ }
171
+
172
+ protected updateFilteredRows(source: PreferenceFilterChangeSource): void {
173
+ this.updateRows();
174
+ this.onTreeFilterChangedEmitter.fire({ source });
175
+ }
176
+
177
+ protected passesCurrentFilters(node: Preference.LeafNode, prefID: string): boolean {
178
+ if (!this.schemaProvider.isValidInScope(prefID, this._currentScope)) {
179
+ return false;
180
+ }
181
+ if (!this._isFiltered) {
182
+ return true;
183
+ }
184
+ // When filtering, VSCode will render an item that is present in the commonly used section only once but render both its possible parents in the left-hand tree.
185
+ // E.g. searching for editor.renderWhitespace will show one item in the main panel, but both 'Commonly Used' and 'Text Editor' in the left tree.
186
+ // That seems counterintuitive and introduces a number of special cases, so I prefer to remove the commonly used section entirely when the user searches.
187
+ if (node.id.startsWith(COMMONLY_USED_SECTION_PREFIX)) {
188
+ return false;
189
+ }
190
+ if (!this.lastSearchedTags.every(tag => node.preference.data.tags?.includes(tag))) {
191
+ return false;
192
+ }
193
+ return fuzzy.test(this.lastSearchedFuzzy, prefID) // search matches preference name.
194
+ // search matches description. Fuzzy isn't ideal here because the score depends on the order of discovery.
195
+ || (node.preference.data.description ?? '').includes(this.lastSearchedLiteral);
196
+ }
197
+
198
+ protected override isVisibleSelectableNode(node: TreeNode): node is SelectableTreeNode {
199
+ return CompositeTreeNode.is(node) && !!this._currentRows.get(node.id)?.visibleChildren;
200
+ }
201
+
202
+ protected updateVisibleChildren(node: TreeNode): void {
203
+ if (!CompositeTreeNode.is(node)) {
204
+ this._totalVisibleLeaves++;
205
+ let nextParent = node.parent?.id && this._currentRows.get(node.parent?.id);
206
+ while (nextParent && nextParent.node !== this.root) {
207
+ if (nextParent) {
208
+ nextParent.visibleChildren += 1;
209
+ }
210
+ nextParent = nextParent.node.parent?.id && this._currentRows.get(nextParent.node.parent?.id);
211
+ if (nextParent) {
212
+ nextParent.isExpansible = true;
213
+ }
214
+ }
215
+ }
216
+ }
217
+
218
+ collapseAllExcept(openNode: TreeNode | undefined): void {
219
+ const openNodes: TreeNode[] = [];
220
+ while (ExpandableTreeNode.is(openNode)) {
221
+ openNodes.push(openNode);
222
+ this.expandNode(openNode);
223
+ openNode = openNode.parent;
224
+ }
225
+ if (CompositeTreeNode.is(this.root)) {
226
+ this.root.children.forEach(child => {
227
+ if (!openNodes.includes(child) && ExpandableTreeNode.is(child)) {
228
+ this.collapseNode(child);
229
+ }
230
+ });
231
+ }
232
+ }
233
+
234
+ protected expandAll(): void {
235
+ if (CompositeTreeNode.is(this.root)) {
236
+ this.root.children.forEach(child => {
237
+ if (ExpandableTreeNode.is(child)) {
238
+ this.expandNode(child);
239
+ }
240
+ });
241
+ }
242
+ }
243
+
244
+ getNodeFromPreferenceId(id: string): Preference.TreeNode | undefined {
245
+ const node = this.getNode(this.treeGenerator.getNodeId(id));
246
+ return node && Preference.TreeNode.is(node) ? node : undefined;
247
+ }
248
+
249
+ /**
250
+ * @returns true if selection changed, false otherwise
251
+ */
252
+ selectIfNotSelected(node: SelectableTreeNode): boolean {
253
+ const currentlySelected = this.selectedNodes[0];
254
+ if (node !== currentlySelected) {
255
+ this.selectNode(node);
256
+ return true;
257
+ }
258
+ return false;
259
+ }
260
+ }