@theia/core 1.62.0-next.3 → 1.62.1

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 (244) hide show
  1. package/README.md +7 -7
  2. package/i18n/nls.cs.json +158 -13
  3. package/i18n/nls.de.json +158 -13
  4. package/i18n/nls.es.json +158 -13
  5. package/i18n/nls.fr.json +158 -13
  6. package/i18n/nls.hu.json +158 -13
  7. package/i18n/nls.it.json +158 -13
  8. package/i18n/nls.ja.json +158 -13
  9. package/i18n/nls.json +159 -14
  10. package/i18n/nls.ko.json +158 -13
  11. package/i18n/nls.pl.json +158 -13
  12. package/i18n/nls.pt-br.json +158 -13
  13. package/i18n/nls.ru.json +158 -13
  14. package/i18n/nls.tr.json +158 -13
  15. package/i18n/nls.zh-cn.json +158 -13
  16. package/i18n/nls.zh-tw.json +158 -13
  17. package/lib/browser/catalog.json +206 -33
  18. package/lib/browser/common-frontend-contribution.d.ts +1 -1
  19. package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
  20. package/lib/browser/common-frontend-contribution.js +13 -11
  21. package/lib/browser/common-frontend-contribution.js.map +1 -1
  22. package/lib/browser/context-menu-renderer.d.ts +14 -3
  23. package/lib/browser/context-menu-renderer.d.ts.map +1 -1
  24. package/lib/browser/context-menu-renderer.js +23 -1
  25. package/lib/browser/context-menu-renderer.js.map +1 -1
  26. package/lib/browser/frontend-application-module.d.ts.map +1 -1
  27. package/lib/browser/frontend-application-module.js +1 -3
  28. package/lib/browser/frontend-application-module.js.map +1 -1
  29. package/lib/browser/hover-service.d.ts.map +1 -1
  30. package/lib/browser/hover-service.js +7 -0
  31. package/lib/browser/hover-service.js.map +1 -1
  32. package/lib/browser/menu/action-menu-node.d.ts +36 -0
  33. package/lib/browser/menu/action-menu-node.d.ts.map +1 -0
  34. package/lib/browser/menu/action-menu-node.js +113 -0
  35. package/lib/browser/menu/action-menu-node.js.map +1 -0
  36. package/lib/browser/menu/browser-context-menu-renderer.d.ts +12 -4
  37. package/lib/browser/menu/browser-context-menu-renderer.d.ts.map +1 -1
  38. package/lib/browser/menu/browser-context-menu-renderer.js +12 -13
  39. package/lib/browser/menu/browser-context-menu-renderer.js.map +1 -1
  40. package/lib/browser/menu/browser-menu-module.d.ts.map +1 -1
  41. package/lib/browser/menu/browser-menu-module.js +4 -0
  42. package/lib/browser/menu/browser-menu-module.js.map +1 -1
  43. package/lib/browser/menu/browser-menu-node-factory.d.ts +13 -0
  44. package/lib/browser/menu/browser-menu-node-factory.d.ts.map +1 -0
  45. package/lib/browser/menu/browser-menu-node-factory.js +54 -0
  46. package/lib/browser/menu/browser-menu-node-factory.js.map +1 -0
  47. package/lib/browser/menu/browser-menu-plugin.d.ts +12 -30
  48. package/lib/browser/menu/browser-menu-plugin.d.ts.map +1 -1
  49. package/lib/browser/menu/browser-menu-plugin.js +78 -159
  50. package/lib/browser/menu/browser-menu-plugin.js.map +1 -1
  51. package/lib/browser/menu/composite-menu-node.d.ts +49 -0
  52. package/lib/browser/menu/composite-menu-node.d.ts.map +1 -0
  53. package/lib/browser/menu/composite-menu-node.js +127 -0
  54. package/lib/browser/menu/composite-menu-node.js.map +1 -0
  55. package/lib/browser/menu/menu.spec.d.ts.map +1 -0
  56. package/lib/{common → browser}/menu/menu.spec.js +38 -13
  57. package/lib/browser/menu/menu.spec.js.map +1 -0
  58. package/lib/browser/open-with-service.d.ts +1 -1
  59. package/lib/browser/saveable-service.d.ts.map +1 -1
  60. package/lib/browser/saveable-service.js +6 -1
  61. package/lib/browser/saveable-service.js.map +1 -1
  62. package/lib/browser/shell/application-shell.d.ts +7 -5
  63. package/lib/browser/shell/application-shell.d.ts.map +1 -1
  64. package/lib/browser/shell/application-shell.js +82 -28
  65. package/lib/browser/shell/application-shell.js.map +1 -1
  66. package/lib/browser/shell/index.d.ts +1 -0
  67. package/lib/browser/shell/index.d.ts.map +1 -1
  68. package/lib/browser/shell/index.js +1 -0
  69. package/lib/browser/shell/index.js.map +1 -1
  70. package/lib/browser/shell/sidebar-bottom-menu-widget.d.ts.map +1 -1
  71. package/lib/browser/shell/sidebar-bottom-menu-widget.js +2 -1
  72. package/lib/browser/shell/sidebar-bottom-menu-widget.js.map +1 -1
  73. package/lib/browser/shell/sidebar-menu-widget.d.ts +4 -1
  74. package/lib/browser/shell/sidebar-menu-widget.d.ts.map +1 -1
  75. package/lib/browser/shell/sidebar-menu-widget.js +14 -1
  76. package/lib/browser/shell/sidebar-menu-widget.js.map +1 -1
  77. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.d.ts +66 -8
  78. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.d.ts.map +1 -1
  79. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.js +161 -8
  80. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.js.map +1 -1
  81. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.d.ts +18 -32
  82. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.d.ts.map +1 -1
  83. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.js +52 -88
  84. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.js.map +1 -1
  85. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.d.ts +17 -21
  86. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.d.ts.map +1 -1
  87. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.js +9 -9
  88. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.js.map +1 -1
  89. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.d.ts +7 -39
  90. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.d.ts.map +1 -1
  91. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js +30 -238
  92. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js.map +1 -1
  93. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.js +13 -13
  94. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.js.map +1 -1
  95. package/lib/browser/shell/tab-bar-toolbar/tab-toolbar-item.d.ts +56 -0
  96. package/lib/browser/shell/tab-bar-toolbar/tab-toolbar-item.d.ts.map +1 -0
  97. package/lib/browser/shell/tab-bar-toolbar/tab-toolbar-item.js +208 -0
  98. package/lib/browser/shell/tab-bar-toolbar/tab-toolbar-item.js.map +1 -0
  99. package/lib/browser/shell/tab-bars.d.ts.map +1 -1
  100. package/lib/browser/shell/tab-bars.js +2 -1
  101. package/lib/browser/shell/tab-bars.js.map +1 -1
  102. package/lib/browser/shell/theia-dock-panel.d.ts +4 -10
  103. package/lib/browser/shell/theia-dock-panel.d.ts.map +1 -1
  104. package/lib/browser/shell/theia-dock-panel.js +7 -84
  105. package/lib/browser/shell/theia-dock-panel.js.map +1 -1
  106. package/lib/browser/shell/theia-split-panel.d.ts +6 -0
  107. package/lib/browser/shell/theia-split-panel.d.ts.map +1 -0
  108. package/lib/browser/shell/theia-split-panel.js +56 -0
  109. package/lib/browser/shell/theia-split-panel.js.map +1 -0
  110. package/lib/browser/tree/tree-widget.d.ts +1 -0
  111. package/lib/browser/tree/tree-widget.d.ts.map +1 -1
  112. package/lib/browser/tree/tree-widget.js +6 -0
  113. package/lib/browser/tree/tree-widget.js.map +1 -1
  114. package/lib/browser/view-container.d.ts +6 -3
  115. package/lib/browser/view-container.d.ts.map +1 -1
  116. package/lib/browser/view-container.js +36 -26
  117. package/lib/browser/view-container.js.map +1 -1
  118. package/lib/browser/window/default-secondary-window-service.d.ts +1 -0
  119. package/lib/browser/window/default-secondary-window-service.d.ts.map +1 -1
  120. package/lib/browser/window/default-secondary-window-service.js +3 -0
  121. package/lib/browser/window/default-secondary-window-service.js.map +1 -1
  122. package/lib/common/listener.d.ts +21 -0
  123. package/lib/common/listener.d.ts.map +1 -0
  124. package/lib/common/listener.js +81 -0
  125. package/lib/common/listener.js.map +1 -0
  126. package/lib/common/listener.spec.d.ts +2 -0
  127. package/lib/common/listener.spec.d.ts.map +1 -0
  128. package/lib/common/listener.spec.js +255 -0
  129. package/lib/common/listener.spec.js.map +1 -0
  130. package/lib/common/menu/index.d.ts +2 -3
  131. package/lib/common/menu/index.d.ts.map +1 -1
  132. package/lib/common/menu/index.js +2 -3
  133. package/lib/common/menu/index.js.map +1 -1
  134. package/lib/common/menu/menu-model-registry.d.ts +37 -50
  135. package/lib/common/menu/menu-model-registry.d.ts.map +1 -1
  136. package/lib/common/menu/menu-model-registry.js +176 -225
  137. package/lib/common/menu/menu-model-registry.js.map +1 -1
  138. package/lib/common/menu/menu-types.d.ts +58 -96
  139. package/lib/common/menu/menu-types.d.ts.map +1 -1
  140. package/lib/common/menu/menu-types.js +43 -39
  141. package/lib/common/menu/menu-types.js.map +1 -1
  142. package/lib/common/messaging/proxy-factory.d.ts.map +1 -1
  143. package/lib/common/messaging/proxy-factory.js +4 -0
  144. package/lib/common/messaging/proxy-factory.js.map +1 -1
  145. package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts +15 -5
  146. package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts.map +1 -1
  147. package/lib/electron-browser/menu/electron-context-menu-renderer.js +21 -14
  148. package/lib/electron-browser/menu/electron-context-menu-renderer.js.map +1 -1
  149. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts +4 -16
  150. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts.map +1 -1
  151. package/lib/electron-browser/menu/electron-main-menu-factory.js +84 -104
  152. package/lib/electron-browser/menu/electron-main-menu-factory.js.map +1 -1
  153. package/lib/electron-browser/menu/electron-menu-contribution.d.ts.map +1 -1
  154. package/lib/electron-browser/menu/electron-menu-contribution.js +1 -4
  155. package/lib/electron-browser/menu/electron-menu-contribution.js.map +1 -1
  156. package/lib/electron-browser/menu/electron-menu-module.d.ts.map +1 -1
  157. package/lib/electron-browser/menu/electron-menu-module.js +5 -0
  158. package/lib/electron-browser/menu/electron-menu-module.js.map +1 -1
  159. package/lib/electron-browser/window/electron-secondary-window-service.d.ts +1 -0
  160. package/lib/electron-browser/window/electron-secondary-window-service.d.ts.map +1 -1
  161. package/lib/electron-browser/window/electron-secondary-window-service.js +20 -0
  162. package/lib/electron-browser/window/electron-secondary-window-service.js.map +1 -1
  163. package/lib/electron-browser/window/electron-window-service.d.ts +3 -0
  164. package/lib/electron-browser/window/electron-window-service.d.ts.map +1 -1
  165. package/lib/electron-browser/window/electron-window-service.js +10 -1
  166. package/lib/electron-browser/window/electron-window-service.js.map +1 -1
  167. package/lib/electron-main/theia-electron-window.d.ts.map +1 -1
  168. package/lib/electron-main/theia-electron-window.js +2 -0
  169. package/lib/electron-main/theia-electron-window.js.map +1 -1
  170. package/package.json +7 -8
  171. package/src/browser/common-frontend-contribution.ts +14 -14
  172. package/src/browser/context-menu-renderer.ts +33 -5
  173. package/src/browser/frontend-application-module.ts +1 -7
  174. package/src/browser/hover-service.ts +7 -0
  175. package/src/browser/menu/action-menu-node.ts +128 -0
  176. package/src/browser/menu/browser-context-menu-renderer.ts +18 -11
  177. package/src/browser/menu/browser-menu-module.ts +4 -0
  178. package/src/browser/menu/browser-menu-node-factory.ts +48 -0
  179. package/src/browser/menu/browser-menu-plugin.ts +80 -168
  180. package/src/browser/menu/composite-menu-node.ts +140 -0
  181. package/src/{common → browser}/menu/menu.spec.ts +47 -15
  182. package/src/browser/open-with-service.ts +1 -1
  183. package/src/browser/saveable-service.ts +6 -1
  184. package/src/browser/shell/application-shell.ts +91 -29
  185. package/src/browser/shell/index.ts +1 -0
  186. package/src/browser/shell/sidebar-bottom-menu-widget.tsx +2 -1
  187. package/src/browser/shell/sidebar-menu-widget.tsx +12 -2
  188. package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.tsx +239 -0
  189. package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.ts +59 -102
  190. package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.ts +14 -23
  191. package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.ts +14 -14
  192. package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar.tsx +34 -261
  193. package/src/browser/shell/tab-bar-toolbar/tab-toolbar-item.tsx +251 -0
  194. package/src/browser/shell/tab-bars.ts +2 -1
  195. package/src/browser/shell/theia-dock-panel.ts +10 -91
  196. package/src/browser/shell/theia-split-panel.ts +56 -0
  197. package/src/browser/style/hover-service.css +6 -1
  198. package/src/browser/style/index.css +3 -11
  199. package/src/browser/style/view-container.css +17 -31
  200. package/src/browser/tree/tree-widget.tsx +7 -0
  201. package/src/browser/view-container.ts +51 -30
  202. package/src/browser/window/default-secondary-window-service.ts +4 -0
  203. package/src/common/listener.spec.ts +315 -0
  204. package/src/common/listener.ts +88 -0
  205. package/src/common/menu/index.ts +2 -3
  206. package/src/common/menu/menu-model-registry.ts +187 -230
  207. package/src/common/menu/menu-types.ts +82 -128
  208. package/src/common/messaging/proxy-factory.ts +4 -1
  209. package/src/electron-browser/menu/electron-context-menu-renderer.ts +29 -13
  210. package/src/electron-browser/menu/electron-main-menu-factory.ts +92 -116
  211. package/src/electron-browser/menu/electron-menu-contribution.ts +1 -4
  212. package/src/electron-browser/menu/electron-menu-module.ts +6 -1
  213. package/src/electron-browser/window/electron-secondary-window-service.ts +22 -0
  214. package/src/electron-browser/window/electron-window-service.ts +11 -1
  215. package/src/electron-main/theia-electron-window.ts +2 -0
  216. package/lib/common/menu/action-menu-node.d.ts +0 -20
  217. package/lib/common/menu/action-menu-node.d.ts.map +0 -1
  218. package/lib/common/menu/action-menu-node.js +0 -57
  219. package/lib/common/menu/action-menu-node.js.map +0 -1
  220. package/lib/common/menu/composite-menu-node.d.ts +0 -47
  221. package/lib/common/menu/composite-menu-node.d.ts.map +0 -1
  222. package/lib/common/menu/composite-menu-node.js +0 -96
  223. package/lib/common/menu/composite-menu-node.js.map +0 -1
  224. package/lib/common/menu/composite-menu-node.spec.d.ts +0 -2
  225. package/lib/common/menu/composite-menu-node.spec.d.ts.map +0 -1
  226. package/lib/common/menu/composite-menu-node.spec.js +0 -68
  227. package/lib/common/menu/composite-menu-node.spec.js.map +0 -1
  228. package/lib/common/menu/menu-adapter.d.ts +0 -36
  229. package/lib/common/menu/menu-adapter.d.ts.map +0 -1
  230. package/lib/common/menu/menu-adapter.js +0 -93
  231. package/lib/common/menu/menu-adapter.js.map +0 -1
  232. package/lib/common/menu/menu.spec.d.ts.map +0 -1
  233. package/lib/common/menu/menu.spec.js.map +0 -1
  234. package/lib/common/test/mock-menu.d.ts +0 -8
  235. package/lib/common/test/mock-menu.d.ts.map +0 -1
  236. package/lib/common/test/mock-menu.js +0 -35
  237. package/lib/common/test/mock-menu.js.map +0 -1
  238. package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.ts +0 -31
  239. package/src/common/menu/action-menu-node.ts +0 -65
  240. package/src/common/menu/composite-menu-node.spec.ts +0 -67
  241. package/src/common/menu/composite-menu-node.ts +0 -116
  242. package/src/common/menu/menu-adapter.ts +0 -103
  243. package/src/common/test/mock-menu.ts +0 -35
  244. /package/lib/{common → browser}/menu/menu.spec.d.ts +0 -0
@@ -17,12 +17,17 @@
17
17
  import debounce = require('lodash.debounce');
18
18
  import { inject, injectable, named } from 'inversify';
19
19
  // eslint-disable-next-line max-len
20
- import { CommandRegistry, ContributionProvider, Disposable, DisposableCollection, Emitter, Event, MenuModelRegistry, MenuNode, MenuPath } from '../../../common';
20
+ import { CommandRegistry, ContributionProvider, Disposable, DisposableCollection, Emitter, Event, MenuModelRegistry, MenuPath } from '../../../common';
21
21
  import { ContextKeyService } from '../../context-key-service';
22
22
  import { FrontendApplicationContribution } from '../../frontend-application-contribution';
23
23
  import { Widget } from '../../widgets';
24
- import { MenuDelegate, ReactTabBarToolbarItem, RenderedToolbarItem, TabBarToolbarItem } from './tab-bar-toolbar-types';
25
- import { ToolbarMenuNodeWrapper } from './tab-bar-toolbar-menu-adapters';
24
+ import { ReactTabBarToolbarAction, RenderedToolbarAction } from './tab-bar-toolbar-types';
25
+ import { ToolbarMenuNodeWrapper, ToolbarSubmenuWrapper } from './tab-bar-toolbar-menu-adapters';
26
+ import { KeybindingRegistry } from '../../keybinding';
27
+ import { LabelParser } from '../../label-parser';
28
+ import { ContextMenuRenderer } from '../../context-menu-renderer';
29
+ import { CommandMenu, CompoundMenuNode, RenderedMenuNode } from '../../../common/menu';
30
+ import { ReactToolbarItemImpl, RenderedToolbarItemImpl, TabBarToolbarItem } from './tab-toolbar-item';
26
31
 
27
32
  /**
28
33
  * Clients should implement this interface if they want to contribute to the tab-bar toolbar.
@@ -39,21 +44,26 @@ export interface TabBarToolbarContribution {
39
44
  registerToolbarItems(registry: TabBarToolbarRegistry): void;
40
45
  }
41
46
 
42
- function yes(): true { return true; }
43
47
  const menuDelegateSeparator = '=@=';
44
-
48
+ interface MenuDelegate {
49
+ menuPath: MenuPath;
50
+ isVisible(widget?: Widget): boolean;
51
+ }
45
52
  /**
46
53
  * Main, shared registry for tab-bar toolbar items.
47
54
  */
48
55
  @injectable()
49
56
  export class TabBarToolbarRegistry implements FrontendApplicationContribution {
50
57
 
51
- protected items = new Map<string, TabBarToolbarItem | ReactTabBarToolbarItem>();
58
+ protected items = new Map<string, TabBarToolbarItem>();
52
59
  protected menuDelegates = new Map<string, MenuDelegate>();
53
60
 
54
61
  @inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
55
62
  @inject(ContextKeyService) protected readonly contextKeyService: ContextKeyService;
56
63
  @inject(MenuModelRegistry) protected readonly menuRegistry: MenuModelRegistry;
64
+ @inject(KeybindingRegistry) protected readonly keybindingRegistry: KeybindingRegistry;
65
+ @inject(LabelParser) protected readonly labelParser: LabelParser;
66
+ @inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer;
57
67
 
58
68
  @inject(ContributionProvider) @named(TabBarToolbarContribution)
59
69
  protected readonly contributionProvider: ContributionProvider<TabBarToolbarContribution>;
@@ -75,17 +85,35 @@ export class TabBarToolbarRegistry implements FrontendApplicationContribution {
75
85
  *
76
86
  * @param item the item to register.
77
87
  */
78
- registerItem(item: RenderedToolbarItem | ReactTabBarToolbarItem): Disposable {
79
- const { id } = item;
80
- if (this.items.has(id)) {
81
- throw new Error(`A toolbar item is already registered with the '${id}' ID.`);
88
+ registerItem(item: RenderedToolbarAction | ReactTabBarToolbarAction): Disposable {
89
+ if (ReactTabBarToolbarAction.is(item)) {
90
+ return this.doRegisterItem(new ReactToolbarItemImpl(this.commandRegistry, this.contextKeyService, item));
91
+ } else {
92
+ if (item.menuPath) {
93
+ return this.doRegisterItem(new ToolbarSubmenuWrapper(item.menuPath,
94
+ this.commandRegistry, this.menuRegistry, this.contextKeyService, this.contextMenuRenderer, item));
95
+ } else {
96
+ const wrapper = new RenderedToolbarItemImpl(this.commandRegistry, this.contextKeyService, this.keybindingRegistry, this.labelParser, item);
97
+ const disposables = this.doRegisterItem(wrapper);
98
+ disposables.push(wrapper);
99
+ return disposables;
100
+ }
101
+ }
102
+ }
103
+
104
+ doRegisterItem(item: TabBarToolbarItem): DisposableCollection {
105
+ if (this.items.has(item.id)) {
106
+ throw new Error(`A toolbar item is already registered with the '${item.id}' ID.`);
82
107
  }
83
- this.items.set(id, item);
108
+ this.items.set(item.id, item);
84
109
  this.fireOnDidChange();
85
110
  const toDispose = new DisposableCollection(
86
- Disposable.create(() => this.fireOnDidChange()),
87
- Disposable.create(() => this.items.delete(id))
111
+ Disposable.create(() => {
112
+ this.items.delete(item.id);
113
+ this.fireOnDidChange();
114
+ })
88
115
  );
116
+
89
117
  if (item.onDidChange) {
90
118
  toDispose.push(item.onDidChange(() => this.fireOnDidChange()));
91
119
  }
@@ -97,31 +125,32 @@ export class TabBarToolbarRegistry implements FrontendApplicationContribution {
97
125
  *
98
126
  * By default returns with all items where the command is enabled and `item.isVisible` is `true`.
99
127
  */
100
- visibleItems(widget: Widget): Array<TabBarToolbarItem | ReactTabBarToolbarItem> {
128
+ visibleItems(widget: Widget): Array<TabBarToolbarItem> {
101
129
  if (widget.isDisposed) {
102
130
  return [];
103
131
  }
104
- const result: Array<TabBarToolbarItem | ReactTabBarToolbarItem> = [];
132
+ const result: Array<TabBarToolbarItem> = [];
105
133
  for (const item of this.items.values()) {
106
- if (this.isItemVisible(item, widget)) {
134
+ if (item.isVisible(widget)) {
107
135
  result.push(item);
108
136
  }
109
137
  }
138
+
110
139
  for (const delegate of this.menuDelegates.values()) {
111
140
  if (delegate.isVisible(widget)) {
112
- const menu = this.menuRegistry.getMenu(delegate.menuPath);
141
+ const menu = this.menuRegistry.getMenu(delegate.menuPath)!;
113
142
  for (const child of menu.children) {
114
- if (!child.when || this.contextKeyService.match(child.when, widget.node)) {
115
- if (child.children) {
143
+ if (child.isVisible([...delegate.menuPath, child.id], this.contextKeyService, widget.node)) {
144
+ if (CompoundMenuNode.is(child)) {
116
145
  for (const grandchild of child.children) {
117
- if (!grandchild.when || this.contextKeyService.match(grandchild.when, widget.node)) {
118
- const menuPath = this.menuRegistry.getPath(grandchild);
119
- result.push(new ToolbarMenuNodeWrapper(grandchild, child.id, delegate.menuPath, menuPath));
146
+ if (grandchild.isVisible([...delegate.menuPath, child.id, grandchild.id], this.contextKeyService, widget.node) && RenderedMenuNode.is(grandchild)) {
147
+ result.push(new ToolbarMenuNodeWrapper([...delegate.menuPath, child.id, grandchild.id], this.commandRegistry, this.menuRegistry,
148
+ this.contextKeyService, this.contextMenuRenderer, grandchild, child.id, delegate.menuPath));
120
149
  }
121
150
  }
122
- } else if (child.command) {
123
- const menuPath = this.menuRegistry.getPath(child);
124
- result.push(new ToolbarMenuNodeWrapper(child, undefined, delegate.menuPath, menuPath));
151
+ } else if (CommandMenu.is(child)) {
152
+ result.push(new ToolbarMenuNodeWrapper([...delegate.menuPath, child.id], this.commandRegistry, this.menuRegistry,
153
+ this.contextKeyService, this.contextMenuRenderer, child, undefined, delegate.menuPath));
125
154
  }
126
155
  }
127
156
  }
@@ -130,77 +159,7 @@ export class TabBarToolbarRegistry implements FrontendApplicationContribution {
130
159
  return result;
131
160
  }
132
161
 
133
- /**
134
- * Query whether a toolbar `item` should be shown in the toolbar.
135
- * This implementation delegates to item-specific checks according to their type.
136
- *
137
- * @param item a menu toolbar item
138
- * @param widget the widget that is updating the toolbar
139
- * @returns `false` if the `item` should be suppressed, otherwise `true`
140
- */
141
- protected isItemVisible(item: TabBarToolbarItem | ReactTabBarToolbarItem, widget: Widget): boolean {
142
- if (!this.isConditionalItemVisible(item, widget)) {
143
- return false;
144
- }
145
-
146
- if (item.command && !this.commandRegistry.isVisible(item.command, widget)) {
147
- return false;
148
- }
149
- if (item.menuPath && !this.isNonEmptyMenu(item, widget)) {
150
- return false;
151
- }
152
-
153
- // The item is not vetoed. Accept it
154
- return true;
155
- }
156
-
157
- /**
158
- * Query whether a conditional toolbar `item` should be shown in the toolbar.
159
- * This implementation delegates to the `item`'s own intrinsic conditionality.
160
- *
161
- * @param item a menu toolbar item
162
- * @param widget the widget that is updating the toolbar
163
- * @returns `false` if the `item` should be suppressed, otherwise `true`
164
- */
165
- protected isConditionalItemVisible(item: TabBarToolbarItem, widget: Widget): boolean {
166
- if (item.isVisible && !item.isVisible(widget)) {
167
- return false;
168
- }
169
- if (item.when && !this.contextKeyService.match(item.when, widget.node)) {
170
- return false;
171
- }
172
- return true;
173
- }
174
-
175
- /**
176
- * Query whether a menu toolbar `item` should be shown in the toolbar.
177
- * This implementation returns `false` if the `item` does not have any actual menu to show.
178
- *
179
- * @param item a menu toolbar item
180
- * @param widget the widget that is updating the toolbar
181
- * @returns `false` if the `item` should be suppressed, otherwise `true`
182
- */
183
- isNonEmptyMenu(item: TabBarToolbarItem, widget: Widget | undefined): boolean {
184
- if (!item.menuPath) {
185
- return false;
186
- }
187
- const menu = this.menuRegistry.getMenu(item.menuPath);
188
- const isVisible: (node: MenuNode) => boolean = node =>
189
- node.children?.length
190
- // Either the node is a sub-menu that has some visible child ...
191
- ? node.children?.some(isVisible)
192
- // ... or there is a command ...
193
- : !!node.command
194
- // ... that is visible ...
195
- && this.commandRegistry.isVisible(node.command, widget)
196
- // ... and a "when" clause does not suppress the menu node.
197
- && (!node.when || this.contextKeyService.match(node.when, widget?.node));
198
-
199
- return isVisible(menu);
200
- }
201
-
202
- unregisterItem(itemOrId: TabBarToolbarItem | ReactTabBarToolbarItem | string): void {
203
- const id = typeof itemOrId === 'string' ? itemOrId : itemOrId.id;
162
+ unregisterItem(id: string): void {
204
163
  if (this.items.delete(id)) {
205
164
  this.fireOnDidChange();
206
165
  }
@@ -209,12 +168,10 @@ export class TabBarToolbarRegistry implements FrontendApplicationContribution {
209
168
  registerMenuDelegate(menuPath: MenuPath, when?: ((widget: Widget) => boolean)): Disposable {
210
169
  const id = this.toElementId(menuPath);
211
170
  if (!this.menuDelegates.has(id)) {
212
- const isVisible: MenuDelegate['isVisible'] = !when
213
- ? yes
214
- : typeof when === 'function'
215
- ? when
216
- : widget => this.contextKeyService.match(when, widget?.node);
217
- this.menuDelegates.set(id, { menuPath, isVisible });
171
+
172
+ this.menuDelegates.set(id, {
173
+ menuPath, isVisible: (widget: Widget) => !when || when(widget)
174
+ });
218
175
  this.fireOnDidChange();
219
176
  return { dispose: () => this.unregisterMenuDelegate(menuPath) };
220
177
  }
@@ -15,8 +15,9 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import * as React from 'react';
18
- import { ArrayUtils, Event, isFunction, isObject, MenuPath } from '../../../common';
18
+ import { ArrayUtils, Event, isFunction, isObject } from '../../../common';
19
19
  import { Widget } from '../../widgets';
20
+ import { MenuPath } from '../../../common/menu';
20
21
 
21
22
  /** Items whose group is exactly 'navigation' will be rendered inline. */
22
23
  export const NAVIGATION = 'navigation';
@@ -32,12 +33,12 @@ export namespace TabBarDelegator {
32
33
  }
33
34
  }
34
35
 
35
- export type TabBarToolbarItem = RenderedToolbarItem | ReactTabBarToolbarItem;
36
+ export type TabBarToolbarAction = RenderedToolbarAction | ReactTabBarToolbarAction;
36
37
 
37
38
  /**
38
39
  * Representation of an item in the tab
39
40
  */
40
- export interface TabBarToolbarItemBase {
41
+ export interface TabBarToolbarActionBase {
41
42
  /**
42
43
  * The unique ID of the toolbar item.
43
44
  */
@@ -55,6 +56,7 @@ export interface TabBarToolbarItemBase {
55
56
  * Checked before the item is shown.
56
57
  */
57
58
  isVisible?(widget?: Widget): boolean;
59
+
58
60
  /**
59
61
  * When defined, the container tool-bar will be updated if this event is fired.
60
62
  *
@@ -69,22 +71,16 @@ export interface TabBarToolbarItemBase {
69
71
  group?: string;
70
72
  /**
71
73
  * A menu path with which this item is associated.
72
- * If accompanied by a command, this data will be passed to the {@link MenuCommandExecutor}.
73
- * If no command is present, this menu will be opened.
74
74
  */
75
75
  menuPath?: MenuPath;
76
- /**
77
- * The path of the menu delegate that contributed this toolbar item
78
- */
79
- delegateMenuPath?: MenuPath;
80
- contextKeyOverlays?: Record<string, string>;
76
+
81
77
  /**
82
78
  * Optional ordering string for placing the item within its group
83
79
  */
84
80
  order?: string;
85
81
  }
86
82
 
87
- export interface RenderedToolbarItem extends TabBarToolbarItemBase {
83
+ export interface RenderedToolbarAction extends TabBarToolbarActionBase {
88
84
  /**
89
85
  * Optional icon for the item.
90
86
  */
@@ -110,29 +106,24 @@ export interface RenderedToolbarItem extends TabBarToolbarItemBase {
110
106
 
111
107
  /**
112
108
  * Tab-bar toolbar item backed by a `React.ReactNode`.
113
- * Unlike the `TabBarToolbarItem`, this item is not connected to the command service.
109
+ * Unlike the `TabBarToolbarAction`, this item is not connected to the command service.
114
110
  */
115
- export interface ReactTabBarToolbarItem extends TabBarToolbarItemBase {
111
+ export interface ReactTabBarToolbarAction extends TabBarToolbarActionBase {
116
112
  render(widget?: Widget): React.ReactNode;
117
113
  }
118
114
 
119
- export namespace ReactTabBarToolbarItem {
120
- export function is(item: TabBarToolbarItem): item is ReactTabBarToolbarItem {
121
- return isObject<ReactTabBarToolbarItem>(item) && typeof item.render === 'function';
115
+ export namespace ReactTabBarToolbarAction {
116
+ export function is(item: TabBarToolbarAction): item is ReactTabBarToolbarAction {
117
+ return isObject<ReactTabBarToolbarAction>(item) && typeof item.render === 'function';
122
118
  }
123
119
  }
124
120
 
125
- export interface MenuDelegate {
126
- menuPath: MenuPath;
127
- isVisible(widget?: Widget): boolean;
128
- }
129
-
130
- export namespace TabBarToolbarItem {
121
+ export namespace TabBarToolbarAction {
131
122
 
132
123
  /**
133
124
  * Compares the items by `priority` in ascending. Undefined priorities will be treated as `0`.
134
125
  */
135
- export const PRIORITY_COMPARATOR = (left: TabBarToolbarItem, right: TabBarToolbarItem) => {
126
+ export const PRIORITY_COMPARATOR = (left: { group?: string, priority?: number }, right: { group?: string, priority?: number }) => {
136
127
  const leftGroup: string = left.group ?? NAVIGATION;
137
128
  const rightGroup: string = right.group ?? NAVIGATION;
138
129
  if (leftGroup === NAVIGATION && rightGroup !== NAVIGATION) {
@@ -18,7 +18,7 @@ import { enableJSDOM } from '../../test/jsdom';
18
18
 
19
19
  let disableJSDOM = enableJSDOM();
20
20
  import { expect } from 'chai';
21
- import { TabBarToolbarItem } from './tab-bar-toolbar-types';
21
+ import { TabBarToolbarAction } from './tab-bar-toolbar-types';
22
22
 
23
23
  disableJSDOM();
24
24
 
@@ -34,27 +34,27 @@ describe('tab-bar-toolbar', () => {
34
34
  disableJSDOM();
35
35
  });
36
36
 
37
- const testMe = TabBarToolbarItem.PRIORITY_COMPARATOR;
37
+ const testMe = TabBarToolbarAction.PRIORITY_COMPARATOR;
38
38
 
39
39
  it("should favour the 'navigation' group before everything else", () => {
40
- expect(testMe({ id: 'a', command: 'a', group: 'navigation' }, { id: 'b', command: 'b', group: 'other' })).to.be.equal(-1);
40
+ expect(testMe({ group: 'navigation' }, { group: 'other' })).to.be.equal(-1);
41
41
  });
42
42
 
43
43
  it("should treat 'undefined' groups as 'navigation'", () => {
44
- expect(testMe({ id: 'a', command: 'a' }, { id: 'b', command: 'b' })).to.be.equal(0);
45
- expect(testMe({ id: 'a', command: 'a', group: 'navigation' }, { id: 'b', command: 'b' })).to.be.equal(0);
46
- expect(testMe({ id: 'a', command: 'a' }, { id: 'b', command: 'b', group: 'navigation' })).to.be.equal(0);
47
- expect(testMe({ id: 'a', command: 'a' }, { id: 'b', command: 'b', group: 'other' })).to.be.equal(-1);
44
+ expect(testMe({}, {})).to.be.equal(0);
45
+ expect(testMe({ group: 'navigation' }, {})).to.be.equal(0);
46
+ expect(testMe({}, { group: 'navigation' })).to.be.equal(0);
47
+ expect(testMe({}, { group: 'other' })).to.be.equal(-1);
48
48
  });
49
49
 
50
50
  it("should fall back to 'priority' if the groups are the same", () => {
51
- expect(testMe({ id: 'a', command: 'a', priority: 1 }, { id: 'b', command: 'b', priority: 2 })).to.be.equal(-1);
52
- expect(testMe({ id: 'a', command: 'a', group: 'navigation', priority: 1 }, { id: 'b', command: 'b', priority: 2 })).to.be.equal(-1);
53
- expect(testMe({ id: 'a', command: 'a', priority: 1 }, { id: 'b', command: 'b', group: 'navigation', priority: 2 })).to.be.equal(-1);
54
- expect(testMe({ id: 'a', command: 'a', priority: 1, group: 'other' }, { id: 'b', command: 'b', priority: 2 })).to.be.equal(1);
55
- expect(testMe({ id: 'a', command: 'a', group: 'other', priority: 1 }, { id: 'b', command: 'b', priority: 2, group: 'other' })).to.be.equal(-1);
56
- expect(testMe({ id: 'a', command: 'a', priority: 10 }, { id: 'b', command: 'b', group: 'other', priority: 2 })).to.be.equal(-1);
57
- expect(testMe({ id: 'a', command: 'a', group: 'other', priority: 10 }, { id: 'b', command: 'b', group: 'other', priority: 10 })).to.be.equal(0);
51
+ expect(testMe({ priority: 1 }, { priority: 2 })).to.be.equal(-1);
52
+ expect(testMe({ group: 'navigation', priority: 1 }, { priority: 2 })).to.be.equal(-1);
53
+ expect(testMe({ priority: 1 }, { group: 'navigation', priority: 2 })).to.be.equal(-1);
54
+ expect(testMe({ priority: 1, group: 'other' }, { priority: 2 })).to.be.equal(1);
55
+ expect(testMe({ group: 'other', priority: 1 }, { priority: 2, group: 'other' })).to.be.equal(-1);
56
+ expect(testMe({ priority: 10 }, { group: 'other', priority: 2 })).to.be.equal(-1);
57
+ expect(testMe({ group: 'other', priority: 10 }, { group: 'other', priority: 10 })).to.be.equal(0);
58
58
  });
59
59
 
60
60
  });