@theia/toolbar 1.34.1 → 1.34.3

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/LICENSE +641 -641
  2. package/README.md +32 -32
  3. package/lib/browser/abstract-toolbar-contribution.d.ts +16 -16
  4. package/lib/browser/abstract-toolbar-contribution.js +68 -68
  5. package/lib/browser/application-shell-with-toolbar-override.d.ts +14 -14
  6. package/lib/browser/application-shell-with-toolbar-override.js +98 -98
  7. package/lib/browser/codicons.d.ts +1 -1
  8. package/lib/browser/codicons.js +20 -20
  9. package/lib/browser/font-awesome-icons.d.ts +1 -1
  10. package/lib/browser/font-awesome-icons.js +20 -20
  11. package/lib/browser/package.spec.js +18 -18
  12. package/lib/browser/toolbar-command-contribution.d.ts +25 -25
  13. package/lib/browser/toolbar-command-contribution.js +211 -211
  14. package/lib/browser/toolbar-command-quick-input-service.d.ts +19 -19
  15. package/lib/browser/toolbar-command-quick-input-service.js +108 -108
  16. package/lib/browser/toolbar-constants.d.ts +23 -23
  17. package/lib/browser/toolbar-constants.js +75 -75
  18. package/lib/browser/toolbar-controller.d.ts +33 -33
  19. package/lib/browser/toolbar-controller.js +184 -184
  20. package/lib/browser/toolbar-defaults.d.ts +3 -3
  21. package/lib/browser/toolbar-defaults.js +60 -60
  22. package/lib/browser/toolbar-frontend-module.d.ts +4 -4
  23. package/lib/browser/toolbar-frontend-module.js +25 -25
  24. package/lib/browser/toolbar-icon-selector-dialog.d.ts +65 -65
  25. package/lib/browser/toolbar-icon-selector-dialog.js +235 -235
  26. package/lib/browser/toolbar-interfaces.d.ts +45 -45
  27. package/lib/browser/toolbar-interfaces.js +42 -42
  28. package/lib/browser/toolbar-preference-contribution.d.ts +9 -9
  29. package/lib/browser/toolbar-preference-contribution.js +34 -34
  30. package/lib/browser/toolbar-preference-schema.d.ts +5 -5
  31. package/lib/browser/toolbar-preference-schema.js +72 -72
  32. package/lib/browser/toolbar-storage-provider.d.ts +46 -46
  33. package/lib/browser/toolbar-storage-provider.js +354 -354
  34. package/lib/browser/toolbar.d.ts +56 -56
  35. package/lib/browser/toolbar.js +380 -380
  36. package/package.json +10 -10
  37. package/src/browser/abstract-toolbar-contribution.tsx +53 -53
  38. package/src/browser/application-shell-with-toolbar-override.ts +94 -94
  39. package/src/browser/codicons.ts +18 -18
  40. package/src/browser/font-awesome-icons.ts +18 -18
  41. package/src/browser/package.spec.ts +19 -19
  42. package/src/browser/style/toolbar.css +253 -253
  43. package/src/browser/toolbar-command-contribution.ts +211 -211
  44. package/src/browser/toolbar-command-quick-input-service.ts +86 -86
  45. package/src/browser/toolbar-constants.ts +79 -79
  46. package/src/browser/toolbar-controller.ts +182 -182
  47. package/src/browser/toolbar-defaults.ts +58 -58
  48. package/src/browser/toolbar-frontend-module.ts +30 -30
  49. package/src/browser/toolbar-icon-selector-dialog.tsx +296 -296
  50. package/src/browser/toolbar-interfaces.ts +76 -76
  51. package/src/browser/toolbar-preference-contribution.ts +38 -38
  52. package/src/browser/toolbar-preference-schema.ts +74 -74
  53. package/src/browser/toolbar-storage-provider.ts +348 -348
  54. package/src/browser/toolbar.tsx +421 -421
@@ -1,211 +1,211 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2022 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 {
18
- bindContributionProvider,
19
- CommandContribution,
20
- CommandRegistry,
21
- CommandService,
22
- InMemoryResources,
23
- MenuContribution,
24
- MenuModelRegistry,
25
- } from '@theia/core';
26
- import {
27
- CommonMenus,
28
- createPreferenceProxy,
29
- KeybindingContribution,
30
- KeybindingRegistry,
31
- PreferenceContribution,
32
- PreferenceScope,
33
- PreferenceService,
34
- QuickInputService,
35
- Widget,
36
- } from '@theia/core/lib/browser';
37
- import { injectable, inject, interfaces, Container } from '@theia/core/shared/inversify';
38
- import { EditorManager } from '@theia/editor/lib/browser';
39
- import { ToolbarImpl } from './toolbar';
40
- import { bindToolbarIconDialog } from './toolbar-icon-selector-dialog';
41
- import {
42
- ToolbarContribution,
43
- ToolbarItemPosition,
44
- ToolbarFactory,
45
- Toolbar,
46
- LateInjector,
47
- lateInjector,
48
- } from './toolbar-interfaces';
49
- import { ToolbarCommandQuickInputService } from './toolbar-command-quick-input-service';
50
- import { ToolbarStorageProvider } from './toolbar-storage-provider';
51
- import { ToolbarController } from './toolbar-controller';
52
- import { ToolbarPreferencesSchema, ToolbarPreferences, TOOLBAR_ENABLE_PREFERENCE_ID } from './toolbar-preference-contribution';
53
- import { ToolbarDefaults, ToolbarDefaultsFactory } from './toolbar-defaults';
54
- import { ToolbarCommands, ToolbarMenus, UserToolbarURI, USER_TOOLBAR_URI } from './toolbar-constants';
55
- import { JsonSchemaContribution, JsonSchemaRegisterContext } from '@theia/core/lib/browser/json-schema-store';
56
- import { toolbarConfigurationSchema, toolbarSchemaId } from './toolbar-preference-schema';
57
- import URI from '@theia/core/lib/common/uri';
58
-
59
- @injectable()
60
- export class ToolbarCommandContribution implements CommandContribution, KeybindingContribution, MenuContribution, JsonSchemaContribution {
61
- @inject(ToolbarController) protected readonly model: ToolbarController;
62
- @inject(QuickInputService) protected readonly quickInputService: QuickInputService;
63
- @inject(ToolbarCommandQuickInputService) protected toolbarCommandPickService: ToolbarCommandQuickInputService;
64
- @inject(CommandService) protected readonly commandService: CommandService;
65
- @inject(EditorManager) protected readonly editorManager: EditorManager;
66
- @inject(PreferenceService) protected readonly preferenceService: PreferenceService;
67
- @inject(ToolbarController) protected readonly toolbarModel: ToolbarController;
68
- @inject(InMemoryResources) protected readonly inMemoryResources: InMemoryResources;
69
- protected readonly schemaURI = new URI(toolbarSchemaId);
70
-
71
- registerSchemas(context: JsonSchemaRegisterContext): void {
72
- this.inMemoryResources.add(this.schemaURI, JSON.stringify(toolbarConfigurationSchema));
73
- context.registerSchema({
74
- fileMatch: ['toolbar.json'],
75
- url: this.schemaURI.toString(),
76
- });
77
- }
78
-
79
- registerCommands(registry: CommandRegistry): void {
80
- registry.registerCommand(ToolbarCommands.CUSTOMIZE_TOOLBAR, {
81
- execute: () => this.model.openOrCreateJSONFile(true),
82
- });
83
- registry.registerCommand(ToolbarCommands.RESET_TOOLBAR, {
84
- execute: () => this.model.clearAll(),
85
- });
86
- registry.registerCommand(ToolbarCommands.TOGGLE_TOOLBAR, {
87
- execute: () => {
88
- const isVisible = this.preferenceService.get<boolean>(TOOLBAR_ENABLE_PREFERENCE_ID);
89
- this.preferenceService.set(TOOLBAR_ENABLE_PREFERENCE_ID, !isVisible, PreferenceScope.User);
90
- },
91
- });
92
-
93
- registry.registerCommand(ToolbarCommands.REMOVE_COMMAND_FROM_TOOLBAR, {
94
- execute: async (_widget, position: ToolbarItemPosition | undefined, id?: string) => position && this.model.removeItem(position, id),
95
- isVisible: (...args) => this.isToolbarWidget(args[0]),
96
- });
97
- registry.registerCommand(ToolbarCommands.INSERT_GROUP_LEFT, {
98
- execute: async (_widget: Widget, position: ToolbarItemPosition | undefined) => position && this.model.insertGroup(position, 'left'),
99
- isVisible: (widget: Widget, position: ToolbarItemPosition | undefined) => {
100
- if (position) {
101
- const { alignment, groupIndex, itemIndex } = position;
102
- const owningGroupLength = this.toolbarModel.toolbarItems.items[alignment][groupIndex].length;
103
- return this.isToolbarWidget(widget) && (owningGroupLength > 1) && (itemIndex > 0);
104
- }
105
- return false;
106
- },
107
- });
108
- registry.registerCommand(ToolbarCommands.INSERT_GROUP_RIGHT, {
109
- execute: async (_widget: Widget, position: ToolbarItemPosition | undefined) => position && this.model.insertGroup(position, 'right'),
110
- isVisible: (widget: Widget, position: ToolbarItemPosition | undefined) => {
111
- if (position) {
112
- const { alignment, groupIndex, itemIndex } = position;
113
- const owningGroupLength = this.toolbarModel.toolbarItems.items[alignment][groupIndex].length;
114
- const isNotLastItem = itemIndex < (owningGroupLength - 1);
115
- return this.isToolbarWidget(widget) && owningGroupLength > 1 && isNotLastItem;
116
- }
117
- return false;
118
- },
119
- });
120
- registry.registerCommand(ToolbarCommands.ADD_COMMAND_TO_TOOLBAR, {
121
- execute: () => this.toolbarCommandPickService.openIconDialog(),
122
- });
123
- }
124
-
125
- protected isToolbarWidget(arg: unknown): boolean {
126
- return arg instanceof ToolbarImpl;
127
- }
128
-
129
- registerKeybindings(keys: KeybindingRegistry): void {
130
- keys.registerKeybinding({
131
- command: ToolbarCommands.TOGGLE_TOOLBAR.id,
132
- keybinding: 'alt+t',
133
- });
134
- }
135
-
136
- registerMenus(registry: MenuModelRegistry): void {
137
- registry.registerMenuAction(CommonMenus.VIEW_LAYOUT, {
138
- commandId: ToolbarCommands.TOGGLE_TOOLBAR.id,
139
- order: 'z',
140
- });
141
-
142
- registry.registerMenuAction(ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
143
- commandId: ToolbarCommands.ADD_COMMAND_TO_TOOLBAR.id,
144
- order: 'a',
145
- });
146
- registry.registerMenuAction(ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
147
- commandId: ToolbarCommands.INSERT_GROUP_LEFT.id,
148
- order: 'b',
149
- });
150
- registry.registerMenuAction(ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
151
- commandId: ToolbarCommands.INSERT_GROUP_RIGHT.id,
152
- order: 'c',
153
- });
154
- registry.registerMenuAction(ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
155
- commandId: ToolbarCommands.REMOVE_COMMAND_FROM_TOOLBAR.id,
156
- order: 'd',
157
- });
158
-
159
- registry.registerMenuAction(ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
160
- commandId: ToolbarCommands.ADD_COMMAND_TO_TOOLBAR.id,
161
- order: 'a',
162
- });
163
- registry.registerMenuAction(ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
164
- commandId: ToolbarCommands.CUSTOMIZE_TOOLBAR.id,
165
- order: 'b',
166
- });
167
- registry.registerMenuAction(ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
168
- commandId: ToolbarCommands.TOGGLE_TOOLBAR.id,
169
- order: 'c',
170
- });
171
- registry.registerMenuAction(ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
172
- commandId: ToolbarCommands.RESET_TOOLBAR.id,
173
- order: 'd',
174
- });
175
- }
176
- }
177
-
178
- export function bindToolbar(bind: interfaces.Bind): void {
179
- bind(ToolbarFactory).toFactory(({ container }) => (): Toolbar => {
180
- const child = new Container({ defaultScope: 'Singleton' });
181
- child.parent = container;
182
- child.bind(Toolbar).to(ToolbarImpl);
183
- return child.get(Toolbar);
184
- });
185
- bind(ToolbarCommandContribution).toSelf().inSingletonScope();
186
- bind(CommandContribution).to(ToolbarCommandContribution);
187
- bind(MenuContribution).toService(ToolbarCommandContribution);
188
- bind(KeybindingContribution).toService(ToolbarCommandContribution);
189
- bind(JsonSchemaContribution).toService(ToolbarCommandContribution);
190
-
191
- bind(ToolbarCommandQuickInputService).toSelf().inSingletonScope();
192
-
193
- bindToolbarIconDialog(bind);
194
- bind(ToolbarDefaultsFactory).toConstantValue(ToolbarDefaults);
195
- bind(ToolbarPreferences).toDynamicValue(({ container }) => {
196
- const preferences = container.get<PreferenceService>(PreferenceService);
197
- return createPreferenceProxy(preferences, ToolbarPreferencesSchema);
198
- }).inSingletonScope();
199
- bind(PreferenceContribution).toConstantValue({
200
- schema: ToolbarPreferencesSchema,
201
- });
202
-
203
- bind(UserToolbarURI).toConstantValue(USER_TOOLBAR_URI);
204
-
205
- bind(ToolbarController).toSelf().inSingletonScope();
206
- bind(ToolbarStorageProvider).toSelf().inSingletonScope();
207
- bindContributionProvider(bind, ToolbarContribution);
208
- bind(LateInjector).toFactory(
209
- <T>(context: interfaces.Context) => (id: interfaces.ServiceIdentifier<T>): T => lateInjector(context.container, id),
210
- );
211
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2022 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 {
18
+ bindContributionProvider,
19
+ CommandContribution,
20
+ CommandRegistry,
21
+ CommandService,
22
+ InMemoryResources,
23
+ MenuContribution,
24
+ MenuModelRegistry,
25
+ } from '@theia/core';
26
+ import {
27
+ CommonMenus,
28
+ createPreferenceProxy,
29
+ KeybindingContribution,
30
+ KeybindingRegistry,
31
+ PreferenceContribution,
32
+ PreferenceScope,
33
+ PreferenceService,
34
+ QuickInputService,
35
+ Widget,
36
+ } from '@theia/core/lib/browser';
37
+ import { injectable, inject, interfaces, Container } from '@theia/core/shared/inversify';
38
+ import { EditorManager } from '@theia/editor/lib/browser';
39
+ import { ToolbarImpl } from './toolbar';
40
+ import { bindToolbarIconDialog } from './toolbar-icon-selector-dialog';
41
+ import {
42
+ ToolbarContribution,
43
+ ToolbarItemPosition,
44
+ ToolbarFactory,
45
+ Toolbar,
46
+ LateInjector,
47
+ lateInjector,
48
+ } from './toolbar-interfaces';
49
+ import { ToolbarCommandQuickInputService } from './toolbar-command-quick-input-service';
50
+ import { ToolbarStorageProvider } from './toolbar-storage-provider';
51
+ import { ToolbarController } from './toolbar-controller';
52
+ import { ToolbarPreferencesSchema, ToolbarPreferences, TOOLBAR_ENABLE_PREFERENCE_ID } from './toolbar-preference-contribution';
53
+ import { ToolbarDefaults, ToolbarDefaultsFactory } from './toolbar-defaults';
54
+ import { ToolbarCommands, ToolbarMenus, UserToolbarURI, USER_TOOLBAR_URI } from './toolbar-constants';
55
+ import { JsonSchemaContribution, JsonSchemaRegisterContext } from '@theia/core/lib/browser/json-schema-store';
56
+ import { toolbarConfigurationSchema, toolbarSchemaId } from './toolbar-preference-schema';
57
+ import URI from '@theia/core/lib/common/uri';
58
+
59
+ @injectable()
60
+ export class ToolbarCommandContribution implements CommandContribution, KeybindingContribution, MenuContribution, JsonSchemaContribution {
61
+ @inject(ToolbarController) protected readonly model: ToolbarController;
62
+ @inject(QuickInputService) protected readonly quickInputService: QuickInputService;
63
+ @inject(ToolbarCommandQuickInputService) protected toolbarCommandPickService: ToolbarCommandQuickInputService;
64
+ @inject(CommandService) protected readonly commandService: CommandService;
65
+ @inject(EditorManager) protected readonly editorManager: EditorManager;
66
+ @inject(PreferenceService) protected readonly preferenceService: PreferenceService;
67
+ @inject(ToolbarController) protected readonly toolbarModel: ToolbarController;
68
+ @inject(InMemoryResources) protected readonly inMemoryResources: InMemoryResources;
69
+ protected readonly schemaURI = new URI(toolbarSchemaId);
70
+
71
+ registerSchemas(context: JsonSchemaRegisterContext): void {
72
+ this.inMemoryResources.add(this.schemaURI, JSON.stringify(toolbarConfigurationSchema));
73
+ context.registerSchema({
74
+ fileMatch: ['toolbar.json'],
75
+ url: this.schemaURI.toString(),
76
+ });
77
+ }
78
+
79
+ registerCommands(registry: CommandRegistry): void {
80
+ registry.registerCommand(ToolbarCommands.CUSTOMIZE_TOOLBAR, {
81
+ execute: () => this.model.openOrCreateJSONFile(true),
82
+ });
83
+ registry.registerCommand(ToolbarCommands.RESET_TOOLBAR, {
84
+ execute: () => this.model.clearAll(),
85
+ });
86
+ registry.registerCommand(ToolbarCommands.TOGGLE_TOOLBAR, {
87
+ execute: () => {
88
+ const isVisible = this.preferenceService.get<boolean>(TOOLBAR_ENABLE_PREFERENCE_ID);
89
+ this.preferenceService.set(TOOLBAR_ENABLE_PREFERENCE_ID, !isVisible, PreferenceScope.User);
90
+ },
91
+ });
92
+
93
+ registry.registerCommand(ToolbarCommands.REMOVE_COMMAND_FROM_TOOLBAR, {
94
+ execute: async (_widget, position: ToolbarItemPosition | undefined, id?: string) => position && this.model.removeItem(position, id),
95
+ isVisible: (...args) => this.isToolbarWidget(args[0]),
96
+ });
97
+ registry.registerCommand(ToolbarCommands.INSERT_GROUP_LEFT, {
98
+ execute: async (_widget: Widget, position: ToolbarItemPosition | undefined) => position && this.model.insertGroup(position, 'left'),
99
+ isVisible: (widget: Widget, position: ToolbarItemPosition | undefined) => {
100
+ if (position) {
101
+ const { alignment, groupIndex, itemIndex } = position;
102
+ const owningGroupLength = this.toolbarModel.toolbarItems.items[alignment][groupIndex].length;
103
+ return this.isToolbarWidget(widget) && (owningGroupLength > 1) && (itemIndex > 0);
104
+ }
105
+ return false;
106
+ },
107
+ });
108
+ registry.registerCommand(ToolbarCommands.INSERT_GROUP_RIGHT, {
109
+ execute: async (_widget: Widget, position: ToolbarItemPosition | undefined) => position && this.model.insertGroup(position, 'right'),
110
+ isVisible: (widget: Widget, position: ToolbarItemPosition | undefined) => {
111
+ if (position) {
112
+ const { alignment, groupIndex, itemIndex } = position;
113
+ const owningGroupLength = this.toolbarModel.toolbarItems.items[alignment][groupIndex].length;
114
+ const isNotLastItem = itemIndex < (owningGroupLength - 1);
115
+ return this.isToolbarWidget(widget) && owningGroupLength > 1 && isNotLastItem;
116
+ }
117
+ return false;
118
+ },
119
+ });
120
+ registry.registerCommand(ToolbarCommands.ADD_COMMAND_TO_TOOLBAR, {
121
+ execute: () => this.toolbarCommandPickService.openIconDialog(),
122
+ });
123
+ }
124
+
125
+ protected isToolbarWidget(arg: unknown): boolean {
126
+ return arg instanceof ToolbarImpl;
127
+ }
128
+
129
+ registerKeybindings(keys: KeybindingRegistry): void {
130
+ keys.registerKeybinding({
131
+ command: ToolbarCommands.TOGGLE_TOOLBAR.id,
132
+ keybinding: 'alt+t',
133
+ });
134
+ }
135
+
136
+ registerMenus(registry: MenuModelRegistry): void {
137
+ registry.registerMenuAction(CommonMenus.VIEW_LAYOUT, {
138
+ commandId: ToolbarCommands.TOGGLE_TOOLBAR.id,
139
+ order: 'z',
140
+ });
141
+
142
+ registry.registerMenuAction(ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
143
+ commandId: ToolbarCommands.ADD_COMMAND_TO_TOOLBAR.id,
144
+ order: 'a',
145
+ });
146
+ registry.registerMenuAction(ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
147
+ commandId: ToolbarCommands.INSERT_GROUP_LEFT.id,
148
+ order: 'b',
149
+ });
150
+ registry.registerMenuAction(ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
151
+ commandId: ToolbarCommands.INSERT_GROUP_RIGHT.id,
152
+ order: 'c',
153
+ });
154
+ registry.registerMenuAction(ToolbarMenus.TOOLBAR_ITEM_CONTEXT_MENU, {
155
+ commandId: ToolbarCommands.REMOVE_COMMAND_FROM_TOOLBAR.id,
156
+ order: 'd',
157
+ });
158
+
159
+ registry.registerMenuAction(ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
160
+ commandId: ToolbarCommands.ADD_COMMAND_TO_TOOLBAR.id,
161
+ order: 'a',
162
+ });
163
+ registry.registerMenuAction(ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
164
+ commandId: ToolbarCommands.CUSTOMIZE_TOOLBAR.id,
165
+ order: 'b',
166
+ });
167
+ registry.registerMenuAction(ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
168
+ commandId: ToolbarCommands.TOGGLE_TOOLBAR.id,
169
+ order: 'c',
170
+ });
171
+ registry.registerMenuAction(ToolbarMenus.TOOLBAR_BACKGROUND_CONTEXT_MENU, {
172
+ commandId: ToolbarCommands.RESET_TOOLBAR.id,
173
+ order: 'd',
174
+ });
175
+ }
176
+ }
177
+
178
+ export function bindToolbar(bind: interfaces.Bind): void {
179
+ bind(ToolbarFactory).toFactory(({ container }) => (): Toolbar => {
180
+ const child = new Container({ defaultScope: 'Singleton' });
181
+ child.parent = container;
182
+ child.bind(Toolbar).to(ToolbarImpl);
183
+ return child.get(Toolbar);
184
+ });
185
+ bind(ToolbarCommandContribution).toSelf().inSingletonScope();
186
+ bind(CommandContribution).to(ToolbarCommandContribution);
187
+ bind(MenuContribution).toService(ToolbarCommandContribution);
188
+ bind(KeybindingContribution).toService(ToolbarCommandContribution);
189
+ bind(JsonSchemaContribution).toService(ToolbarCommandContribution);
190
+
191
+ bind(ToolbarCommandQuickInputService).toSelf().inSingletonScope();
192
+
193
+ bindToolbarIconDialog(bind);
194
+ bind(ToolbarDefaultsFactory).toConstantValue(ToolbarDefaults);
195
+ bind(ToolbarPreferences).toDynamicValue(({ container }) => {
196
+ const preferences = container.get<PreferenceService>(PreferenceService);
197
+ return createPreferenceProxy(preferences, ToolbarPreferencesSchema);
198
+ }).inSingletonScope();
199
+ bind(PreferenceContribution).toConstantValue({
200
+ schema: ToolbarPreferencesSchema,
201
+ });
202
+
203
+ bind(UserToolbarURI).toConstantValue(USER_TOOLBAR_URI);
204
+
205
+ bind(ToolbarController).toSelf().inSingletonScope();
206
+ bind(ToolbarStorageProvider).toSelf().inSingletonScope();
207
+ bindContributionProvider(bind, ToolbarContribution);
208
+ bind(LateInjector).toFactory(
209
+ <T>(context: interfaces.Context) => (id: interfaces.ServiceIdentifier<T>): T => lateInjector(context.container, id),
210
+ );
211
+ }
@@ -1,86 +1,86 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2022 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 { Command, CommandRegistry, CommandService, nls } from '@theia/core';
18
- import { QuickCommandService, QuickInputService, QuickPickItem } from '@theia/core/lib/browser';
19
- import { injectable, inject } from '@theia/core/shared/inversify';
20
- import { ToolbarIconDialogFactory } from './toolbar-icon-selector-dialog';
21
- import { ToolbarAlignment, ToolbarAlignmentString } from './toolbar-interfaces';
22
- import { ToolbarController } from './toolbar-controller';
23
-
24
- @injectable()
25
- export class ToolbarCommandQuickInputService {
26
- @inject(CommandService) protected readonly commandService: CommandService;
27
- @inject(QuickInputService) protected readonly quickInputService: QuickInputService;
28
- @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
29
- @inject(QuickCommandService) protected readonly quickCommandService: QuickCommandService;
30
- @inject(ToolbarController) protected readonly model: ToolbarController;
31
- @inject(ToolbarIconDialogFactory) protected readonly iconDialogFactory: ToolbarIconDialogFactory;
32
-
33
- protected quickPickItems: QuickPickItem[] = [];
34
-
35
- protected iconClass: string | undefined;
36
- protected commandToAdd: Command | undefined;
37
-
38
- protected columnQuickPickItems: QuickPickItem[] = [
39
- {
40
- label: nls.localize('theia/toolbar/leftColumn', 'Left Column'),
41
- id: ToolbarAlignment.LEFT,
42
- },
43
- {
44
- label: nls.localize('theia/toolbar/centerColumn', 'Center Column'),
45
- id: ToolbarAlignment.CENTER,
46
- },
47
- {
48
- label: nls.localize('theia/toolbar/rightColumn', 'Right Column'),
49
- id: ToolbarAlignment.RIGHT
50
- },
51
- ];
52
-
53
- openIconDialog(): void {
54
- this.quickPickItems = this.generateCommandsList();
55
- this.quickInputService.showQuickPick(this.quickPickItems, {
56
- placeholder: nls.localize('theia/toolbar/addCommandPlaceholder', 'Find a command to add to the toolbar'),
57
- });
58
- }
59
-
60
- protected openColumnQP(): Promise<QuickPickItem | undefined> {
61
- return this.quickInputService.showQuickPick(this.columnQuickPickItems, {
62
- placeholder: nls.localize('theia/toolbar/toolbarLocationPlaceholder', 'Where would you like the command added?')
63
- });
64
- }
65
-
66
- protected generateCommandsList(): QuickPickItem[] {
67
- const { recent, other } = this.quickCommandService.getCommands();
68
- return [...recent, ...other].map(command => {
69
- const formattedItem = this.quickCommandService.toItem(command) as QuickPickItem;
70
- return {
71
- ...formattedItem,
72
- alwaysShow: true,
73
- execute: async (): Promise<void> => {
74
- const iconDialog = this.iconDialogFactory(command);
75
- const iconClass = await iconDialog.open();
76
- if (iconClass) {
77
- const { id } = await this.openColumnQP() ?? {};
78
- if (ToolbarAlignmentString.is(id)) {
79
- this.model.addItem({ ...command, iconClass }, id);
80
- }
81
- }
82
- },
83
- };
84
- });
85
- }
86
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2022 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 { Command, CommandRegistry, CommandService, nls } from '@theia/core';
18
+ import { QuickCommandService, QuickInputService, QuickPickItem } from '@theia/core/lib/browser';
19
+ import { injectable, inject } from '@theia/core/shared/inversify';
20
+ import { ToolbarIconDialogFactory } from './toolbar-icon-selector-dialog';
21
+ import { ToolbarAlignment, ToolbarAlignmentString } from './toolbar-interfaces';
22
+ import { ToolbarController } from './toolbar-controller';
23
+
24
+ @injectable()
25
+ export class ToolbarCommandQuickInputService {
26
+ @inject(CommandService) protected readonly commandService: CommandService;
27
+ @inject(QuickInputService) protected readonly quickInputService: QuickInputService;
28
+ @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
29
+ @inject(QuickCommandService) protected readonly quickCommandService: QuickCommandService;
30
+ @inject(ToolbarController) protected readonly model: ToolbarController;
31
+ @inject(ToolbarIconDialogFactory) protected readonly iconDialogFactory: ToolbarIconDialogFactory;
32
+
33
+ protected quickPickItems: QuickPickItem[] = [];
34
+
35
+ protected iconClass: string | undefined;
36
+ protected commandToAdd: Command | undefined;
37
+
38
+ protected columnQuickPickItems: QuickPickItem[] = [
39
+ {
40
+ label: nls.localize('theia/toolbar/leftColumn', 'Left Column'),
41
+ id: ToolbarAlignment.LEFT,
42
+ },
43
+ {
44
+ label: nls.localize('theia/toolbar/centerColumn', 'Center Column'),
45
+ id: ToolbarAlignment.CENTER,
46
+ },
47
+ {
48
+ label: nls.localize('theia/toolbar/rightColumn', 'Right Column'),
49
+ id: ToolbarAlignment.RIGHT
50
+ },
51
+ ];
52
+
53
+ openIconDialog(): void {
54
+ this.quickPickItems = this.generateCommandsList();
55
+ this.quickInputService.showQuickPick(this.quickPickItems, {
56
+ placeholder: nls.localize('theia/toolbar/addCommandPlaceholder', 'Find a command to add to the toolbar'),
57
+ });
58
+ }
59
+
60
+ protected openColumnQP(): Promise<QuickPickItem | undefined> {
61
+ return this.quickInputService.showQuickPick(this.columnQuickPickItems, {
62
+ placeholder: nls.localize('theia/toolbar/toolbarLocationPlaceholder', 'Where would you like the command added?')
63
+ });
64
+ }
65
+
66
+ protected generateCommandsList(): QuickPickItem[] {
67
+ const { recent, other } = this.quickCommandService.getCommands();
68
+ return [...recent, ...other].map(command => {
69
+ const formattedItem = this.quickCommandService.toItem(command) as QuickPickItem;
70
+ return {
71
+ ...formattedItem,
72
+ alwaysShow: true,
73
+ execute: async (): Promise<void> => {
74
+ const iconDialog = this.iconDialogFactory(command);
75
+ const iconClass = await iconDialog.open();
76
+ if (iconClass) {
77
+ const { id } = await this.openColumnQP() ?? {};
78
+ if (ToolbarAlignmentString.is(id)) {
79
+ this.model.addItem({ ...command, iconClass }, id);
80
+ }
81
+ }
82
+ },
83
+ };
84
+ });
85
+ }
86
+ }