@theia/preferences 1.34.3 → 1.34.4

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 (128) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +81 -81
  3. package/lib/browser/abstract-resource-preference-provider.d.ts +46 -46
  4. package/lib/browser/abstract-resource-preference-provider.js +237 -237
  5. package/lib/browser/abstract-resource-preference-provider.spec.d.ts +1 -1
  6. package/lib/browser/abstract-resource-preference-provider.spec.js +83 -83
  7. package/lib/browser/folder-preference-provider.d.ts +20 -20
  8. package/lib/browser/folder-preference-provider.js +59 -59
  9. package/lib/browser/folders-preferences-provider.d.ts +25 -25
  10. package/lib/browser/folders-preferences-provider.js +239 -239
  11. package/lib/browser/index.d.ts +7 -7
  12. package/lib/browser/index.js +34 -34
  13. package/lib/browser/monaco-jsonc-editor.d.ts +9 -9
  14. package/lib/browser/monaco-jsonc-editor.js +80 -80
  15. package/lib/browser/package.spec.js +25 -25
  16. package/lib/browser/preference-bindings.d.ts +4 -4
  17. package/lib/browser/preference-bindings.js +63 -63
  18. package/lib/browser/preference-frontend-module.d.ts +6 -6
  19. package/lib/browser/preference-frontend-module.js +52 -52
  20. package/lib/browser/preference-open-handler.d.ts +9 -9
  21. package/lib/browser/preference-open-handler.js +64 -64
  22. package/lib/browser/preference-transaction-manager.d.ts +98 -98
  23. package/lib/browser/preference-transaction-manager.js +295 -295
  24. package/lib/browser/preference-tree-model.d.ts +59 -59
  25. package/lib/browser/preference-tree-model.js +240 -240
  26. package/lib/browser/preferences-contribution.d.ts +37 -37
  27. package/lib/browser/preferences-contribution.js +279 -279
  28. package/lib/browser/preferences-json-schema-contribution.d.ts +17 -17
  29. package/lib/browser/preferences-json-schema-contribution.js +91 -91
  30. package/lib/browser/preferences-monaco-contribution.d.ts +1 -1
  31. package/lib/browser/preferences-monaco-contribution.js +30 -30
  32. package/lib/browser/section-preference-provider.d.ts +21 -21
  33. package/lib/browser/section-preference-provider.js +96 -96
  34. package/lib/browser/user-configs-preference-provider.d.ts +21 -21
  35. package/lib/browser/user-configs-preference-provider.js +134 -134
  36. package/lib/browser/user-preference-provider.d.ts +13 -13
  37. package/lib/browser/user-preference-provider.js +41 -41
  38. package/lib/browser/util/preference-scope-command-manager.d.ts +17 -17
  39. package/lib/browser/util/preference-scope-command-manager.js +87 -87
  40. package/lib/browser/util/preference-tree-generator.d.ts +30 -30
  41. package/lib/browser/util/preference-tree-generator.js +234 -234
  42. package/lib/browser/util/preference-tree-label-provider.d.ts +11 -11
  43. package/lib/browser/util/preference-tree-label-provider.js +77 -77
  44. package/lib/browser/util/preference-tree-label-provider.spec.d.ts +1 -1
  45. package/lib/browser/util/preference-tree-label-provider.spec.js +87 -87
  46. package/lib/browser/util/preference-types.d.ts +62 -62
  47. package/lib/browser/util/preference-types.js +128 -128
  48. package/lib/browser/views/components/preference-array-input.d.ts +28 -28
  49. package/lib/browser/views/components/preference-array-input.js +180 -180
  50. package/lib/browser/views/components/preference-boolean-input.d.ts +17 -17
  51. package/lib/browser/views/components/preference-boolean-input.js +79 -79
  52. package/lib/browser/views/components/preference-file-input.d.ts +29 -29
  53. package/lib/browser/views/components/preference-file-input.js +110 -110
  54. package/lib/browser/views/components/preference-json-input.d.ts +19 -19
  55. package/lib/browser/views/components/preference-json-input.js +93 -93
  56. package/lib/browser/views/components/preference-node-renderer-creator.d.ts +48 -48
  57. package/lib/browser/views/components/preference-node-renderer-creator.js +132 -132
  58. package/lib/browser/views/components/preference-node-renderer.d.ts +111 -111
  59. package/lib/browser/views/components/preference-node-renderer.js +460 -460
  60. package/lib/browser/views/components/preference-number-input.d.ts +34 -34
  61. package/lib/browser/views/components/preference-number-input.js +142 -142
  62. package/lib/browser/views/components/preference-select-input.d.ts +27 -27
  63. package/lib/browser/views/components/preference-select-input.js +135 -135
  64. package/lib/browser/views/components/preference-string-input.d.ts +17 -17
  65. package/lib/browser/views/components/preference-string-input.js +89 -89
  66. package/lib/browser/views/preference-editor-widget.d.ts +67 -67
  67. package/lib/browser/views/preference-editor-widget.js +376 -376
  68. package/lib/browser/views/preference-scope-tabbar-widget.d.ts +54 -54
  69. package/lib/browser/views/preference-scope-tabbar-widget.js +343 -343
  70. package/lib/browser/views/preference-searchbar-widget.d.ts +53 -53
  71. package/lib/browser/views/preference-searchbar-widget.js +173 -173
  72. package/lib/browser/views/preference-tree-widget.d.ts +17 -17
  73. package/lib/browser/views/preference-tree-widget.js +104 -104
  74. package/lib/browser/views/preference-widget-bindings.d.ts +3 -3
  75. package/lib/browser/views/preference-widget-bindings.js +85 -85
  76. package/lib/browser/views/preference-widget.d.ts +35 -35
  77. package/lib/browser/views/preference-widget.js +123 -123
  78. package/lib/browser/workspace-file-preference-provider.d.ts +23 -23
  79. package/lib/browser/workspace-file-preference-provider.js +110 -110
  80. package/lib/browser/workspace-preference-provider.d.ts +28 -28
  81. package/lib/browser/workspace-preference-provider.js +142 -142
  82. package/package.json +9 -9
  83. package/src/browser/abstract-resource-preference-provider.spec.ts +95 -95
  84. package/src/browser/abstract-resource-preference-provider.ts +228 -228
  85. package/src/browser/folder-preference-provider.ts +58 -58
  86. package/src/browser/folders-preferences-provider.ts +236 -236
  87. package/src/browser/index.ts +23 -23
  88. package/src/browser/monaco-jsonc-editor.ts +67 -67
  89. package/src/browser/package.spec.ts +28 -28
  90. package/src/browser/preference-bindings.ts +65 -65
  91. package/src/browser/preference-frontend-module.ts +57 -57
  92. package/src/browser/preference-open-handler.ts +53 -53
  93. package/src/browser/preference-transaction-manager.ts +283 -283
  94. package/src/browser/preference-tree-model.ts +246 -246
  95. package/src/browser/preferences-contribution.ts +263 -263
  96. package/src/browser/preferences-json-schema-contribution.ts +86 -86
  97. package/src/browser/preferences-monaco-contribution.ts +30 -30
  98. package/src/browser/section-preference-provider.ts +83 -83
  99. package/src/browser/style/index.css +456 -456
  100. package/src/browser/style/preference-array.css +90 -90
  101. package/src/browser/style/preference-context-menu.css +74 -74
  102. package/src/browser/style/preference-file.css +32 -32
  103. package/src/browser/style/preference-object.css +49 -49
  104. package/src/browser/style/search-input.css +66 -66
  105. package/src/browser/user-configs-preference-provider.ts +123 -123
  106. package/src/browser/user-preference-provider.ts +35 -35
  107. package/src/browser/util/preference-scope-command-manager.ts +75 -75
  108. package/src/browser/util/preference-tree-generator.ts +222 -222
  109. package/src/browser/util/preference-tree-label-provider.spec.ts +108 -108
  110. package/src/browser/util/preference-tree-label-provider.ts +64 -64
  111. package/src/browser/util/preference-types.ts +169 -169
  112. package/src/browser/views/components/preference-array-input.ts +174 -174
  113. package/src/browser/views/components/preference-boolean-input.ts +69 -69
  114. package/src/browser/views/components/preference-file-input.ts +104 -104
  115. package/src/browser/views/components/preference-json-input.ts +78 -78
  116. package/src/browser/views/components/preference-node-renderer-creator.ts +141 -141
  117. package/src/browser/views/components/preference-node-renderer.ts +499 -499
  118. package/src/browser/views/components/preference-number-input.ts +147 -147
  119. package/src/browser/views/components/preference-select-input.ts +127 -127
  120. package/src/browser/views/components/preference-string-input.ts +76 -76
  121. package/src/browser/views/preference-editor-widget.ts +361 -361
  122. package/src/browser/views/preference-scope-tabbar-widget.tsx +344 -344
  123. package/src/browser/views/preference-searchbar-widget.tsx +183 -183
  124. package/src/browser/views/preference-tree-widget.tsx +93 -93
  125. package/src/browser/views/preference-widget-bindings.ts +99 -99
  126. package/src/browser/views/preference-widget.tsx +113 -113
  127. package/src/browser/workspace-file-preference-provider.ts +100 -100
  128. package/src/browser/workspace-preference-provider.ts +134 -134
@@ -1,99 +1,99 @@
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 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 { PreferencesEditorWidget } from './preference-editor-widget';
34
- import { PreferencesScopeTabBar } from './preference-scope-tabbar-widget';
35
- import { PreferencesSearchbarWidget } from './preference-searchbar-widget';
36
- import { PreferencesTreeWidget } from './preference-tree-widget';
37
- import { PreferencesWidget } from './preference-widget';
38
-
39
- export function bindPreferencesWidgets(bind: interfaces.Bind): void {
40
- bind(PreferenceTreeLabelProvider).toSelf().inSingletonScope();
41
- bind(LabelProviderContribution).toService(PreferenceTreeLabelProvider);
42
- bind(PreferencesWidget)
43
- .toDynamicValue(({ container }) => createPreferencesWidgetContainer(container).get(PreferencesWidget))
44
- .inSingletonScope();
45
- bind(WidgetFactory).toDynamicValue(({ container }) => ({
46
- id: PreferencesWidget.ID,
47
- createWidget: () => container.get(PreferencesWidget)
48
- })).inSingletonScope();
49
-
50
- bindContributionProvider(bind, PreferenceNodeRendererContribution);
51
-
52
- bind(PreferenceSelectInputRenderer).toSelf();
53
- bind(PreferenceNodeRendererContribution).to(PreferenceSelectInputRendererContribution).inSingletonScope();
54
-
55
- bind(PreferenceArrayInputRenderer).toSelf();
56
- bind(PreferenceNodeRendererContribution).to(PreferenceArrayInputRendererContribution).inSingletonScope();
57
-
58
- bind(PreferenceStringInputRenderer).toSelf();
59
- bind(PreferenceNodeRendererContribution).to(PreferenceStringInputRendererContribution).inSingletonScope();
60
-
61
- bind(PreferenceBooleanInputRenderer).toSelf();
62
- bind(PreferenceNodeRendererContribution).to(PreferenceBooleanInputRendererContribution).inSingletonScope();
63
-
64
- bind(PreferenceNumberInputRenderer).toSelf();
65
- bind(PreferenceNodeRendererContribution).to(PreferenceNumberInputRendererContribution).inSingletonScope();
66
-
67
- bind(PreferenceJSONLinkRenderer).toSelf();
68
- bind(PreferenceNodeRendererContribution).to(PreferenceJSONLinkRendererContribution).inSingletonScope();
69
-
70
- bind(PreferenceHeaderRenderer).toSelf();
71
- bind(PreferenceNodeRendererContribution).to(PreferenceHeaderRendererContribution).inSingletonScope();
72
-
73
- bind(PreferenceSingleFilePathInputRenderer).toSelf();
74
- bind(PreferenceNodeRendererContribution).to(PreferenceSingleFilePathInputRendererContribution).inSingletonScope();
75
-
76
- bind(DefaultPreferenceNodeRendererCreatorRegistry).toSelf().inSingletonScope();
77
- bind(PreferenceNodeRendererCreatorRegistry).toService(DefaultPreferenceNodeRendererCreatorRegistry);
78
- }
79
-
80
- export function createPreferencesWidgetContainer(parent: interfaces.Container): Container {
81
- const child = createTreeContainer(parent, {
82
- model: PreferenceTreeModel,
83
- widget: PreferencesTreeWidget,
84
- props: { search: false }
85
- });
86
- child.bind(PreferencesEditorWidget).toSelf();
87
-
88
- child.bind(PreferencesSearchbarWidget).toSelf();
89
- child.bind(PreferencesScopeTabBar).toSelf();
90
- child.bind(PreferencesWidget).toSelf();
91
-
92
- child.bind(PreferenceNodeRendererFactory).toFactory(({ container }) => (node: Preference.TreeNode) => {
93
- const registry = container.get<PreferenceNodeRendererCreatorRegistry>(PreferenceNodeRendererCreatorRegistry);
94
- const creator = registry.getPreferenceNodeRendererCreator(node);
95
- return creator.createRenderer(node, container);
96
- });
97
-
98
- return child;
99
- }
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 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 { PreferencesEditorWidget } from './preference-editor-widget';
34
+ import { PreferencesScopeTabBar } from './preference-scope-tabbar-widget';
35
+ import { PreferencesSearchbarWidget } from './preference-searchbar-widget';
36
+ import { PreferencesTreeWidget } from './preference-tree-widget';
37
+ import { PreferencesWidget } from './preference-widget';
38
+
39
+ export function bindPreferencesWidgets(bind: interfaces.Bind): void {
40
+ bind(PreferenceTreeLabelProvider).toSelf().inSingletonScope();
41
+ bind(LabelProviderContribution).toService(PreferenceTreeLabelProvider);
42
+ bind(PreferencesWidget)
43
+ .toDynamicValue(({ container }) => createPreferencesWidgetContainer(container).get(PreferencesWidget))
44
+ .inSingletonScope();
45
+ bind(WidgetFactory).toDynamicValue(({ container }) => ({
46
+ id: PreferencesWidget.ID,
47
+ createWidget: () => container.get(PreferencesWidget)
48
+ })).inSingletonScope();
49
+
50
+ bindContributionProvider(bind, PreferenceNodeRendererContribution);
51
+
52
+ bind(PreferenceSelectInputRenderer).toSelf();
53
+ bind(PreferenceNodeRendererContribution).to(PreferenceSelectInputRendererContribution).inSingletonScope();
54
+
55
+ bind(PreferenceArrayInputRenderer).toSelf();
56
+ bind(PreferenceNodeRendererContribution).to(PreferenceArrayInputRendererContribution).inSingletonScope();
57
+
58
+ bind(PreferenceStringInputRenderer).toSelf();
59
+ bind(PreferenceNodeRendererContribution).to(PreferenceStringInputRendererContribution).inSingletonScope();
60
+
61
+ bind(PreferenceBooleanInputRenderer).toSelf();
62
+ bind(PreferenceNodeRendererContribution).to(PreferenceBooleanInputRendererContribution).inSingletonScope();
63
+
64
+ bind(PreferenceNumberInputRenderer).toSelf();
65
+ bind(PreferenceNodeRendererContribution).to(PreferenceNumberInputRendererContribution).inSingletonScope();
66
+
67
+ bind(PreferenceJSONLinkRenderer).toSelf();
68
+ bind(PreferenceNodeRendererContribution).to(PreferenceJSONLinkRendererContribution).inSingletonScope();
69
+
70
+ bind(PreferenceHeaderRenderer).toSelf();
71
+ bind(PreferenceNodeRendererContribution).to(PreferenceHeaderRendererContribution).inSingletonScope();
72
+
73
+ bind(PreferenceSingleFilePathInputRenderer).toSelf();
74
+ bind(PreferenceNodeRendererContribution).to(PreferenceSingleFilePathInputRendererContribution).inSingletonScope();
75
+
76
+ bind(DefaultPreferenceNodeRendererCreatorRegistry).toSelf().inSingletonScope();
77
+ bind(PreferenceNodeRendererCreatorRegistry).toService(DefaultPreferenceNodeRendererCreatorRegistry);
78
+ }
79
+
80
+ export function createPreferencesWidgetContainer(parent: interfaces.Container): Container {
81
+ const child = createTreeContainer(parent, {
82
+ model: PreferenceTreeModel,
83
+ widget: PreferencesTreeWidget,
84
+ props: { search: false }
85
+ });
86
+ child.bind(PreferencesEditorWidget).toSelf();
87
+
88
+ child.bind(PreferencesSearchbarWidget).toSelf();
89
+ child.bind(PreferencesScopeTabBar).toSelf();
90
+ child.bind(PreferencesWidget).toSelf();
91
+
92
+ child.bind(PreferenceNodeRendererFactory).toFactory(({ container }) => (node: Preference.TreeNode) => {
93
+ const registry = container.get<PreferenceNodeRendererCreatorRegistry>(PreferenceNodeRendererCreatorRegistry);
94
+ const creator = registry.getPreferenceNodeRendererCreator(node);
95
+ return creator.createRenderer(node, container);
96
+ });
97
+
98
+ return child;
99
+ }
@@ -1,113 +1,113 @@
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 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('Preferences');
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
- storeState(): PreferencesWidgetState {
101
- return {
102
- scopeTabBarState: this.tabBarWidget.storeState(),
103
- editorState: this.editorWidget.storeState(),
104
- searchbarWidgetState: this.searchbarWidget.storeState(),
105
- };
106
- }
107
-
108
- restoreState(state: PreferencesWidgetState): void {
109
- this.tabBarWidget.restoreState(state.scopeTabBarState);
110
- this.editorWidget.restoreState(state.editorState);
111
- this.searchbarWidget.restoreState(state.searchbarWidgetState);
112
- }
113
- }
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 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('Preferences');
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
+ storeState(): PreferencesWidgetState {
101
+ return {
102
+ scopeTabBarState: this.tabBarWidget.storeState(),
103
+ editorState: this.editorWidget.storeState(),
104
+ searchbarWidgetState: this.searchbarWidget.storeState(),
105
+ };
106
+ }
107
+
108
+ restoreState(state: PreferencesWidgetState): void {
109
+ this.tabBarWidget.restoreState(state.scopeTabBarState);
110
+ this.editorWidget.restoreState(state.editorState);
111
+ this.searchbarWidget.restoreState(state.searchbarWidgetState);
112
+ }
113
+ }
@@ -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 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 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
+ }