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

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 (74) hide show
  1. package/README.md +81 -81
  2. package/lib/browser/preference-tree-model.d.ts.map +1 -1
  3. package/lib/browser/preference-tree-model.js +5 -2
  4. package/lib/browser/preference-tree-model.js.map +1 -1
  5. package/lib/browser/util/preference-layout.d.ts.map +1 -1
  6. package/lib/browser/util/preference-layout.js +4 -0
  7. package/lib/browser/util/preference-layout.js.map +1 -1
  8. package/lib/browser/util/preference-tree-generator.d.ts +14 -2
  9. package/lib/browser/util/preference-tree-generator.d.ts.map +1 -1
  10. package/lib/browser/util/preference-tree-generator.js +89 -26
  11. package/lib/browser/util/preference-tree-generator.js.map +1 -1
  12. package/lib/browser/util/preference-tree-label-provider.d.ts.map +1 -1
  13. package/lib/browser/util/preference-tree-label-provider.js +4 -11
  14. package/lib/browser/util/preference-tree-label-provider.js.map +1 -1
  15. package/lib/browser/util/preference-types.d.ts +4 -2
  16. package/lib/browser/util/preference-types.d.ts.map +1 -1
  17. package/lib/browser/util/preference-types.js.map +1 -1
  18. package/lib/browser/views/preference-tree-widget.d.ts +2 -0
  19. package/lib/browser/views/preference-tree-widget.d.ts.map +1 -1
  20. package/lib/browser/views/preference-tree-widget.js +10 -1
  21. package/lib/browser/views/preference-tree-widget.js.map +1 -1
  22. package/package.json +9 -9
  23. package/src/browser/abstract-resource-preference-provider.spec.ts +95 -95
  24. package/src/browser/abstract-resource-preference-provider.ts +232 -232
  25. package/src/browser/folder-preference-provider.ts +58 -58
  26. package/src/browser/folders-preferences-provider.ts +244 -244
  27. package/src/browser/index.ts +23 -23
  28. package/src/browser/monaco-jsonc-editor.ts +67 -67
  29. package/src/browser/package.spec.ts +28 -28
  30. package/src/browser/preference-bindings.ts +65 -65
  31. package/src/browser/preference-frontend-contribution.ts +38 -38
  32. package/src/browser/preference-frontend-module.ts +66 -66
  33. package/src/browser/preference-open-handler.ts +53 -53
  34. package/src/browser/preference-transaction-manager.ts +287 -287
  35. package/src/browser/preference-tree-model.ts +260 -257
  36. package/src/browser/preferences-contribution.ts +263 -263
  37. package/src/browser/preferences-json-schema-contribution.ts +86 -86
  38. package/src/browser/preferences-monaco-contribution.ts +27 -27
  39. package/src/browser/section-preference-provider.ts +83 -83
  40. package/src/browser/style/index.css +506 -506
  41. package/src/browser/style/preference-array.css +94 -94
  42. package/src/browser/style/preference-context-menu.css +74 -74
  43. package/src/browser/style/preference-file.css +31 -31
  44. package/src/browser/style/preference-object.css +49 -49
  45. package/src/browser/style/search-input.css +66 -66
  46. package/src/browser/user-configs-preference-provider.ts +127 -127
  47. package/src/browser/user-preference-provider.ts +35 -35
  48. package/src/browser/util/preference-layout.ts +381 -377
  49. package/src/browser/util/preference-scope-command-manager.ts +75 -75
  50. package/src/browser/util/preference-tree-generator.ts +260 -190
  51. package/src/browser/util/preference-tree-label-provider.spec.ts +110 -110
  52. package/src/browser/util/preference-tree-label-provider.ts +72 -78
  53. package/src/browser/util/preference-types.ts +177 -175
  54. package/src/browser/views/components/preference-array-input.ts +174 -174
  55. package/src/browser/views/components/preference-boolean-input.ts +69 -69
  56. package/src/browser/views/components/preference-file-input.ts +104 -104
  57. package/src/browser/views/components/preference-json-input.ts +78 -78
  58. package/src/browser/views/components/preference-markdown-renderer.ts +68 -68
  59. package/src/browser/views/components/preference-node-renderer-creator.ts +141 -141
  60. package/src/browser/views/components/preference-node-renderer.ts +477 -477
  61. package/src/browser/views/components/preference-number-input.ts +147 -147
  62. package/src/browser/views/components/preference-select-input.ts +131 -131
  63. package/src/browser/views/components/preference-string-input.ts +76 -76
  64. package/src/browser/views/preference-editor-widget.ts +349 -349
  65. package/src/browser/views/preference-scope-tabbar-widget.tsx +344 -344
  66. package/src/browser/views/preference-searchbar-widget.tsx +183 -183
  67. package/src/browser/views/preference-tree-widget.tsx +102 -93
  68. package/src/browser/views/preference-widget-bindings.ts +102 -102
  69. package/src/browser/views/preference-widget.tsx +118 -118
  70. package/src/browser/workspace-file-preference-provider.ts +100 -100
  71. package/src/browser/workspace-preference-provider.ts +134 -134
  72. package/src/common/cli-preferences.ts +22 -22
  73. package/src/node/preference-backend-module.ts +33 -33
  74. package/src/node/preference-cli-contribution.ts +48 -48
@@ -1,102 +1,102 @@
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
- import { createTreeContainer, LabelProviderContribution, WidgetFactory } from '@theia/core/lib/browser';
17
- import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider';
18
- import { Container, interfaces } from '@theia/core/shared/inversify';
19
- import { PreferenceTreeModel } from '../preference-tree-model';
20
- import { PreferenceTreeLabelProvider } from '../util/preference-tree-label-provider';
21
- import { Preference } from '../util/preference-types';
22
- import { PreferenceArrayInputRenderer, PreferenceArrayInputRendererContribution } from './components/preference-array-input';
23
- import { PreferenceBooleanInputRenderer, PreferenceBooleanInputRendererContribution } from './components/preference-boolean-input';
24
- import { PreferenceSingleFilePathInputRenderer, PreferenceSingleFilePathInputRendererContribution } from './components/preference-file-input';
25
- import { PreferenceJSONLinkRenderer, PreferenceJSONLinkRendererContribution } from './components/preference-json-input';
26
- import { PreferenceHeaderRenderer, PreferenceNodeRendererFactory } from './components/preference-node-renderer';
27
- import {
28
- DefaultPreferenceNodeRendererCreatorRegistry, PreferenceHeaderRendererContribution, PreferenceNodeRendererContribution, PreferenceNodeRendererCreatorRegistry
29
- } from './components/preference-node-renderer-creator';
30
- import { PreferenceNumberInputRenderer, PreferenceNumberInputRendererContribution } from './components/preference-number-input';
31
- import { PreferenceSelectInputRenderer, PreferenceSelectInputRendererContribution } from './components/preference-select-input';
32
- import { PreferenceStringInputRenderer, PreferenceStringInputRendererContribution } from './components/preference-string-input';
33
- import { PreferenceMarkdownRenderer } from './components/preference-markdown-renderer';
34
- import { PreferencesEditorWidget } from './preference-editor-widget';
35
- import { PreferencesScopeTabBar } from './preference-scope-tabbar-widget';
36
- import { PreferencesSearchbarWidget } from './preference-searchbar-widget';
37
- import { PreferencesTreeWidget } from './preference-tree-widget';
38
- import { PreferencesWidget } from './preference-widget';
39
-
40
- export function bindPreferencesWidgets(bind: interfaces.Bind): void {
41
- bind(PreferenceTreeLabelProvider).toSelf().inSingletonScope();
42
- bind(LabelProviderContribution).toService(PreferenceTreeLabelProvider);
43
- bind(PreferencesWidget)
44
- .toDynamicValue(({ container }) => createPreferencesWidgetContainer(container).get(PreferencesWidget))
45
- .inSingletonScope();
46
- bind(WidgetFactory).toDynamicValue(({ container }) => ({
47
- id: PreferencesWidget.ID,
48
- createWidget: () => container.get(PreferencesWidget)
49
- })).inSingletonScope();
50
-
51
- bindContributionProvider(bind, PreferenceNodeRendererContribution);
52
-
53
- bind(PreferenceSelectInputRenderer).toSelf();
54
- bind(PreferenceNodeRendererContribution).to(PreferenceSelectInputRendererContribution).inSingletonScope();
55
-
56
- bind(PreferenceArrayInputRenderer).toSelf();
57
- bind(PreferenceNodeRendererContribution).to(PreferenceArrayInputRendererContribution).inSingletonScope();
58
-
59
- bind(PreferenceStringInputRenderer).toSelf();
60
- bind(PreferenceNodeRendererContribution).to(PreferenceStringInputRendererContribution).inSingletonScope();
61
-
62
- bind(PreferenceBooleanInputRenderer).toSelf();
63
- bind(PreferenceNodeRendererContribution).to(PreferenceBooleanInputRendererContribution).inSingletonScope();
64
-
65
- bind(PreferenceNumberInputRenderer).toSelf();
66
- bind(PreferenceNodeRendererContribution).to(PreferenceNumberInputRendererContribution).inSingletonScope();
67
-
68
- bind(PreferenceJSONLinkRenderer).toSelf();
69
- bind(PreferenceNodeRendererContribution).to(PreferenceJSONLinkRendererContribution).inSingletonScope();
70
-
71
- bind(PreferenceHeaderRenderer).toSelf();
72
- bind(PreferenceNodeRendererContribution).to(PreferenceHeaderRendererContribution).inSingletonScope();
73
-
74
- bind(PreferenceSingleFilePathInputRenderer).toSelf();
75
- bind(PreferenceNodeRendererContribution).to(PreferenceSingleFilePathInputRendererContribution).inSingletonScope();
76
-
77
- bind(DefaultPreferenceNodeRendererCreatorRegistry).toSelf().inSingletonScope();
78
- bind(PreferenceNodeRendererCreatorRegistry).toService(DefaultPreferenceNodeRendererCreatorRegistry);
79
- }
80
-
81
- export function createPreferencesWidgetContainer(parent: interfaces.Container): Container {
82
- const child = createTreeContainer(parent, {
83
- model: PreferenceTreeModel,
84
- widget: PreferencesTreeWidget,
85
- props: { search: false }
86
- });
87
- child.bind(PreferencesEditorWidget).toSelf();
88
-
89
- child.bind(PreferencesSearchbarWidget).toSelf();
90
- child.bind(PreferencesScopeTabBar).toSelf();
91
- child.bind(PreferencesWidget).toSelf();
92
-
93
- child.bind(PreferenceNodeRendererFactory).toFactory(({ container }) => (node: Preference.TreeNode) => {
94
- const registry = container.get<PreferenceNodeRendererCreatorRegistry>(PreferenceNodeRendererCreatorRegistry);
95
- const creator = registry.getPreferenceNodeRendererCreator(node);
96
- return creator.createRenderer(node, container);
97
- });
98
-
99
- child.bind(PreferenceMarkdownRenderer).toSelf().inSingletonScope();
100
-
101
- return child;
102
- }
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
+ import { createTreeContainer, LabelProviderContribution, WidgetFactory } from '@theia/core/lib/browser';
17
+ import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider';
18
+ import { Container, interfaces } from '@theia/core/shared/inversify';
19
+ import { PreferenceTreeModel } from '../preference-tree-model';
20
+ import { PreferenceTreeLabelProvider } from '../util/preference-tree-label-provider';
21
+ import { Preference } from '../util/preference-types';
22
+ import { PreferenceArrayInputRenderer, PreferenceArrayInputRendererContribution } from './components/preference-array-input';
23
+ import { PreferenceBooleanInputRenderer, PreferenceBooleanInputRendererContribution } from './components/preference-boolean-input';
24
+ import { PreferenceSingleFilePathInputRenderer, PreferenceSingleFilePathInputRendererContribution } from './components/preference-file-input';
25
+ import { PreferenceJSONLinkRenderer, PreferenceJSONLinkRendererContribution } from './components/preference-json-input';
26
+ import { PreferenceHeaderRenderer, PreferenceNodeRendererFactory } from './components/preference-node-renderer';
27
+ import {
28
+ DefaultPreferenceNodeRendererCreatorRegistry, PreferenceHeaderRendererContribution, PreferenceNodeRendererContribution, PreferenceNodeRendererCreatorRegistry
29
+ } from './components/preference-node-renderer-creator';
30
+ import { PreferenceNumberInputRenderer, PreferenceNumberInputRendererContribution } from './components/preference-number-input';
31
+ import { PreferenceSelectInputRenderer, PreferenceSelectInputRendererContribution } from './components/preference-select-input';
32
+ import { PreferenceStringInputRenderer, PreferenceStringInputRendererContribution } from './components/preference-string-input';
33
+ import { PreferenceMarkdownRenderer } from './components/preference-markdown-renderer';
34
+ import { PreferencesEditorWidget } from './preference-editor-widget';
35
+ import { PreferencesScopeTabBar } from './preference-scope-tabbar-widget';
36
+ import { PreferencesSearchbarWidget } from './preference-searchbar-widget';
37
+ import { PreferencesTreeWidget } from './preference-tree-widget';
38
+ import { PreferencesWidget } from './preference-widget';
39
+
40
+ export function bindPreferencesWidgets(bind: interfaces.Bind): void {
41
+ bind(PreferenceTreeLabelProvider).toSelf().inSingletonScope();
42
+ bind(LabelProviderContribution).toService(PreferenceTreeLabelProvider);
43
+ bind(PreferencesWidget)
44
+ .toDynamicValue(({ container }) => createPreferencesWidgetContainer(container).get(PreferencesWidget))
45
+ .inSingletonScope();
46
+ bind(WidgetFactory).toDynamicValue(({ container }) => ({
47
+ id: PreferencesWidget.ID,
48
+ createWidget: () => container.get(PreferencesWidget)
49
+ })).inSingletonScope();
50
+
51
+ bindContributionProvider(bind, PreferenceNodeRendererContribution);
52
+
53
+ bind(PreferenceSelectInputRenderer).toSelf();
54
+ bind(PreferenceNodeRendererContribution).to(PreferenceSelectInputRendererContribution).inSingletonScope();
55
+
56
+ bind(PreferenceArrayInputRenderer).toSelf();
57
+ bind(PreferenceNodeRendererContribution).to(PreferenceArrayInputRendererContribution).inSingletonScope();
58
+
59
+ bind(PreferenceStringInputRenderer).toSelf();
60
+ bind(PreferenceNodeRendererContribution).to(PreferenceStringInputRendererContribution).inSingletonScope();
61
+
62
+ bind(PreferenceBooleanInputRenderer).toSelf();
63
+ bind(PreferenceNodeRendererContribution).to(PreferenceBooleanInputRendererContribution).inSingletonScope();
64
+
65
+ bind(PreferenceNumberInputRenderer).toSelf();
66
+ bind(PreferenceNodeRendererContribution).to(PreferenceNumberInputRendererContribution).inSingletonScope();
67
+
68
+ bind(PreferenceJSONLinkRenderer).toSelf();
69
+ bind(PreferenceNodeRendererContribution).to(PreferenceJSONLinkRendererContribution).inSingletonScope();
70
+
71
+ bind(PreferenceHeaderRenderer).toSelf();
72
+ bind(PreferenceNodeRendererContribution).to(PreferenceHeaderRendererContribution).inSingletonScope();
73
+
74
+ bind(PreferenceSingleFilePathInputRenderer).toSelf();
75
+ bind(PreferenceNodeRendererContribution).to(PreferenceSingleFilePathInputRendererContribution).inSingletonScope();
76
+
77
+ bind(DefaultPreferenceNodeRendererCreatorRegistry).toSelf().inSingletonScope();
78
+ bind(PreferenceNodeRendererCreatorRegistry).toService(DefaultPreferenceNodeRendererCreatorRegistry);
79
+ }
80
+
81
+ export function createPreferencesWidgetContainer(parent: interfaces.Container): Container {
82
+ const child = createTreeContainer(parent, {
83
+ model: PreferenceTreeModel,
84
+ widget: PreferencesTreeWidget,
85
+ props: { search: false }
86
+ });
87
+ child.bind(PreferencesEditorWidget).toSelf();
88
+
89
+ child.bind(PreferencesSearchbarWidget).toSelf();
90
+ child.bind(PreferencesScopeTabBar).toSelf();
91
+ child.bind(PreferencesWidget).toSelf();
92
+
93
+ child.bind(PreferenceNodeRendererFactory).toFactory(({ container }) => (node: Preference.TreeNode) => {
94
+ const registry = container.get<PreferenceNodeRendererCreatorRegistry>(PreferenceNodeRendererCreatorRegistry);
95
+ const creator = registry.getPreferenceNodeRendererCreator(node);
96
+ return creator.createRenderer(node, container);
97
+ });
98
+
99
+ child.bind(PreferenceMarkdownRenderer).toSelf().inSingletonScope();
100
+
101
+ return child;
102
+ }
@@ -1,118 +1,118 @@
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 { postConstruct, injectable, inject } from '@theia/core/shared/inversify';
18
- import { Panel, Widget, Message, StatefulWidget, PreferenceScope, codicon } from '@theia/core/lib/browser';
19
- import { PreferencesEditorState, PreferencesEditorWidget } from './preference-editor-widget';
20
- import { PreferencesTreeWidget } from './preference-tree-widget';
21
- import { PreferencesSearchbarState, PreferencesSearchbarWidget } from './preference-searchbar-widget';
22
- import { PreferencesScopeTabBar, PreferencesScopeTabBarState } from './preference-scope-tabbar-widget';
23
- import { Preference } from '../util/preference-types';
24
- import URI from '@theia/core/lib/common/uri';
25
- import { nls } from '@theia/core/lib/common/nls';
26
-
27
- interface PreferencesWidgetState {
28
- scopeTabBarState: PreferencesScopeTabBarState,
29
- editorState: PreferencesEditorState,
30
- searchbarWidgetState: PreferencesSearchbarState,
31
- }
32
-
33
- @injectable()
34
- export class PreferencesWidget extends Panel implements StatefulWidget {
35
- /**
36
- * The widget `id`.
37
- */
38
- static readonly ID = 'settings_widget';
39
- /**
40
- * The widget `label` which is used for display purposes.
41
- */
42
- static readonly LABEL = nls.localizeByDefault('Settings');
43
-
44
- @inject(PreferencesEditorWidget) protected readonly editorWidget: PreferencesEditorWidget;
45
- @inject(PreferencesTreeWidget) protected readonly treeWidget: PreferencesTreeWidget;
46
- @inject(PreferencesSearchbarWidget) protected readonly searchbarWidget: PreferencesSearchbarWidget;
47
- @inject(PreferencesScopeTabBar) protected readonly tabBarWidget: PreferencesScopeTabBar;
48
-
49
- get currentScope(): Preference.SelectedScopeDetails {
50
- return this.tabBarWidget.currentScope;
51
- }
52
-
53
- setSearchTerm(query: string): Promise<void> {
54
- return this.searchbarWidget.updateSearchTerm(query);
55
- }
56
-
57
- setScope(scope: PreferenceScope.User | PreferenceScope.Workspace | URI): void {
58
- this.tabBarWidget.setScope(scope);
59
- }
60
-
61
- protected override onResize(msg: Widget.ResizeMessage): void {
62
- super.onResize(msg);
63
- if (msg.width < 600 && this.treeWidget && !this.treeWidget.isHidden) {
64
- this.treeWidget.hide();
65
- this.editorWidget.addClass('full-pane');
66
- } else if (msg.width >= 600 && this.treeWidget && this.treeWidget.isHidden) {
67
- this.treeWidget.show();
68
- this.editorWidget.removeClass('full-pane');
69
- }
70
- }
71
-
72
- protected override onActivateRequest(msg: Message): void {
73
- super.onActivateRequest(msg);
74
- this.searchbarWidget.focus();
75
- }
76
-
77
- @postConstruct()
78
- protected init(): void {
79
- this.id = PreferencesWidget.ID;
80
- this.title.label = PreferencesWidget.LABEL;
81
- this.title.caption = PreferencesWidget.LABEL;
82
- this.title.closable = true;
83
- this.addClass('theia-settings-container');
84
- this.title.iconClass = codicon('settings');
85
-
86
- this.searchbarWidget.addClass('preferences-searchbar-widget');
87
- this.addWidget(this.searchbarWidget);
88
-
89
- this.tabBarWidget.addClass('preferences-tabbar-widget');
90
- this.addWidget(this.tabBarWidget);
91
-
92
- this.treeWidget.addClass('preferences-tree-widget');
93
- this.addWidget(this.treeWidget);
94
-
95
- this.editorWidget.addClass('preferences-editor-widget');
96
- this.addWidget(this.editorWidget);
97
-
98
- this.update();
99
- }
100
-
101
- getPreviewNode(): Node | undefined {
102
- return this.node;
103
- }
104
-
105
- storeState(): PreferencesWidgetState {
106
- return {
107
- scopeTabBarState: this.tabBarWidget.storeState(),
108
- editorState: this.editorWidget.storeState(),
109
- searchbarWidgetState: this.searchbarWidget.storeState(),
110
- };
111
- }
112
-
113
- restoreState(state: PreferencesWidgetState): void {
114
- this.tabBarWidget.restoreState(state.scopeTabBarState);
115
- this.editorWidget.restoreState(state.editorState);
116
- this.searchbarWidget.restoreState(state.searchbarWidgetState);
117
- }
118
- }
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 { postConstruct, injectable, inject } from '@theia/core/shared/inversify';
18
+ import { Panel, Widget, Message, StatefulWidget, PreferenceScope, codicon } from '@theia/core/lib/browser';
19
+ import { PreferencesEditorState, PreferencesEditorWidget } from './preference-editor-widget';
20
+ import { PreferencesTreeWidget } from './preference-tree-widget';
21
+ import { PreferencesSearchbarState, PreferencesSearchbarWidget } from './preference-searchbar-widget';
22
+ import { PreferencesScopeTabBar, PreferencesScopeTabBarState } from './preference-scope-tabbar-widget';
23
+ import { Preference } from '../util/preference-types';
24
+ import URI from '@theia/core/lib/common/uri';
25
+ import { nls } from '@theia/core/lib/common/nls';
26
+
27
+ interface PreferencesWidgetState {
28
+ scopeTabBarState: PreferencesScopeTabBarState,
29
+ editorState: PreferencesEditorState,
30
+ searchbarWidgetState: PreferencesSearchbarState,
31
+ }
32
+
33
+ @injectable()
34
+ export class PreferencesWidget extends Panel implements StatefulWidget {
35
+ /**
36
+ * The widget `id`.
37
+ */
38
+ static readonly ID = 'settings_widget';
39
+ /**
40
+ * The widget `label` which is used for display purposes.
41
+ */
42
+ static readonly LABEL = nls.localizeByDefault('Settings');
43
+
44
+ @inject(PreferencesEditorWidget) protected readonly editorWidget: PreferencesEditorWidget;
45
+ @inject(PreferencesTreeWidget) protected readonly treeWidget: PreferencesTreeWidget;
46
+ @inject(PreferencesSearchbarWidget) protected readonly searchbarWidget: PreferencesSearchbarWidget;
47
+ @inject(PreferencesScopeTabBar) protected readonly tabBarWidget: PreferencesScopeTabBar;
48
+
49
+ get currentScope(): Preference.SelectedScopeDetails {
50
+ return this.tabBarWidget.currentScope;
51
+ }
52
+
53
+ setSearchTerm(query: string): Promise<void> {
54
+ return this.searchbarWidget.updateSearchTerm(query);
55
+ }
56
+
57
+ setScope(scope: PreferenceScope.User | PreferenceScope.Workspace | URI): void {
58
+ this.tabBarWidget.setScope(scope);
59
+ }
60
+
61
+ protected override onResize(msg: Widget.ResizeMessage): void {
62
+ super.onResize(msg);
63
+ if (msg.width < 600 && this.treeWidget && !this.treeWidget.isHidden) {
64
+ this.treeWidget.hide();
65
+ this.editorWidget.addClass('full-pane');
66
+ } else if (msg.width >= 600 && this.treeWidget && this.treeWidget.isHidden) {
67
+ this.treeWidget.show();
68
+ this.editorWidget.removeClass('full-pane');
69
+ }
70
+ }
71
+
72
+ protected override onActivateRequest(msg: Message): void {
73
+ super.onActivateRequest(msg);
74
+ this.searchbarWidget.focus();
75
+ }
76
+
77
+ @postConstruct()
78
+ protected init(): void {
79
+ this.id = PreferencesWidget.ID;
80
+ this.title.label = PreferencesWidget.LABEL;
81
+ this.title.caption = PreferencesWidget.LABEL;
82
+ this.title.closable = true;
83
+ this.addClass('theia-settings-container');
84
+ this.title.iconClass = codicon('settings');
85
+
86
+ this.searchbarWidget.addClass('preferences-searchbar-widget');
87
+ this.addWidget(this.searchbarWidget);
88
+
89
+ this.tabBarWidget.addClass('preferences-tabbar-widget');
90
+ this.addWidget(this.tabBarWidget);
91
+
92
+ this.treeWidget.addClass('preferences-tree-widget');
93
+ this.addWidget(this.treeWidget);
94
+
95
+ this.editorWidget.addClass('preferences-editor-widget');
96
+ this.addWidget(this.editorWidget);
97
+
98
+ this.update();
99
+ }
100
+
101
+ getPreviewNode(): Node | undefined {
102
+ return this.node;
103
+ }
104
+
105
+ storeState(): PreferencesWidgetState {
106
+ return {
107
+ scopeTabBarState: this.tabBarWidget.storeState(),
108
+ editorState: this.editorWidget.storeState(),
109
+ searchbarWidgetState: this.searchbarWidget.storeState(),
110
+ };
111
+ }
112
+
113
+ restoreState(state: PreferencesWidgetState): void {
114
+ this.tabBarWidget.restoreState(state.scopeTabBarState);
115
+ this.editorWidget.restoreState(state.editorState);
116
+ this.searchbarWidget.restoreState(state.searchbarWidgetState);
117
+ }
118
+ }
@@ -1,100 +1,100 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2019 TypeFox 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 } from '@theia/core/shared/inversify';
18
- import URI from '@theia/core/lib/common/uri';
19
- import { PreferenceScope } from '@theia/core/lib/browser/preferences';
20
- import { WorkspaceService, WorkspaceData } from '@theia/workspace/lib/browser/workspace-service';
21
- import { AbstractResourcePreferenceProvider } from './abstract-resource-preference-provider';
22
-
23
- @injectable()
24
- export class WorkspaceFilePreferenceProviderOptions {
25
- workspaceUri: URI;
26
- }
27
-
28
- export const WorkspaceFilePreferenceProviderFactory = Symbol('WorkspaceFilePreferenceProviderFactory');
29
- export type WorkspaceFilePreferenceProviderFactory = (options: WorkspaceFilePreferenceProviderOptions) => WorkspaceFilePreferenceProvider;
30
-
31
- @injectable()
32
- export class WorkspaceFilePreferenceProvider extends AbstractResourcePreferenceProvider {
33
-
34
- @inject(WorkspaceService)
35
- protected readonly workspaceService: WorkspaceService;
36
-
37
- @inject(WorkspaceFilePreferenceProviderOptions)
38
- protected readonly options: WorkspaceFilePreferenceProviderOptions;
39
-
40
- protected sectionsInsideSettings = new Set<string>();
41
-
42
- protected getUri(): URI {
43
- return this.options.workspaceUri;
44
- }
45
-
46
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
- protected override parse(content: string): any {
48
- const data = super.parse(content);
49
- if (WorkspaceData.is(data)) {
50
- const settings = { ...data.settings };
51
- for (const key of this.configurations.getSectionNames().filter(name => name !== 'settings')) {
52
- // If the user has written configuration inside the "settings" object, we will respect that.
53
- if (settings[key]) {
54
- this.sectionsInsideSettings.add(key);
55
- }
56
- // Favor sections outside the "settings" object to agree with VSCode behavior
57
- if (data[key]) {
58
- settings[key] = data[key];
59
- this.sectionsInsideSettings.delete(key);
60
- }
61
- }
62
- return settings;
63
- }
64
- return {};
65
- }
66
-
67
- protected override getPath(preferenceName: string): string[] {
68
- const firstSegment = preferenceName.split('.', 1)[0];
69
- const remainder = preferenceName.slice(firstSegment.length + 1);
70
- if (this.belongsInSection(firstSegment, remainder)) {
71
- // Default to writing sections outside the "settings" object.
72
- const path = [firstSegment];
73
- if (remainder) {
74
- path.push(remainder);
75
- }
76
- // If the user has already written this section inside the "settings" object, modify it there.
77
- if (this.sectionsInsideSettings.has(firstSegment)) {
78
- path.unshift('settings');
79
- }
80
- return path;
81
- }
82
- return ['settings'].concat(super.getPath(preferenceName) ?? []);
83
- }
84
-
85
- /**
86
- * @returns `true` if `firstSegment` is a section name (e.g. `tasks`, `launch`)
87
- */
88
- protected belongsInSection(firstSegment: string, remainder: string): boolean {
89
- return this.configurations.isSectionName(firstSegment);
90
- }
91
-
92
- getScope(): PreferenceScope {
93
- return PreferenceScope.Workspace;
94
- }
95
-
96
- override getDomain(): string[] {
97
- // workspace file is treated as part of the workspace
98
- return this.workspaceService.tryGetRoots().map(r => r.resource.toString()).concat([this.options.workspaceUri.toString()]);
99
- }
100
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2019 TypeFox 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 } from '@theia/core/shared/inversify';
18
+ import URI from '@theia/core/lib/common/uri';
19
+ import { PreferenceScope } from '@theia/core/lib/browser/preferences';
20
+ import { WorkspaceService, WorkspaceData } from '@theia/workspace/lib/browser/workspace-service';
21
+ import { AbstractResourcePreferenceProvider } from './abstract-resource-preference-provider';
22
+
23
+ @injectable()
24
+ export class WorkspaceFilePreferenceProviderOptions {
25
+ workspaceUri: URI;
26
+ }
27
+
28
+ export const WorkspaceFilePreferenceProviderFactory = Symbol('WorkspaceFilePreferenceProviderFactory');
29
+ export type WorkspaceFilePreferenceProviderFactory = (options: WorkspaceFilePreferenceProviderOptions) => WorkspaceFilePreferenceProvider;
30
+
31
+ @injectable()
32
+ export class WorkspaceFilePreferenceProvider extends AbstractResourcePreferenceProvider {
33
+
34
+ @inject(WorkspaceService)
35
+ protected readonly workspaceService: WorkspaceService;
36
+
37
+ @inject(WorkspaceFilePreferenceProviderOptions)
38
+ protected readonly options: WorkspaceFilePreferenceProviderOptions;
39
+
40
+ protected sectionsInsideSettings = new Set<string>();
41
+
42
+ protected getUri(): URI {
43
+ return this.options.workspaceUri;
44
+ }
45
+
46
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
+ protected override parse(content: string): any {
48
+ const data = super.parse(content);
49
+ if (WorkspaceData.is(data)) {
50
+ const settings = { ...data.settings };
51
+ for (const key of this.configurations.getSectionNames().filter(name => name !== 'settings')) {
52
+ // If the user has written configuration inside the "settings" object, we will respect that.
53
+ if (settings[key]) {
54
+ this.sectionsInsideSettings.add(key);
55
+ }
56
+ // Favor sections outside the "settings" object to agree with VSCode behavior
57
+ if (data[key]) {
58
+ settings[key] = data[key];
59
+ this.sectionsInsideSettings.delete(key);
60
+ }
61
+ }
62
+ return settings;
63
+ }
64
+ return {};
65
+ }
66
+
67
+ protected override getPath(preferenceName: string): string[] {
68
+ const firstSegment = preferenceName.split('.', 1)[0];
69
+ const remainder = preferenceName.slice(firstSegment.length + 1);
70
+ if (this.belongsInSection(firstSegment, remainder)) {
71
+ // Default to writing sections outside the "settings" object.
72
+ const path = [firstSegment];
73
+ if (remainder) {
74
+ path.push(remainder);
75
+ }
76
+ // If the user has already written this section inside the "settings" object, modify it there.
77
+ if (this.sectionsInsideSettings.has(firstSegment)) {
78
+ path.unshift('settings');
79
+ }
80
+ return path;
81
+ }
82
+ return ['settings'].concat(super.getPath(preferenceName) ?? []);
83
+ }
84
+
85
+ /**
86
+ * @returns `true` if `firstSegment` is a section name (e.g. `tasks`, `launch`)
87
+ */
88
+ protected belongsInSection(firstSegment: string, remainder: string): boolean {
89
+ return this.configurations.isSectionName(firstSegment);
90
+ }
91
+
92
+ getScope(): PreferenceScope {
93
+ return PreferenceScope.Workspace;
94
+ }
95
+
96
+ override getDomain(): string[] {
97
+ // workspace file is treated as part of the workspace
98
+ return this.workspaceService.tryGetRoots().map(r => r.resource.toString()).concat([this.options.workspaceUri.toString()]);
99
+ }
100
+ }