@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,127 +1,127 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2019 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
- /* eslint-disable @typescript-eslint/no-explicit-any */
18
-
19
- import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
20
- import URI from '@theia/core/lib/common/uri';
21
- import { PreferenceProvider, PreferenceResolveResult } from '@theia/core/lib/browser/preferences/preference-provider';
22
- import { PreferenceConfigurations } from '@theia/core/lib/browser/preferences/preference-configurations';
23
- import { UserStorageUri } from '@theia/userstorage/lib/browser';
24
- import { UserPreferenceProvider, UserPreferenceProviderFactory } from './user-preference-provider';
25
-
26
- /**
27
- * Binds together preference section prefs providers for user-level preferences.
28
- */
29
- @injectable()
30
- export class UserConfigsPreferenceProvider extends PreferenceProvider {
31
-
32
- @inject(UserPreferenceProviderFactory)
33
- protected readonly providerFactory: UserPreferenceProviderFactory;
34
-
35
- @inject(PreferenceConfigurations)
36
- protected readonly configurations: PreferenceConfigurations;
37
-
38
- protected readonly providers = new Map<string, UserPreferenceProvider>();
39
-
40
- @postConstruct()
41
- protected init(): void {
42
- this.doInit();
43
- }
44
-
45
- protected async doInit(): Promise<void> {
46
- this.createProviders();
47
-
48
- const readyPromises: Promise<void>[] = [];
49
- for (const provider of this.providers.values()) {
50
- readyPromises.push(provider.ready.catch(e => console.error(e)));
51
- }
52
- Promise.all(readyPromises).then(() => this._ready.resolve());
53
- }
54
-
55
- protected createProviders(): void {
56
- for (const configName of [...this.configurations.getSectionNames(), this.configurations.getConfigName()]) {
57
- const sectionUri = UserStorageUri.resolve(configName + '.json');
58
- const sectionKey = sectionUri.toString();
59
- if (!this.providers.has(sectionKey)) {
60
- const provider = this.createProvider(sectionUri, configName);
61
- this.providers.set(sectionKey, provider);
62
- }
63
- }
64
- }
65
-
66
- override getConfigUri(resourceUri?: string, sectionName: string = this.configurations.getConfigName()): URI | undefined {
67
- for (const provider of this.providers.values()) {
68
- const configUri = provider.getConfigUri(resourceUri);
69
- if (configUri && this.configurations.getName(configUri) === sectionName) {
70
- return configUri;
71
- }
72
- }
73
- return undefined;
74
- }
75
-
76
- override resolve<T>(preferenceName: string, resourceUri?: string): PreferenceResolveResult<T> {
77
- const result: PreferenceResolveResult<T> = {};
78
- for (const provider of this.providers.values()) {
79
- const { value, configUri } = provider.resolve<T>(preferenceName, resourceUri);
80
- if (configUri && value !== undefined) {
81
- result.configUri = configUri;
82
- result.value = PreferenceProvider.merge(result.value as any, value as any) as any;
83
- }
84
- }
85
- return result;
86
- }
87
-
88
- getPreferences(resourceUri?: string): { [p: string]: any } {
89
- let result = {};
90
- for (const provider of this.providers.values()) {
91
- const preferences = provider.getPreferences();
92
- result = PreferenceProvider.merge(result, preferences) as any;
93
- }
94
- return result;
95
- }
96
-
97
- async setPreference(preferenceName: string, value: any, resourceUri?: string): Promise<boolean> {
98
- const sectionName = preferenceName.split('.', 1)[0];
99
- const defaultConfigName = this.configurations.getConfigName();
100
- const configName = this.configurations.isSectionName(sectionName) ? sectionName : defaultConfigName;
101
-
102
- const setWithConfigName = async (name: string): Promise<boolean> => {
103
- for (const provider of this.providers.values()) {
104
- if (this.configurations.getName(provider.getConfigUri()) === name) {
105
- if (await provider.setPreference(preferenceName, value, resourceUri)) {
106
- return true;
107
- }
108
- }
109
- }
110
- return false;
111
- };
112
-
113
- if (await setWithConfigName(configName)) { // Try in the section we believe it belongs in.
114
- return true;
115
- } else if (configName !== defaultConfigName) { // Fall back to `settings.json` if that fails.
116
- return setWithConfigName(defaultConfigName);
117
- }
118
- return false;
119
- }
120
-
121
- protected createProvider(uri: URI, sectionName: string): UserPreferenceProvider {
122
- const provider = this.providerFactory(uri, sectionName);
123
- this.toDispose.push(provider);
124
- this.toDispose.push(provider.onDidPreferencesChanged(change => this.onDidPreferencesChangedEmitter.fire(change)));
125
- return provider;
126
- }
127
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2019 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
+ /* eslint-disable @typescript-eslint/no-explicit-any */
18
+
19
+ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify';
20
+ import URI from '@theia/core/lib/common/uri';
21
+ import { PreferenceProvider, PreferenceResolveResult } from '@theia/core/lib/browser/preferences/preference-provider';
22
+ import { PreferenceConfigurations } from '@theia/core/lib/browser/preferences/preference-configurations';
23
+ import { UserStorageUri } from '@theia/userstorage/lib/browser';
24
+ import { UserPreferenceProvider, UserPreferenceProviderFactory } from './user-preference-provider';
25
+
26
+ /**
27
+ * Binds together preference section prefs providers for user-level preferences.
28
+ */
29
+ @injectable()
30
+ export class UserConfigsPreferenceProvider extends PreferenceProvider {
31
+
32
+ @inject(UserPreferenceProviderFactory)
33
+ protected readonly providerFactory: UserPreferenceProviderFactory;
34
+
35
+ @inject(PreferenceConfigurations)
36
+ protected readonly configurations: PreferenceConfigurations;
37
+
38
+ protected readonly providers = new Map<string, UserPreferenceProvider>();
39
+
40
+ @postConstruct()
41
+ protected init(): void {
42
+ this.doInit();
43
+ }
44
+
45
+ protected async doInit(): Promise<void> {
46
+ this.createProviders();
47
+
48
+ const readyPromises: Promise<void>[] = [];
49
+ for (const provider of this.providers.values()) {
50
+ readyPromises.push(provider.ready.catch(e => console.error(e)));
51
+ }
52
+ Promise.all(readyPromises).then(() => this._ready.resolve());
53
+ }
54
+
55
+ protected createProviders(): void {
56
+ for (const configName of [...this.configurations.getSectionNames(), this.configurations.getConfigName()]) {
57
+ const sectionUri = UserStorageUri.resolve(configName + '.json');
58
+ const sectionKey = sectionUri.toString();
59
+ if (!this.providers.has(sectionKey)) {
60
+ const provider = this.createProvider(sectionUri, configName);
61
+ this.providers.set(sectionKey, provider);
62
+ }
63
+ }
64
+ }
65
+
66
+ override getConfigUri(resourceUri?: string, sectionName: string = this.configurations.getConfigName()): URI | undefined {
67
+ for (const provider of this.providers.values()) {
68
+ const configUri = provider.getConfigUri(resourceUri);
69
+ if (configUri && this.configurations.getName(configUri) === sectionName) {
70
+ return configUri;
71
+ }
72
+ }
73
+ return undefined;
74
+ }
75
+
76
+ override resolve<T>(preferenceName: string, resourceUri?: string): PreferenceResolveResult<T> {
77
+ const result: PreferenceResolveResult<T> = {};
78
+ for (const provider of this.providers.values()) {
79
+ const { value, configUri } = provider.resolve<T>(preferenceName, resourceUri);
80
+ if (configUri && value !== undefined) {
81
+ result.configUri = configUri;
82
+ result.value = PreferenceProvider.merge(result.value as any, value as any) as any;
83
+ }
84
+ }
85
+ return result;
86
+ }
87
+
88
+ getPreferences(resourceUri?: string): { [p: string]: any } {
89
+ let result = {};
90
+ for (const provider of this.providers.values()) {
91
+ const preferences = provider.getPreferences();
92
+ result = PreferenceProvider.merge(result, preferences) as any;
93
+ }
94
+ return result;
95
+ }
96
+
97
+ async setPreference(preferenceName: string, value: any, resourceUri?: string): Promise<boolean> {
98
+ const sectionName = preferenceName.split('.', 1)[0];
99
+ const defaultConfigName = this.configurations.getConfigName();
100
+ const configName = this.configurations.isSectionName(sectionName) ? sectionName : defaultConfigName;
101
+
102
+ const setWithConfigName = async (name: string): Promise<boolean> => {
103
+ for (const provider of this.providers.values()) {
104
+ if (this.configurations.getName(provider.getConfigUri()) === name) {
105
+ if (await provider.setPreference(preferenceName, value, resourceUri)) {
106
+ return true;
107
+ }
108
+ }
109
+ }
110
+ return false;
111
+ };
112
+
113
+ if (await setWithConfigName(configName)) { // Try in the section we believe it belongs in.
114
+ return true;
115
+ } else if (configName !== defaultConfigName) { // Fall back to `settings.json` if that fails.
116
+ return setWithConfigName(defaultConfigName);
117
+ }
118
+ return false;
119
+ }
120
+
121
+ protected createProvider(uri: URI, sectionName: string): UserPreferenceProvider {
122
+ const provider = this.providerFactory(uri, sectionName);
123
+ this.toDispose.push(provider);
124
+ this.toDispose.push(provider.onDidPreferencesChanged(change => this.onDidPreferencesChangedEmitter.fire(change)));
125
+ return provider;
126
+ }
127
+ }
@@ -1,35 +1,35 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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 { injectable } from '@theia/core/shared/inversify';
18
- import URI from '@theia/core/lib/common/uri';
19
- import { PreferenceScope } from '@theia/core/lib/browser';
20
- import { SectionPreferenceProvider } from './section-preference-provider';
21
-
22
- export const UserPreferenceProviderFactory = Symbol('UserPreferenceProviderFactory');
23
- export interface UserPreferenceProviderFactory {
24
- (uri: URI, section: string): UserPreferenceProvider;
25
- };
26
-
27
- /**
28
- * A @SectionPreferenceProvider that targets the user-level settings
29
- */
30
- @injectable()
31
- export class UserPreferenceProvider extends SectionPreferenceProvider {
32
- getScope(): PreferenceScope {
33
- return PreferenceScope.User;
34
- }
35
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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 { injectable } from '@theia/core/shared/inversify';
18
+ import URI from '@theia/core/lib/common/uri';
19
+ import { PreferenceScope } from '@theia/core/lib/browser';
20
+ import { SectionPreferenceProvider } from './section-preference-provider';
21
+
22
+ export const UserPreferenceProviderFactory = Symbol('UserPreferenceProviderFactory');
23
+ export interface UserPreferenceProviderFactory {
24
+ (uri: URI, section: string): UserPreferenceProvider;
25
+ };
26
+
27
+ /**
28
+ * A @SectionPreferenceProvider that targets the user-level settings
29
+ */
30
+ @injectable()
31
+ export class UserPreferenceProvider extends SectionPreferenceProvider {
32
+ getScope(): PreferenceScope {
33
+ return PreferenceScope.User;
34
+ }
35
+ }