@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,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
+ }