@theia/preferences 1.45.0 → 1.46.0-next.72

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 (130) hide show
  1. package/README.md +81 -81
  2. package/lib/browser/abstract-resource-preference-provider.d.ts +47 -47
  3. package/lib/browser/abstract-resource-preference-provider.js +240 -240
  4. package/lib/browser/abstract-resource-preference-provider.spec.d.ts +1 -1
  5. package/lib/browser/abstract-resource-preference-provider.spec.js +83 -83
  6. package/lib/browser/folder-preference-provider.d.ts +20 -20
  7. package/lib/browser/folder-preference-provider.js +59 -59
  8. package/lib/browser/folders-preferences-provider.d.ts +27 -27
  9. package/lib/browser/folders-preferences-provider.js +245 -245
  10. package/lib/browser/index.d.ts +7 -7
  11. package/lib/browser/index.js +34 -34
  12. package/lib/browser/monaco-jsonc-editor.d.ts +9 -9
  13. package/lib/browser/monaco-jsonc-editor.js +80 -80
  14. package/lib/browser/package.spec.js +25 -25
  15. package/lib/browser/preference-bindings.d.ts +4 -4
  16. package/lib/browser/preference-bindings.js +63 -63
  17. package/lib/browser/preference-frontend-module.d.ts +6 -6
  18. package/lib/browser/preference-frontend-module.js +52 -52
  19. package/lib/browser/preference-open-handler.d.ts +9 -9
  20. package/lib/browser/preference-open-handler.js +64 -64
  21. package/lib/browser/preference-transaction-manager.d.ts +100 -100
  22. package/lib/browser/preference-transaction-manager.js +293 -293
  23. package/lib/browser/preference-tree-model.d.ts +60 -60
  24. package/lib/browser/preference-tree-model.js +243 -243
  25. package/lib/browser/preferences-contribution.d.ts +37 -37
  26. package/lib/browser/preferences-contribution.js +280 -280
  27. package/lib/browser/preferences-json-schema-contribution.d.ts +17 -17
  28. package/lib/browser/preferences-json-schema-contribution.js +91 -91
  29. package/lib/browser/preferences-monaco-contribution.d.ts +1 -1
  30. package/lib/browser/preferences-monaco-contribution.js +27 -27
  31. package/lib/browser/section-preference-provider.d.ts +21 -21
  32. package/lib/browser/section-preference-provider.js +96 -96
  33. package/lib/browser/user-configs-preference-provider.d.ts +22 -22
  34. package/lib/browser/user-configs-preference-provider.js +137 -137
  35. package/lib/browser/user-preference-provider.d.ts +13 -13
  36. package/lib/browser/user-preference-provider.js +41 -41
  37. package/lib/browser/util/preference-scope-command-manager.d.ts +17 -17
  38. package/lib/browser/util/preference-scope-command-manager.js +87 -87
  39. package/lib/browser/util/preference-tree-generator.d.ts +31 -31
  40. package/lib/browser/util/preference-tree-generator.js +237 -237
  41. package/lib/browser/util/preference-tree-label-provider.d.ts +11 -11
  42. package/lib/browser/util/preference-tree-label-provider.js +77 -77
  43. package/lib/browser/util/preference-tree-label-provider.spec.d.ts +1 -1
  44. package/lib/browser/util/preference-tree-label-provider.spec.js +87 -87
  45. package/lib/browser/util/preference-types.d.ts +62 -62
  46. package/lib/browser/util/preference-types.js +128 -128
  47. package/lib/browser/views/components/preference-array-input.d.ts +28 -28
  48. package/lib/browser/views/components/preference-array-input.js +180 -180
  49. package/lib/browser/views/components/preference-boolean-input.d.ts +17 -17
  50. package/lib/browser/views/components/preference-boolean-input.js +79 -79
  51. package/lib/browser/views/components/preference-file-input.d.ts +29 -29
  52. package/lib/browser/views/components/preference-file-input.js +110 -110
  53. package/lib/browser/views/components/preference-json-input.d.ts +19 -19
  54. package/lib/browser/views/components/preference-json-input.js +93 -93
  55. package/lib/browser/views/components/preference-markdown-renderer.d.ts +12 -12
  56. package/lib/browser/views/components/preference-markdown-renderer.js +81 -81
  57. package/lib/browser/views/components/preference-node-renderer-creator.d.ts +48 -48
  58. package/lib/browser/views/components/preference-node-renderer-creator.js +132 -132
  59. package/lib/browser/views/components/preference-node-renderer.d.ts +112 -112
  60. package/lib/browser/views/components/preference-node-renderer.js +441 -441
  61. package/lib/browser/views/components/preference-number-input.d.ts +34 -34
  62. package/lib/browser/views/components/preference-number-input.js +142 -142
  63. package/lib/browser/views/components/preference-select-input.d.ts +28 -28
  64. package/lib/browser/views/components/preference-select-input.js +138 -138
  65. package/lib/browser/views/components/preference-string-input.d.ts +17 -17
  66. package/lib/browser/views/components/preference-string-input.js +89 -89
  67. package/lib/browser/views/preference-editor-widget.d.ts +67 -67
  68. package/lib/browser/views/preference-editor-widget.js +363 -363
  69. package/lib/browser/views/preference-scope-tabbar-widget.d.ts +54 -54
  70. package/lib/browser/views/preference-scope-tabbar-widget.js +343 -343
  71. package/lib/browser/views/preference-searchbar-widget.d.ts +53 -53
  72. package/lib/browser/views/preference-searchbar-widget.js +173 -173
  73. package/lib/browser/views/preference-tree-widget.d.ts +17 -17
  74. package/lib/browser/views/preference-tree-widget.js +104 -104
  75. package/lib/browser/views/preference-widget-bindings.d.ts +3 -3
  76. package/lib/browser/views/preference-widget-bindings.js +87 -87
  77. package/lib/browser/views/preference-widget.d.ts +36 -36
  78. package/lib/browser/views/preference-widget.js +126 -126
  79. package/lib/browser/workspace-file-preference-provider.d.ts +23 -23
  80. package/lib/browser/workspace-file-preference-provider.js +110 -110
  81. package/lib/browser/workspace-preference-provider.d.ts +28 -28
  82. package/lib/browser/workspace-preference-provider.js +142 -142
  83. package/package.json +10 -10
  84. package/src/browser/abstract-resource-preference-provider.spec.ts +95 -95
  85. package/src/browser/abstract-resource-preference-provider.ts +232 -232
  86. package/src/browser/folder-preference-provider.ts +58 -58
  87. package/src/browser/folders-preferences-provider.ts +244 -244
  88. package/src/browser/index.ts +23 -23
  89. package/src/browser/monaco-jsonc-editor.ts +67 -67
  90. package/src/browser/package.spec.ts +28 -28
  91. package/src/browser/preference-bindings.ts +65 -65
  92. package/src/browser/preference-frontend-module.ts +57 -57
  93. package/src/browser/preference-open-handler.ts +53 -53
  94. package/src/browser/preference-transaction-manager.ts +287 -287
  95. package/src/browser/preference-tree-model.ts +250 -250
  96. package/src/browser/preferences-contribution.ts +263 -263
  97. package/src/browser/preferences-json-schema-contribution.ts +86 -86
  98. package/src/browser/preferences-monaco-contribution.ts +27 -27
  99. package/src/browser/section-preference-provider.ts +83 -83
  100. package/src/browser/style/index.css +506 -506
  101. package/src/browser/style/preference-array.css +94 -94
  102. package/src/browser/style/preference-context-menu.css +74 -74
  103. package/src/browser/style/preference-file.css +31 -31
  104. package/src/browser/style/preference-object.css +49 -49
  105. package/src/browser/style/search-input.css +66 -66
  106. package/src/browser/user-configs-preference-provider.ts +127 -127
  107. package/src/browser/user-preference-provider.ts +35 -35
  108. package/src/browser/util/preference-scope-command-manager.ts +75 -75
  109. package/src/browser/util/preference-tree-generator.ts +226 -226
  110. package/src/browser/util/preference-tree-label-provider.spec.ts +108 -108
  111. package/src/browser/util/preference-tree-label-provider.ts +64 -64
  112. package/src/browser/util/preference-types.ts +169 -169
  113. package/src/browser/views/components/preference-array-input.ts +174 -174
  114. package/src/browser/views/components/preference-boolean-input.ts +69 -69
  115. package/src/browser/views/components/preference-file-input.ts +104 -104
  116. package/src/browser/views/components/preference-json-input.ts +78 -78
  117. package/src/browser/views/components/preference-markdown-renderer.ts +68 -68
  118. package/src/browser/views/components/preference-node-renderer-creator.ts +141 -141
  119. package/src/browser/views/components/preference-node-renderer.ts +477 -477
  120. package/src/browser/views/components/preference-number-input.ts +147 -147
  121. package/src/browser/views/components/preference-select-input.ts +131 -131
  122. package/src/browser/views/components/preference-string-input.ts +76 -76
  123. package/src/browser/views/preference-editor-widget.ts +349 -349
  124. package/src/browser/views/preference-scope-tabbar-widget.tsx +344 -344
  125. package/src/browser/views/preference-searchbar-widget.tsx +183 -183
  126. package/src/browser/views/preference-tree-widget.tsx +93 -93
  127. package/src/browser/views/preference-widget-bindings.ts +102 -102
  128. package/src/browser/views/preference-widget.tsx +117 -117
  129. package/src/browser/workspace-file-preference-provider.ts +100 -100
  130. package/src/browser/workspace-preference-provider.ts +134 -134
@@ -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,117 +1,117 @@
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.closable = true;
82
- this.addClass('theia-settings-container');
83
- this.title.iconClass = codicon('settings');
84
-
85
- this.searchbarWidget.addClass('preferences-searchbar-widget');
86
- this.addWidget(this.searchbarWidget);
87
-
88
- this.tabBarWidget.addClass('preferences-tabbar-widget');
89
- this.addWidget(this.tabBarWidget);
90
-
91
- this.treeWidget.addClass('preferences-tree-widget');
92
- this.addWidget(this.treeWidget);
93
-
94
- this.editorWidget.addClass('preferences-editor-widget');
95
- this.addWidget(this.editorWidget);
96
-
97
- this.update();
98
- }
99
-
100
- getPreviewNode(): Node | undefined {
101
- return this.node;
102
- }
103
-
104
- storeState(): PreferencesWidgetState {
105
- return {
106
- scopeTabBarState: this.tabBarWidget.storeState(),
107
- editorState: this.editorWidget.storeState(),
108
- searchbarWidgetState: this.searchbarWidget.storeState(),
109
- };
110
- }
111
-
112
- restoreState(state: PreferencesWidgetState): void {
113
- this.tabBarWidget.restoreState(state.scopeTabBarState);
114
- this.editorWidget.restoreState(state.editorState);
115
- this.searchbarWidget.restoreState(state.searchbarWidgetState);
116
- }
117
- }
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.closable = true;
82
+ this.addClass('theia-settings-container');
83
+ this.title.iconClass = codicon('settings');
84
+
85
+ this.searchbarWidget.addClass('preferences-searchbar-widget');
86
+ this.addWidget(this.searchbarWidget);
87
+
88
+ this.tabBarWidget.addClass('preferences-tabbar-widget');
89
+ this.addWidget(this.tabBarWidget);
90
+
91
+ this.treeWidget.addClass('preferences-tree-widget');
92
+ this.addWidget(this.treeWidget);
93
+
94
+ this.editorWidget.addClass('preferences-editor-widget');
95
+ this.addWidget(this.editorWidget);
96
+
97
+ this.update();
98
+ }
99
+
100
+ getPreviewNode(): Node | undefined {
101
+ return this.node;
102
+ }
103
+
104
+ storeState(): PreferencesWidgetState {
105
+ return {
106
+ scopeTabBarState: this.tabBarWidget.storeState(),
107
+ editorState: this.editorWidget.storeState(),
108
+ searchbarWidgetState: this.searchbarWidget.storeState(),
109
+ };
110
+ }
111
+
112
+ restoreState(state: PreferencesWidgetState): void {
113
+ this.tabBarWidget.restoreState(state.scopeTabBarState);
114
+ this.editorWidget.restoreState(state.editorState);
115
+ this.searchbarWidget.restoreState(state.searchbarWidgetState);
116
+ }
117
+ }
@@ -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
+ }