@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,177 +1,177 @@
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 {
18
- PreferenceDataProperty,
19
- PreferenceScope,
20
- TreeNode as BaseTreeNode,
21
- CompositeTreeNode as BaseCompositeTreeNode,
22
- SelectableTreeNode,
23
- PreferenceInspection,
24
- CommonCommands,
25
- } from '@theia/core/lib/browser';
26
- import { Command, MenuPath } from '@theia/core';
27
- import { JSONValue } from '@theia/core/shared/@phosphor/coreutils';
28
- import { JsonType } from '@theia/core/lib/common/json-schema';
29
-
30
- export namespace Preference {
31
-
32
- export interface EditorCommandArgs {
33
- id: string;
34
- value: string | undefined;
35
- }
36
-
37
- export namespace EditorCommandArgs {
38
- export function is(prefObject: EditorCommandArgs): prefObject is EditorCommandArgs {
39
- return !!prefObject && 'id' in prefObject && 'value' in prefObject;
40
- }
41
- }
42
-
43
- export const Node = Symbol('Preference.Node');
44
- export type Node = TreeNode;
45
-
46
- export type TreeNode = CompositeTreeNode | LeafNode;
47
-
48
- export namespace TreeNode {
49
- export const is = (node: BaseTreeNode | TreeNode): node is TreeNode => 'depth' in node;
50
- export const isTopLevel = (node: BaseTreeNode): boolean => {
51
- const { group, id } = getGroupAndIdFromNodeId(node.id);
52
- return group === id;
53
- };
54
- export const getGroupAndIdFromNodeId = (nodeId: string): { group: string; id: string } => {
55
- const separator = nodeId.indexOf('@');
56
- const group = nodeId.substring(0, separator);
57
- const id = nodeId.substring(separator + 1, nodeId.length);
58
- return { group, id };
59
- };
60
- }
61
-
62
- export interface CompositeTreeNode extends BaseCompositeTreeNode, SelectableTreeNode {
63
- expanded?: boolean;
64
- depth: number;
65
- label?: string;
66
- }
67
-
68
- export namespace CompositeTreeNode {
69
- export const is = (node: TreeNode): node is CompositeTreeNode => !LeafNode.is(node);
70
- }
71
-
72
- export interface LeafNode extends BaseTreeNode {
73
- label?: string;
74
- depth: number;
75
- preference: { data: PreferenceDataProperty };
76
- preferenceId: string;
77
- }
78
-
79
- export namespace LeafNode {
80
- export const is = (node: BaseTreeNode | LeafNode): node is LeafNode => 'preference' in node && !!node.preference.data;
81
-
82
- export const getType = (node: BaseTreeNode | LeafNode): JsonType | undefined => is(node)
83
- ? Array.isArray(node.preference.data.type) ? node.preference.data.type[0] : node.preference.data.type
84
- : undefined;
85
- }
86
-
87
- export const getValueInScope = <T extends JSONValue>(preferenceInfo: PreferenceInspection<T> | undefined, scope: number): T | undefined => {
88
- if (!preferenceInfo) {
89
- return undefined;
90
- }
91
- switch (scope) {
92
- case PreferenceScope.User:
93
- return preferenceInfo.globalValue;
94
- case PreferenceScope.Workspace:
95
- return preferenceInfo.workspaceValue;
96
- case PreferenceScope.Folder:
97
- return preferenceInfo.workspaceFolderValue;
98
- default:
99
- return undefined;
100
- }
101
- };
102
-
103
- export interface SelectedScopeDetails {
104
- scope: number;
105
- uri: string | undefined;
106
- activeScopeIsFolder: boolean;
107
- };
108
-
109
- export const DEFAULT_SCOPE: SelectedScopeDetails = {
110
- scope: PreferenceScope.User,
111
- uri: undefined,
112
- activeScopeIsFolder: false
113
- };
114
-
115
- }
116
-
117
- export namespace PreferencesCommands {
118
- export const OPEN_PREFERENCES_JSON_TOOLBAR: Command = {
119
- id: 'preferences:openJson.toolbar',
120
- iconClass: 'codicon codicon-json'
121
- };
122
- export const COPY_JSON_NAME = Command.toDefaultLocalizedCommand({
123
- id: 'preferences:copyJson.name',
124
- label: 'Copy Setting ID'
125
- });
126
- export const RESET_PREFERENCE = Command.toDefaultLocalizedCommand({
127
- id: 'preferences:reset',
128
- label: 'Reset Setting'
129
- });
130
-
131
- export const COPY_JSON_VALUE = Command.toDefaultLocalizedCommand({
132
- id: 'preferences:copyJson.value',
133
- label: 'Copy Setting as JSON',
134
- });
135
-
136
- export const OPEN_USER_PREFERENCES = Command.toDefaultLocalizedCommand({
137
- id: 'workbench.action.openGlobalSettings',
138
- category: CommonCommands.PREFERENCES_CATEGORY,
139
- label: 'Open User Settings',
140
- });
141
-
142
- export const OPEN_WORKSPACE_PREFERENCES = Command.toDefaultLocalizedCommand({
143
- id: 'workbench.action.openWorkspaceSettings',
144
- category: CommonCommands.PREFERENCES_CATEGORY,
145
- label: 'Open Workspace Settings',
146
- });
147
-
148
- export const OPEN_FOLDER_PREFERENCES = Command.toDefaultLocalizedCommand({
149
- id: 'workbench.action.openFolderSettings',
150
- category: CommonCommands.PREFERENCES_CATEGORY,
151
- label: 'Open Folder Settings'
152
- });
153
-
154
- export const OPEN_USER_PREFERENCES_JSON = Command.toDefaultLocalizedCommand({
155
- id: 'workbench.action.openSettingsJson',
156
- category: CommonCommands.PREFERENCES_CATEGORY,
157
- label: 'Open Settings (JSON)'
158
- });
159
-
160
- export const OPEN_WORKSPACE_PREFERENCES_JSON = Command.toDefaultLocalizedCommand({
161
- id: 'workbench.action.openWorkspaceSettingsFile',
162
- category: CommonCommands.PREFERENCES_CATEGORY,
163
- label: 'Open Workspace Settings (JSON)',
164
- });
165
-
166
- export const OPEN_FOLDER_PREFERENCES_JSON = Command.toDefaultLocalizedCommand({
167
- id: 'workbench.action.openFolderSettingsFile',
168
- category: CommonCommands.PREFERENCES_CATEGORY,
169
- label: 'Open Folder Settings (JSON)',
170
- });
171
- }
172
-
173
- export namespace PreferenceMenus {
174
- export const PREFERENCE_EDITOR_CONTEXT_MENU: MenuPath = ['preferences:editor.contextMenu'];
175
- export const PREFERENCE_EDITOR_COPY_ACTIONS: MenuPath = [...PREFERENCE_EDITOR_CONTEXT_MENU, 'preferences:editor.contextMenu.copy'];
176
- export const FOLDER_SCOPE_MENU_PATH = ['preferences:scope.menu'];
177
- }
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 {
18
+ PreferenceDataProperty,
19
+ PreferenceScope,
20
+ TreeNode as BaseTreeNode,
21
+ CompositeTreeNode as BaseCompositeTreeNode,
22
+ SelectableTreeNode,
23
+ PreferenceInspection,
24
+ CommonCommands,
25
+ } from '@theia/core/lib/browser';
26
+ import { Command, MenuPath } from '@theia/core';
27
+ import { JSONValue } from '@theia/core/shared/@phosphor/coreutils';
28
+ import { JsonType } from '@theia/core/lib/common/json-schema';
29
+
30
+ export namespace Preference {
31
+
32
+ export interface EditorCommandArgs {
33
+ id: string;
34
+ value: string | undefined;
35
+ }
36
+
37
+ export namespace EditorCommandArgs {
38
+ export function is(prefObject: EditorCommandArgs): prefObject is EditorCommandArgs {
39
+ return !!prefObject && 'id' in prefObject && 'value' in prefObject;
40
+ }
41
+ }
42
+
43
+ export const Node = Symbol('Preference.Node');
44
+ export type Node = TreeNode;
45
+
46
+ export type TreeNode = CompositeTreeNode | LeafNode;
47
+
48
+ export namespace TreeNode {
49
+ export const is = (node: BaseTreeNode | TreeNode): node is TreeNode => 'depth' in node;
50
+ export const isTopLevel = (node: BaseTreeNode): boolean => {
51
+ const { group, id } = getGroupAndIdFromNodeId(node.id);
52
+ return group === id;
53
+ };
54
+ export const getGroupAndIdFromNodeId = (nodeId: string): { group: string; id: string } => {
55
+ const separator = nodeId.indexOf('@');
56
+ const group = nodeId.substring(0, separator);
57
+ const id = nodeId.substring(separator + 1, nodeId.length);
58
+ return { group, id };
59
+ };
60
+ }
61
+
62
+ export interface CompositeTreeNode extends BaseCompositeTreeNode, SelectableTreeNode {
63
+ expanded?: boolean;
64
+ depth: number;
65
+ label?: string;
66
+ }
67
+
68
+ export namespace CompositeTreeNode {
69
+ export const is = (node: TreeNode): node is CompositeTreeNode => !LeafNode.is(node);
70
+ }
71
+
72
+ export interface LeafNode extends BaseTreeNode {
73
+ label?: string;
74
+ depth: number;
75
+ preference: { data: PreferenceDataProperty };
76
+ preferenceId: string;
77
+ }
78
+
79
+ export namespace LeafNode {
80
+ export const is = (node: BaseTreeNode | LeafNode): node is LeafNode => 'preference' in node && !!node.preference.data;
81
+
82
+ export const getType = (node: BaseTreeNode | LeafNode): JsonType | undefined => is(node)
83
+ ? Array.isArray(node.preference.data.type) ? node.preference.data.type[0] : node.preference.data.type
84
+ : undefined;
85
+ }
86
+
87
+ export const getValueInScope = <T extends JSONValue>(preferenceInfo: PreferenceInspection<T> | undefined, scope: number): T | undefined => {
88
+ if (!preferenceInfo) {
89
+ return undefined;
90
+ }
91
+ switch (scope) {
92
+ case PreferenceScope.User:
93
+ return preferenceInfo.globalValue;
94
+ case PreferenceScope.Workspace:
95
+ return preferenceInfo.workspaceValue;
96
+ case PreferenceScope.Folder:
97
+ return preferenceInfo.workspaceFolderValue;
98
+ default:
99
+ return undefined;
100
+ }
101
+ };
102
+
103
+ export interface SelectedScopeDetails {
104
+ scope: number;
105
+ uri: string | undefined;
106
+ activeScopeIsFolder: boolean;
107
+ };
108
+
109
+ export const DEFAULT_SCOPE: SelectedScopeDetails = {
110
+ scope: PreferenceScope.User,
111
+ uri: undefined,
112
+ activeScopeIsFolder: false
113
+ };
114
+
115
+ }
116
+
117
+ export namespace PreferencesCommands {
118
+ export const OPEN_PREFERENCES_JSON_TOOLBAR: Command = {
119
+ id: 'preferences:openJson.toolbar',
120
+ iconClass: 'codicon codicon-json'
121
+ };
122
+ export const COPY_JSON_NAME = Command.toDefaultLocalizedCommand({
123
+ id: 'preferences:copyJson.name',
124
+ label: 'Copy Setting ID'
125
+ });
126
+ export const RESET_PREFERENCE = Command.toDefaultLocalizedCommand({
127
+ id: 'preferences:reset',
128
+ label: 'Reset Setting'
129
+ });
130
+
131
+ export const COPY_JSON_VALUE = Command.toDefaultLocalizedCommand({
132
+ id: 'preferences:copyJson.value',
133
+ label: 'Copy Setting as JSON',
134
+ });
135
+
136
+ export const OPEN_USER_PREFERENCES = Command.toDefaultLocalizedCommand({
137
+ id: 'workbench.action.openGlobalSettings',
138
+ category: CommonCommands.PREFERENCES_CATEGORY,
139
+ label: 'Open User Settings',
140
+ });
141
+
142
+ export const OPEN_WORKSPACE_PREFERENCES = Command.toDefaultLocalizedCommand({
143
+ id: 'workbench.action.openWorkspaceSettings',
144
+ category: CommonCommands.PREFERENCES_CATEGORY,
145
+ label: 'Open Workspace Settings',
146
+ });
147
+
148
+ export const OPEN_FOLDER_PREFERENCES = Command.toDefaultLocalizedCommand({
149
+ id: 'workbench.action.openFolderSettings',
150
+ category: CommonCommands.PREFERENCES_CATEGORY,
151
+ label: 'Open Folder Settings'
152
+ });
153
+
154
+ export const OPEN_USER_PREFERENCES_JSON = Command.toDefaultLocalizedCommand({
155
+ id: 'workbench.action.openSettingsJson',
156
+ category: CommonCommands.PREFERENCES_CATEGORY,
157
+ label: 'Open Settings (JSON)'
158
+ });
159
+
160
+ export const OPEN_WORKSPACE_PREFERENCES_JSON = Command.toDefaultLocalizedCommand({
161
+ id: 'workbench.action.openWorkspaceSettingsFile',
162
+ category: CommonCommands.PREFERENCES_CATEGORY,
163
+ label: 'Open Workspace Settings (JSON)',
164
+ });
165
+
166
+ export const OPEN_FOLDER_PREFERENCES_JSON = Command.toDefaultLocalizedCommand({
167
+ id: 'workbench.action.openFolderSettingsFile',
168
+ category: CommonCommands.PREFERENCES_CATEGORY,
169
+ label: 'Open Folder Settings (JSON)',
170
+ });
171
+ }
172
+
173
+ export namespace PreferenceMenus {
174
+ export const PREFERENCE_EDITOR_CONTEXT_MENU: MenuPath = ['preferences:editor.contextMenu'];
175
+ export const PREFERENCE_EDITOR_COPY_ACTIONS: MenuPath = [...PREFERENCE_EDITOR_CONTEXT_MENU, 'preferences:editor.contextMenu.copy'];
176
+ export const FOLDER_SCOPE_MENU_PATH = ['preferences:scope.menu'];
177
+ }