@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.
- package/README.md +7 -7
- package/i18n/nls.cs.json +158 -13
- package/i18n/nls.de.json +158 -13
- package/i18n/nls.es.json +158 -13
- package/i18n/nls.fr.json +158 -13
- package/i18n/nls.hu.json +158 -13
- package/i18n/nls.it.json +158 -13
- package/i18n/nls.ja.json +158 -13
- package/i18n/nls.json +159 -14
- package/i18n/nls.ko.json +158 -13
- package/i18n/nls.pl.json +158 -13
- package/i18n/nls.pt-br.json +158 -13
- package/i18n/nls.ru.json +158 -13
- package/i18n/nls.tr.json +158 -13
- package/i18n/nls.zh-cn.json +158 -13
- package/i18n/nls.zh-tw.json +158 -13
- package/lib/browser/catalog.json +206 -33
- package/lib/browser/common-frontend-contribution.d.ts +1 -1
- package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/common-frontend-contribution.js +13 -11
- package/lib/browser/common-frontend-contribution.js.map +1 -1
- package/lib/browser/context-menu-renderer.d.ts +14 -3
- package/lib/browser/context-menu-renderer.d.ts.map +1 -1
- package/lib/browser/context-menu-renderer.js +23 -1
- package/lib/browser/context-menu-renderer.js.map +1 -1
- package/lib/browser/frontend-application-module.d.ts.map +1 -1
- package/lib/browser/frontend-application-module.js +1 -3
- package/lib/browser/frontend-application-module.js.map +1 -1
- package/lib/browser/hover-service.d.ts.map +1 -1
- package/lib/browser/hover-service.js +7 -0
- package/lib/browser/hover-service.js.map +1 -1
- package/lib/browser/menu/action-menu-node.d.ts +36 -0
- package/lib/browser/menu/action-menu-node.d.ts.map +1 -0
- package/lib/browser/menu/action-menu-node.js +113 -0
- package/lib/browser/menu/action-menu-node.js.map +1 -0
- package/lib/browser/menu/browser-context-menu-renderer.d.ts +12 -4
- package/lib/browser/menu/browser-context-menu-renderer.d.ts.map +1 -1
- package/lib/browser/menu/browser-context-menu-renderer.js +12 -13
- package/lib/browser/menu/browser-context-menu-renderer.js.map +1 -1
- package/lib/browser/menu/browser-menu-module.d.ts.map +1 -1
- package/lib/browser/menu/browser-menu-module.js +4 -0
- package/lib/browser/menu/browser-menu-module.js.map +1 -1
- package/lib/browser/menu/browser-menu-node-factory.d.ts +13 -0
- package/lib/browser/menu/browser-menu-node-factory.d.ts.map +1 -0
- package/lib/browser/menu/browser-menu-node-factory.js +54 -0
- package/lib/browser/menu/browser-menu-node-factory.js.map +1 -0
- package/lib/browser/menu/browser-menu-plugin.d.ts +12 -30
- package/lib/browser/menu/browser-menu-plugin.d.ts.map +1 -1
- package/lib/browser/menu/browser-menu-plugin.js +78 -159
- package/lib/browser/menu/browser-menu-plugin.js.map +1 -1
- package/lib/browser/menu/composite-menu-node.d.ts +49 -0
- package/lib/browser/menu/composite-menu-node.d.ts.map +1 -0
- package/lib/browser/menu/composite-menu-node.js +127 -0
- package/lib/browser/menu/composite-menu-node.js.map +1 -0
- package/lib/browser/menu/menu.spec.d.ts.map +1 -0
- package/lib/{common → browser}/menu/menu.spec.js +38 -13
- package/lib/browser/menu/menu.spec.js.map +1 -0
- package/lib/browser/open-with-service.d.ts +1 -1
- package/lib/browser/saveable-service.d.ts.map +1 -1
- package/lib/browser/saveable-service.js +6 -1
- package/lib/browser/saveable-service.js.map +1 -1
- package/lib/browser/shell/application-shell.d.ts +7 -5
- package/lib/browser/shell/application-shell.d.ts.map +1 -1
- package/lib/browser/shell/application-shell.js +82 -28
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/shell/index.d.ts +1 -0
- package/lib/browser/shell/index.d.ts.map +1 -1
- package/lib/browser/shell/index.js +1 -0
- package/lib/browser/shell/index.js.map +1 -1
- package/lib/browser/shell/sidebar-bottom-menu-widget.d.ts.map +1 -1
- package/lib/browser/shell/sidebar-bottom-menu-widget.js +2 -1
- package/lib/browser/shell/sidebar-bottom-menu-widget.js.map +1 -1
- package/lib/browser/shell/sidebar-menu-widget.d.ts +4 -1
- package/lib/browser/shell/sidebar-menu-widget.d.ts.map +1 -1
- package/lib/browser/shell/sidebar-menu-widget.js +14 -1
- package/lib/browser/shell/sidebar-menu-widget.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.d.ts +66 -8
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.d.ts.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.js +161 -8
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.d.ts +18 -32
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.d.ts.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.js +52 -88
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.d.ts +17 -21
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.d.ts.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.js +9 -9
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.d.ts +7 -39
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.d.ts.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js +30 -238
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.js +13 -13
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-toolbar-item.d.ts +56 -0
- package/lib/browser/shell/tab-bar-toolbar/tab-toolbar-item.d.ts.map +1 -0
- package/lib/browser/shell/tab-bar-toolbar/tab-toolbar-item.js +208 -0
- package/lib/browser/shell/tab-bar-toolbar/tab-toolbar-item.js.map +1 -0
- package/lib/browser/shell/tab-bars.d.ts.map +1 -1
- package/lib/browser/shell/tab-bars.js +2 -1
- package/lib/browser/shell/tab-bars.js.map +1 -1
- package/lib/browser/shell/theia-dock-panel.d.ts +4 -10
- package/lib/browser/shell/theia-dock-panel.d.ts.map +1 -1
- package/lib/browser/shell/theia-dock-panel.js +7 -84
- package/lib/browser/shell/theia-dock-panel.js.map +1 -1
- package/lib/browser/shell/theia-split-panel.d.ts +6 -0
- package/lib/browser/shell/theia-split-panel.d.ts.map +1 -0
- package/lib/browser/shell/theia-split-panel.js +56 -0
- package/lib/browser/shell/theia-split-panel.js.map +1 -0
- package/lib/browser/tree/tree-widget.d.ts +1 -0
- package/lib/browser/tree/tree-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-widget.js +6 -0
- package/lib/browser/tree/tree-widget.js.map +1 -1
- package/lib/browser/view-container.d.ts +6 -3
- package/lib/browser/view-container.d.ts.map +1 -1
- package/lib/browser/view-container.js +36 -26
- package/lib/browser/view-container.js.map +1 -1
- package/lib/browser/window/default-secondary-window-service.d.ts +1 -0
- package/lib/browser/window/default-secondary-window-service.d.ts.map +1 -1
- package/lib/browser/window/default-secondary-window-service.js +3 -0
- package/lib/browser/window/default-secondary-window-service.js.map +1 -1
- package/lib/common/listener.d.ts +21 -0
- package/lib/common/listener.d.ts.map +1 -0
- package/lib/common/listener.js +81 -0
- package/lib/common/listener.js.map +1 -0
- package/lib/common/listener.spec.d.ts +2 -0
- package/lib/common/listener.spec.d.ts.map +1 -0
- package/lib/common/listener.spec.js +255 -0
- package/lib/common/listener.spec.js.map +1 -0
- package/lib/common/menu/index.d.ts +2 -3
- package/lib/common/menu/index.d.ts.map +1 -1
- package/lib/common/menu/index.js +2 -3
- package/lib/common/menu/index.js.map +1 -1
- package/lib/common/menu/menu-model-registry.d.ts +37 -50
- package/lib/common/menu/menu-model-registry.d.ts.map +1 -1
- package/lib/common/menu/menu-model-registry.js +176 -225
- package/lib/common/menu/menu-model-registry.js.map +1 -1
- package/lib/common/menu/menu-types.d.ts +58 -96
- package/lib/common/menu/menu-types.d.ts.map +1 -1
- package/lib/common/menu/menu-types.js +43 -39
- package/lib/common/menu/menu-types.js.map +1 -1
- package/lib/common/messaging/proxy-factory.d.ts.map +1 -1
- package/lib/common/messaging/proxy-factory.js +4 -0
- package/lib/common/messaging/proxy-factory.js.map +1 -1
- package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts +15 -5
- package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts.map +1 -1
- package/lib/electron-browser/menu/electron-context-menu-renderer.js +21 -14
- package/lib/electron-browser/menu/electron-context-menu-renderer.js.map +1 -1
- package/lib/electron-browser/menu/electron-main-menu-factory.d.ts +4 -16
- package/lib/electron-browser/menu/electron-main-menu-factory.d.ts.map +1 -1
- package/lib/electron-browser/menu/electron-main-menu-factory.js +84 -104
- package/lib/electron-browser/menu/electron-main-menu-factory.js.map +1 -1
- package/lib/electron-browser/menu/electron-menu-contribution.d.ts.map +1 -1
- package/lib/electron-browser/menu/electron-menu-contribution.js +1 -4
- package/lib/electron-browser/menu/electron-menu-contribution.js.map +1 -1
- package/lib/electron-browser/menu/electron-menu-module.d.ts.map +1 -1
- package/lib/electron-browser/menu/electron-menu-module.js +5 -0
- package/lib/electron-browser/menu/electron-menu-module.js.map +1 -1
- package/lib/electron-browser/window/electron-secondary-window-service.d.ts +1 -0
- package/lib/electron-browser/window/electron-secondary-window-service.d.ts.map +1 -1
- package/lib/electron-browser/window/electron-secondary-window-service.js +20 -0
- package/lib/electron-browser/window/electron-secondary-window-service.js.map +1 -1
- package/lib/electron-browser/window/electron-window-service.d.ts +3 -0
- package/lib/electron-browser/window/electron-window-service.d.ts.map +1 -1
- package/lib/electron-browser/window/electron-window-service.js +10 -1
- package/lib/electron-browser/window/electron-window-service.js.map +1 -1
- package/lib/electron-main/theia-electron-window.d.ts.map +1 -1
- package/lib/electron-main/theia-electron-window.js +2 -0
- package/lib/electron-main/theia-electron-window.js.map +1 -1
- package/package.json +7 -8
- package/src/browser/common-frontend-contribution.ts +14 -14
- package/src/browser/context-menu-renderer.ts +33 -5
- package/src/browser/frontend-application-module.ts +1 -7
- package/src/browser/hover-service.ts +7 -0
- package/src/browser/menu/action-menu-node.ts +128 -0
- package/src/browser/menu/browser-context-menu-renderer.ts +18 -11
- package/src/browser/menu/browser-menu-module.ts +4 -0
- package/src/browser/menu/browser-menu-node-factory.ts +48 -0
- package/src/browser/menu/browser-menu-plugin.ts +80 -168
- package/src/browser/menu/composite-menu-node.ts +140 -0
- package/src/{common → browser}/menu/menu.spec.ts +47 -15
- package/src/browser/open-with-service.ts +1 -1
- package/src/browser/saveable-service.ts +6 -1
- package/src/browser/shell/application-shell.ts +91 -29
- package/src/browser/shell/index.ts +1 -0
- package/src/browser/shell/sidebar-bottom-menu-widget.tsx +2 -1
- package/src/browser/shell/sidebar-menu-widget.tsx +12 -2
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.tsx +239 -0
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.ts +59 -102
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-types.ts +14 -23
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.ts +14 -14
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar.tsx +34 -261
- package/src/browser/shell/tab-bar-toolbar/tab-toolbar-item.tsx +251 -0
- package/src/browser/shell/tab-bars.ts +2 -1
- package/src/browser/shell/theia-dock-panel.ts +10 -91
- package/src/browser/shell/theia-split-panel.ts +56 -0
- package/src/browser/style/hover-service.css +6 -1
- package/src/browser/style/index.css +3 -11
- package/src/browser/style/view-container.css +17 -31
- package/src/browser/tree/tree-widget.tsx +7 -0
- package/src/browser/view-container.ts +51 -30
- package/src/browser/window/default-secondary-window-service.ts +4 -0
- package/src/common/listener.spec.ts +315 -0
- package/src/common/listener.ts +88 -0
- package/src/common/menu/index.ts +2 -3
- package/src/common/menu/menu-model-registry.ts +187 -230
- package/src/common/menu/menu-types.ts +82 -128
- package/src/common/messaging/proxy-factory.ts +4 -1
- package/src/electron-browser/menu/electron-context-menu-renderer.ts +29 -13
- package/src/electron-browser/menu/electron-main-menu-factory.ts +92 -116
- package/src/electron-browser/menu/electron-menu-contribution.ts +1 -4
- package/src/electron-browser/menu/electron-menu-module.ts +6 -1
- package/src/electron-browser/window/electron-secondary-window-service.ts +22 -0
- package/src/electron-browser/window/electron-window-service.ts +11 -1
- package/src/electron-main/theia-electron-window.ts +2 -0
- package/lib/common/menu/action-menu-node.d.ts +0 -20
- package/lib/common/menu/action-menu-node.d.ts.map +0 -1
- package/lib/common/menu/action-menu-node.js +0 -57
- package/lib/common/menu/action-menu-node.js.map +0 -1
- package/lib/common/menu/composite-menu-node.d.ts +0 -47
- package/lib/common/menu/composite-menu-node.d.ts.map +0 -1
- package/lib/common/menu/composite-menu-node.js +0 -96
- package/lib/common/menu/composite-menu-node.js.map +0 -1
- package/lib/common/menu/composite-menu-node.spec.d.ts +0 -2
- package/lib/common/menu/composite-menu-node.spec.d.ts.map +0 -1
- package/lib/common/menu/composite-menu-node.spec.js +0 -68
- package/lib/common/menu/composite-menu-node.spec.js.map +0 -1
- package/lib/common/menu/menu-adapter.d.ts +0 -36
- package/lib/common/menu/menu-adapter.d.ts.map +0 -1
- package/lib/common/menu/menu-adapter.js +0 -93
- package/lib/common/menu/menu-adapter.js.map +0 -1
- package/lib/common/menu/menu.spec.d.ts.map +0 -1
- package/lib/common/menu/menu.spec.js.map +0 -1
- package/lib/common/test/mock-menu.d.ts +0 -8
- package/lib/common/test/mock-menu.d.ts.map +0 -1
- package/lib/common/test/mock-menu.js +0 -35
- package/lib/common/test/mock-menu.js.map +0 -1
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-menu-adapters.ts +0 -31
- package/src/common/menu/action-menu-node.ts +0 -65
- package/src/common/menu/composite-menu-node.spec.ts +0 -67
- package/src/common/menu/composite-menu-node.ts +0 -116
- package/src/common/menu/menu-adapter.ts +0 -103
- package/src/common/test/mock-menu.ts +0 -35
- /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,
|
|
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 {
|
|
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
|
|
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:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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(() =>
|
|
87
|
-
|
|
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
|
|
128
|
+
visibleItems(widget: Widget): Array<TabBarToolbarItem> {
|
|
101
129
|
if (widget.isDisposed) {
|
|
102
130
|
return [];
|
|
103
131
|
}
|
|
104
|
-
const result: Array<TabBarToolbarItem
|
|
132
|
+
const result: Array<TabBarToolbarItem> = [];
|
|
105
133
|
for (const item of this.items.values()) {
|
|
106
|
-
if (
|
|
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 (
|
|
115
|
-
if (child
|
|
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 (
|
|
118
|
-
|
|
119
|
-
|
|
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
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
|
|
213
|
-
|
|
214
|
-
:
|
|
215
|
-
|
|
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
|
|
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
|
|
36
|
+
export type TabBarToolbarAction = RenderedToolbarAction | ReactTabBarToolbarAction;
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* Representation of an item in the tab
|
|
39
40
|
*/
|
|
40
|
-
export interface
|
|
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
|
|
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 `
|
|
109
|
+
* Unlike the `TabBarToolbarAction`, this item is not connected to the command service.
|
|
114
110
|
*/
|
|
115
|
-
export interface
|
|
111
|
+
export interface ReactTabBarToolbarAction extends TabBarToolbarActionBase {
|
|
116
112
|
render(widget?: Widget): React.ReactNode;
|
|
117
113
|
}
|
|
118
114
|
|
|
119
|
-
export namespace
|
|
120
|
-
export function is(item:
|
|
121
|
-
return isObject<
|
|
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
|
|
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:
|
|
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 {
|
|
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 =
|
|
37
|
+
const testMe = TabBarToolbarAction.PRIORITY_COMPARATOR;
|
|
38
38
|
|
|
39
39
|
it("should favour the 'navigation' group before everything else", () => {
|
|
40
|
-
expect(testMe({
|
|
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({
|
|
45
|
-
expect(testMe({
|
|
46
|
-
expect(testMe({
|
|
47
|
-
expect(testMe({
|
|
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({
|
|
52
|
-
expect(testMe({
|
|
53
|
-
expect(testMe({
|
|
54
|
-
expect(testMe({
|
|
55
|
-
expect(testMe({
|
|
56
|
-
expect(testMe({
|
|
57
|
-
expect(testMe({
|
|
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
|
});
|