@opensumi/ide-main-layout 2.21.13 → 2.22.0
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/lib/browser/accordion/accordion.service.js +1 -1
- package/lib/browser/accordion/accordion.service.js.map +1 -1
- package/lib/browser/accordion/styles.module.less +4 -2
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/layout.service.d.ts.map +1 -1
- package/lib/browser/layout.service.js +6 -6
- package/lib/browser/layout.service.js.map +1 -1
- package/lib/browser/main-layout.contribution.js +1 -1
- package/lib/browser/main-layout.contribution.js.map +1 -1
- package/lib/browser/quick-open-view.js +3 -2
- package/lib/browser/quick-open-view.js.map +1 -1
- package/lib/browser/tabbar/tabbar.service.js.map +1 -1
- package/lib/browser/tabbar-handler.js.map +1 -1
- package/lib/browser/views-registry.js +7 -7
- package/lib/browser/views-registry.js.map +1 -1
- package/package.json +10 -9
- package/src/browser/accordion/accordion.service.ts +635 -0
- package/src/browser/accordion/accordion.view.tsx +102 -0
- package/src/browser/accordion/section.view.tsx +181 -0
- package/src/browser/accordion/styles.module.less +214 -0
- package/src/browser/accordion/titlebar.view.tsx +17 -0
- package/src/browser/default-config.ts +35 -0
- package/src/browser/index.ts +40 -0
- package/src/browser/input/index.tsx +32 -0
- package/src/browser/layout.service.ts +515 -0
- package/src/browser/main-layout.contribution.ts +447 -0
- package/src/browser/quick-open-view.ts +138 -0
- package/src/browser/tabbar/bar.view.tsx +289 -0
- package/src/browser/tabbar/panel.view.tsx +190 -0
- package/src/browser/tabbar/renderer.view.tsx +133 -0
- package/src/browser/tabbar/styles.module.less +408 -0
- package/src/browser/tabbar/tabbar.service.ts +845 -0
- package/src/browser/tabbar-handler.ts +200 -0
- package/src/browser/views-registry.ts +157 -0
- package/src/browser/welcome.view.tsx +152 -0
- package/src/common/index.ts +2 -0
- package/src/common/main-layout.definition.ts +122 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
import { Autowired } from '@opensumi/di';
|
|
2
|
+
import {
|
|
3
|
+
IContextKeyService,
|
|
4
|
+
ClientAppContribution,
|
|
5
|
+
SlotLocation,
|
|
6
|
+
SlotRendererContribution,
|
|
7
|
+
SlotRendererRegistry,
|
|
8
|
+
slotRendererRegistry,
|
|
9
|
+
KeybindingRegistry,
|
|
10
|
+
LAYOUT_COMMANDS,
|
|
11
|
+
IQuickOpenHandlerRegistry,
|
|
12
|
+
QuickOpenContribution,
|
|
13
|
+
QUICK_OPEN_COMMANDS,
|
|
14
|
+
EDITOR_COMMANDS,
|
|
15
|
+
} from '@opensumi/ide-core-browser';
|
|
16
|
+
import { getIcon } from '@opensumi/ide-core-browser';
|
|
17
|
+
import {
|
|
18
|
+
DEBUG_CONSOLE_CONTAINER_ID,
|
|
19
|
+
DEBUG_CONTAINER_ID,
|
|
20
|
+
EXPLORER_CONTAINER_ID,
|
|
21
|
+
EXTENSION_CONTAINER_ID,
|
|
22
|
+
MARKER_CONTAINER_ID,
|
|
23
|
+
OUTPUT_CONTAINER_ID,
|
|
24
|
+
SCM_CONTAINER_ID,
|
|
25
|
+
SEARCH_CONTAINER_ID,
|
|
26
|
+
TERMINAL_CONTAINER_ID,
|
|
27
|
+
} from '@opensumi/ide-core-browser/lib/common/container-id';
|
|
28
|
+
import {
|
|
29
|
+
ComponentContribution,
|
|
30
|
+
ComponentRegistry,
|
|
31
|
+
TabBarToolbarContribution,
|
|
32
|
+
ToolbarRegistry,
|
|
33
|
+
} from '@opensumi/ide-core-browser/lib/layout';
|
|
34
|
+
import { LayoutState } from '@opensumi/ide-core-browser/lib/layout/layout-state';
|
|
35
|
+
import {
|
|
36
|
+
IMenuRegistry,
|
|
37
|
+
MenuCommandDesc,
|
|
38
|
+
MenuContribution as MenuContribution,
|
|
39
|
+
MenuId,
|
|
40
|
+
} from '@opensumi/ide-core-browser/lib/menu/next';
|
|
41
|
+
import { Domain, IEventBus, ContributionProvider, localize, WithEventBus } from '@opensumi/ide-core-common';
|
|
42
|
+
import { CommandContribution, CommandRegistry, Command, CommandService } from '@opensumi/ide-core-common/lib/command';
|
|
43
|
+
|
|
44
|
+
import { IMainLayoutService } from '../common';
|
|
45
|
+
|
|
46
|
+
import { ViewQuickOpenHandler } from './quick-open-view';
|
|
47
|
+
import { RightTabRenderer, LeftTabRenderer, BottomTabRenderer } from './tabbar/renderer.view';
|
|
48
|
+
|
|
49
|
+
// NOTE 左右侧面板的展开、折叠命令请使用组合命令 activity-bar.left.toggle,layout命令仅做折叠展开,不处理tab激活逻辑
|
|
50
|
+
export const HIDE_LEFT_PANEL_COMMAND: Command = {
|
|
51
|
+
id: 'main-layout.left-panel.hide',
|
|
52
|
+
label: '%main-layout.left-panel.hide%',
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const WORKBENCH_ACTION_CLOSESIDECAR: Command = {
|
|
56
|
+
id: 'workbench.action.closeSidebar',
|
|
57
|
+
label: '%main-layout.sidebar.hide%',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export const SHOW_LEFT_PANEL_COMMAND: Command = {
|
|
61
|
+
id: 'main-layout.left-panel.show',
|
|
62
|
+
label: '%main-layout.left-panel.show%',
|
|
63
|
+
};
|
|
64
|
+
export const TOGGLE_LEFT_PANEL_COMMAND: MenuCommandDesc = {
|
|
65
|
+
id: 'main-layout.left-panel.toggle',
|
|
66
|
+
label: '%main-layout.left-panel.toggle%',
|
|
67
|
+
};
|
|
68
|
+
export const HIDE_RIGHT_PANEL_COMMAND: Command = {
|
|
69
|
+
id: 'main-layout.right-panel.hide',
|
|
70
|
+
label: '%main-layout.right-panel.hide%',
|
|
71
|
+
};
|
|
72
|
+
export const SHOW_RIGHT_PANEL_COMMAND: Command = {
|
|
73
|
+
id: 'main-layout.right-panel.show',
|
|
74
|
+
label: '%main-layout.right-panel.show%',
|
|
75
|
+
};
|
|
76
|
+
export const TOGGLE_RIGHT_PANEL_COMMAND: MenuCommandDesc = {
|
|
77
|
+
id: 'main-layout.right-panel.toggle',
|
|
78
|
+
label: '%main-layout.right-panel.toggle%',
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const HIDE_BOTTOM_PANEL_COMMAND: Command = {
|
|
82
|
+
id: 'main-layout.bottom-panel.hide',
|
|
83
|
+
label: '%main-layout.bottom-panel.hide%',
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const WORKBENCH_ACTION_CLOSEPANEL: Command = {
|
|
87
|
+
id: 'workbench.action.closePanel',
|
|
88
|
+
delegate: HIDE_BOTTOM_PANEL_COMMAND.id,
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const SHOW_BOTTOM_PANEL_COMMAND: Command = {
|
|
92
|
+
id: 'main-layout.bottom-panel.show',
|
|
93
|
+
label: '%main-layout.bottom-panel.show%',
|
|
94
|
+
};
|
|
95
|
+
export const TOGGLE_BOTTOM_PANEL_COMMAND: Command = {
|
|
96
|
+
id: 'main-layout.bottom-panel.toggle',
|
|
97
|
+
iconClass: getIcon('minus'),
|
|
98
|
+
label: '%layout.tabbar.toggle%',
|
|
99
|
+
};
|
|
100
|
+
export const IS_VISIBLE_BOTTOM_PANEL_COMMAND: Command = {
|
|
101
|
+
id: 'main-layout.bottom-panel.is-visible',
|
|
102
|
+
};
|
|
103
|
+
export const IS_VISIBLE_LEFT_PANEL_COMMAND: Command = {
|
|
104
|
+
id: 'main-layout.left-panel.is-visible',
|
|
105
|
+
};
|
|
106
|
+
export const IS_VISIBLE_RIGHT_PANEL_COMMAND: Command = {
|
|
107
|
+
id: 'main-layout.right-panel.is-visible',
|
|
108
|
+
};
|
|
109
|
+
export const SET_PANEL_SIZE_COMMAND: Command = {
|
|
110
|
+
id: 'main-layout.panel.size.set',
|
|
111
|
+
};
|
|
112
|
+
export const EXPAND_BOTTOM_PANEL: Command = {
|
|
113
|
+
id: 'main-layout.bottom-panel.expand',
|
|
114
|
+
label: '%layout.tabbar.expand%',
|
|
115
|
+
iconClass: getIcon('expand'),
|
|
116
|
+
};
|
|
117
|
+
export const RETRACT_BOTTOM_PANEL: Command = {
|
|
118
|
+
id: 'main-layout.bottom-panel.retract',
|
|
119
|
+
label: '%layout.tabbar.retract%',
|
|
120
|
+
iconClass: getIcon('shrink'),
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
@Domain(CommandContribution, ClientAppContribution, SlotRendererContribution, MenuContribution, QuickOpenContribution)
|
|
124
|
+
export class MainLayoutModuleContribution
|
|
125
|
+
extends WithEventBus
|
|
126
|
+
implements
|
|
127
|
+
CommandContribution,
|
|
128
|
+
ClientAppContribution,
|
|
129
|
+
SlotRendererContribution,
|
|
130
|
+
MenuContribution,
|
|
131
|
+
QuickOpenContribution
|
|
132
|
+
{
|
|
133
|
+
@Autowired(IMainLayoutService)
|
|
134
|
+
private mainLayoutService: IMainLayoutService;
|
|
135
|
+
|
|
136
|
+
@Autowired(IContextKeyService)
|
|
137
|
+
contextKeyService: IContextKeyService;
|
|
138
|
+
|
|
139
|
+
@Autowired(IEventBus)
|
|
140
|
+
eventBus: IEventBus;
|
|
141
|
+
|
|
142
|
+
@Autowired(ComponentContribution)
|
|
143
|
+
contributionProvider: ContributionProvider<ComponentContribution>;
|
|
144
|
+
|
|
145
|
+
@Autowired(SlotRendererContribution)
|
|
146
|
+
rendererContributionProvider: ContributionProvider<SlotRendererContribution>;
|
|
147
|
+
|
|
148
|
+
@Autowired(ComponentRegistry)
|
|
149
|
+
componentRegistry: ComponentRegistry;
|
|
150
|
+
|
|
151
|
+
@Autowired(CommandService)
|
|
152
|
+
private commandService!: CommandService;
|
|
153
|
+
|
|
154
|
+
@Autowired()
|
|
155
|
+
private layoutState: LayoutState;
|
|
156
|
+
|
|
157
|
+
@Autowired(TabBarToolbarContribution)
|
|
158
|
+
protected readonly toolBarContributionProvider: ContributionProvider<TabBarToolbarContribution>;
|
|
159
|
+
|
|
160
|
+
@Autowired()
|
|
161
|
+
private toolBarRegistry: ToolbarRegistry;
|
|
162
|
+
|
|
163
|
+
@Autowired(KeybindingRegistry)
|
|
164
|
+
protected keybindingRegistry: KeybindingRegistry;
|
|
165
|
+
|
|
166
|
+
@Autowired(ViewQuickOpenHandler)
|
|
167
|
+
private quickOpenViewHandler: ViewQuickOpenHandler;
|
|
168
|
+
|
|
169
|
+
async initialize() {
|
|
170
|
+
// 全局只要初始化一次
|
|
171
|
+
await this.layoutState.initStorage();
|
|
172
|
+
const componentContributions = this.contributionProvider.getContributions();
|
|
173
|
+
for (const contribution of componentContributions) {
|
|
174
|
+
if (contribution.registerComponent) {
|
|
175
|
+
contribution.registerComponent(this.componentRegistry);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const rendererContributions = this.rendererContributionProvider.getContributions();
|
|
179
|
+
for (const contribution of rendererContributions) {
|
|
180
|
+
if (contribution.registerRenderer) {
|
|
181
|
+
contribution.registerRenderer(slotRendererRegistry);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const contributions = this.toolBarContributionProvider.getContributions();
|
|
185
|
+
for (const contribution of contributions) {
|
|
186
|
+
if (contribution.registerToolbarItems) {
|
|
187
|
+
contribution.registerToolbarItems(this.toolBarRegistry);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async onStart() {
|
|
193
|
+
this.registerSideToggleKey();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
async onDidStart() {
|
|
197
|
+
this.mainLayoutService.didMount();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
registerRenderer(registry: SlotRendererRegistry) {
|
|
201
|
+
registry.registerSlotRenderer(SlotLocation.right, RightTabRenderer);
|
|
202
|
+
registry.registerSlotRenderer(SlotLocation.left, LeftTabRenderer);
|
|
203
|
+
registry.registerSlotRenderer(SlotLocation.bottom, BottomTabRenderer);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
registerCommands(commands: CommandRegistry): void {
|
|
207
|
+
// @deprecated
|
|
208
|
+
commands.registerCommand(HIDE_LEFT_PANEL_COMMAND, {
|
|
209
|
+
execute: () => {
|
|
210
|
+
this.mainLayoutService.toggleSlot(SlotLocation.left, false);
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
// @deprecated
|
|
214
|
+
commands.registerCommand(SHOW_LEFT_PANEL_COMMAND, {
|
|
215
|
+
execute: (size?: number) => {
|
|
216
|
+
this.mainLayoutService.toggleSlot(SlotLocation.left, true, size);
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
commands.registerCommand(TOGGLE_LEFT_PANEL_COMMAND, {
|
|
220
|
+
execute: (show?: boolean, size?: number) => {
|
|
221
|
+
this.mainLayoutService.toggleSlot(SlotLocation.left, show, size);
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// @deprecated
|
|
226
|
+
commands.registerCommand(HIDE_RIGHT_PANEL_COMMAND, {
|
|
227
|
+
execute: () => {
|
|
228
|
+
this.mainLayoutService.toggleSlot(SlotLocation.right, false);
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
// @deprecated
|
|
232
|
+
commands.registerCommand(SHOW_RIGHT_PANEL_COMMAND, {
|
|
233
|
+
execute: (size?: number) => {
|
|
234
|
+
this.mainLayoutService.toggleSlot(SlotLocation.right, true, size);
|
|
235
|
+
},
|
|
236
|
+
});
|
|
237
|
+
commands.registerCommand(TOGGLE_RIGHT_PANEL_COMMAND, {
|
|
238
|
+
execute: (show?: boolean, size?: number) => {
|
|
239
|
+
this.mainLayoutService.toggleSlot(SlotLocation.right, show, size);
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
commands.registerCommand(WORKBENCH_ACTION_CLOSESIDECAR, {
|
|
244
|
+
execute: () =>
|
|
245
|
+
Promise.all([
|
|
246
|
+
this.mainLayoutService.toggleSlot(SlotLocation.left, false),
|
|
247
|
+
this.mainLayoutService.toggleSlot(SlotLocation.right, false),
|
|
248
|
+
]),
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
commands.registerCommand(SHOW_BOTTOM_PANEL_COMMAND, {
|
|
252
|
+
execute: () => {
|
|
253
|
+
this.mainLayoutService.toggleSlot(SlotLocation.bottom, true);
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
commands.registerCommand(HIDE_BOTTOM_PANEL_COMMAND, {
|
|
258
|
+
execute: () => {
|
|
259
|
+
this.mainLayoutService.toggleSlot(SlotLocation.bottom, false);
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
commands.registerCommand(WORKBENCH_ACTION_CLOSEPANEL);
|
|
263
|
+
commands.registerCommand(IS_VISIBLE_BOTTOM_PANEL_COMMAND, {
|
|
264
|
+
execute: () => this.mainLayoutService.getTabbarService('bottom').currentContainerId !== '',
|
|
265
|
+
});
|
|
266
|
+
commands.registerCommand(IS_VISIBLE_LEFT_PANEL_COMMAND, {
|
|
267
|
+
execute: () => this.mainLayoutService.isVisible(SlotLocation.left),
|
|
268
|
+
});
|
|
269
|
+
commands.registerCommand(IS_VISIBLE_RIGHT_PANEL_COMMAND, {
|
|
270
|
+
execute: () => this.mainLayoutService.isVisible(SlotLocation.left),
|
|
271
|
+
});
|
|
272
|
+
commands.registerCommand(SET_PANEL_SIZE_COMMAND, {
|
|
273
|
+
execute: (size: number) => {
|
|
274
|
+
this.mainLayoutService.setFloatSize(size);
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
commands.registerCommand(
|
|
279
|
+
{
|
|
280
|
+
id: 'view.outward.right-panel.hide',
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
execute: () => {
|
|
284
|
+
this.commandService.executeCommand('main-layout.right-panel.toggle', false);
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
);
|
|
288
|
+
commands.registerCommand(
|
|
289
|
+
{
|
|
290
|
+
id: 'view.outward.right-panel.show',
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
execute: (size?: number) => {
|
|
294
|
+
this.commandService.executeCommand('main-layout.right-panel.toggle', true, size);
|
|
295
|
+
},
|
|
296
|
+
},
|
|
297
|
+
);
|
|
298
|
+
commands.registerCommand(
|
|
299
|
+
{
|
|
300
|
+
id: 'view.outward.left-panel.hide',
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
execute: () => {
|
|
304
|
+
this.commandService.executeCommand('main-layout.left-panel.toggle', false);
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
);
|
|
308
|
+
commands.registerCommand(
|
|
309
|
+
{
|
|
310
|
+
id: 'view.outward.left-panel.show',
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
execute: (size?: number) => {
|
|
314
|
+
this.commandService.executeCommand('main-layout.left-panel.toggle', true, size);
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
);
|
|
318
|
+
|
|
319
|
+
commands.registerCommand(
|
|
320
|
+
{
|
|
321
|
+
id: LAYOUT_COMMANDS.MAXIMIZE_EDITOR.id,
|
|
322
|
+
},
|
|
323
|
+
{
|
|
324
|
+
execute: () => {
|
|
325
|
+
this.commandService.executeCommand(TOGGLE_RIGHT_PANEL_COMMAND.id, false);
|
|
326
|
+
this.commandService.executeCommand(TOGGLE_LEFT_PANEL_COMMAND.id, false);
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
commands.registerCommand(LAYOUT_COMMANDS.OPEN_VIEW, {
|
|
332
|
+
execute: () => {
|
|
333
|
+
this.commandService.executeCommand(QUICK_OPEN_COMMANDS.OPEN_VIEW.id);
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
registerMenus(menus: IMenuRegistry) {
|
|
339
|
+
menus.registerMenuItem(MenuId.ActivityBarExtra, {
|
|
340
|
+
submenu: MenuId.SettingsIconMenu,
|
|
341
|
+
iconClass: getIcon('setting'),
|
|
342
|
+
label: localize('layout.tabbar.setting'),
|
|
343
|
+
order: 1,
|
|
344
|
+
group: 'navigation',
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
Object.entries({
|
|
348
|
+
[SlotLocation.left]: [
|
|
349
|
+
EXPLORER_CONTAINER_ID,
|
|
350
|
+
SEARCH_CONTAINER_ID,
|
|
351
|
+
SCM_CONTAINER_ID,
|
|
352
|
+
DEBUG_CONTAINER_ID,
|
|
353
|
+
EXTENSION_CONTAINER_ID,
|
|
354
|
+
],
|
|
355
|
+
[SlotLocation.bottom]: [
|
|
356
|
+
MARKER_CONTAINER_ID,
|
|
357
|
+
OUTPUT_CONTAINER_ID,
|
|
358
|
+
DEBUG_CONSOLE_CONTAINER_ID,
|
|
359
|
+
TERMINAL_CONTAINER_ID,
|
|
360
|
+
],
|
|
361
|
+
}).forEach(([slotLocation, containerIds], index) => {
|
|
362
|
+
/**
|
|
363
|
+
* 这里使用 getContainer 是因为可能我们要注册到 menu 上的 id 在集成方并没有挂载。
|
|
364
|
+
* 所以如果 getContainer 有值,说明集成方也使用了这个 container,我们就把它注册到 menu 上
|
|
365
|
+
*/
|
|
366
|
+
const tabbarService = this.mainLayoutService.getTabbarService(slotLocation);
|
|
367
|
+
|
|
368
|
+
tabbarService.viewReady.promise.then(() => {
|
|
369
|
+
containerIds.forEach((id) => {
|
|
370
|
+
const info = tabbarService.getContainer(id);
|
|
371
|
+
if (info) {
|
|
372
|
+
menus.registerMenuItem(MenuId.MenubarViewMenu, {
|
|
373
|
+
command: {
|
|
374
|
+
id: `container.toggle.${id}`,
|
|
375
|
+
label: info.options?.title ?? id,
|
|
376
|
+
},
|
|
377
|
+
// 因为当前菜单已有菜单项,这里从 3 开始
|
|
378
|
+
group: `${3 + index}_${slotLocation}`,
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
menus.registerMenuItem(MenuId.MenubarViewMenu, {
|
|
386
|
+
command: TOGGLE_LEFT_PANEL_COMMAND,
|
|
387
|
+
group: '5_panel',
|
|
388
|
+
});
|
|
389
|
+
menus.registerMenuItem(MenuId.MenubarViewMenu, {
|
|
390
|
+
command: TOGGLE_RIGHT_PANEL_COMMAND,
|
|
391
|
+
group: '5_panel',
|
|
392
|
+
});
|
|
393
|
+
menus.registerMenuItem(MenuId.MenubarViewMenu, {
|
|
394
|
+
command: TOGGLE_BOTTOM_PANEL_COMMAND as MenuCommandDesc,
|
|
395
|
+
group: '5_panel',
|
|
396
|
+
});
|
|
397
|
+
menus.registerMenuItem(MenuId.MenubarViewMenu, {
|
|
398
|
+
command: EXPAND_BOTTOM_PANEL as MenuCommandDesc,
|
|
399
|
+
group: '5_panel',
|
|
400
|
+
when: '!bottomFullExpanded',
|
|
401
|
+
});
|
|
402
|
+
menus.registerMenuItem(MenuId.MenubarViewMenu, {
|
|
403
|
+
command: RETRACT_BOTTOM_PANEL as MenuCommandDesc,
|
|
404
|
+
group: '5_panel',
|
|
405
|
+
when: 'bottomFullExpanded',
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
menus.registerMenuItem(MenuId.MenubarViewMenu, {
|
|
409
|
+
command: {
|
|
410
|
+
id: EDITOR_COMMANDS.TOGGLE_WORD_WRAP.id,
|
|
411
|
+
label: '%preference.editor.wordWrap%',
|
|
412
|
+
},
|
|
413
|
+
group: '6_capability',
|
|
414
|
+
toggledWhen: 'config.editor.wordWrap == on',
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
protected registerSideToggleKey() {
|
|
419
|
+
this.keybindingRegistry.registerKeybinding({
|
|
420
|
+
keybinding: 'ctrlcmd+b',
|
|
421
|
+
command: TOGGLE_LEFT_PANEL_COMMAND.id,
|
|
422
|
+
});
|
|
423
|
+
this.keybindingRegistry.registerKeybinding({
|
|
424
|
+
keybinding: 'ctrlcmd+j',
|
|
425
|
+
command: TOGGLE_BOTTOM_PANEL_COMMAND.id,
|
|
426
|
+
});
|
|
427
|
+
this.keybindingRegistry.registerKeybinding({
|
|
428
|
+
keybinding: 'ctrlcmd+shift+j',
|
|
429
|
+
command: EXPAND_BOTTOM_PANEL.id,
|
|
430
|
+
when: '!bottomFullExpanded',
|
|
431
|
+
});
|
|
432
|
+
this.keybindingRegistry.registerKeybinding({
|
|
433
|
+
keybinding: 'ctrlcmd+shift+j',
|
|
434
|
+
command: RETRACT_BOTTOM_PANEL.id,
|
|
435
|
+
when: 'bottomFullExpanded',
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
registerQuickOpenHandlers(handlers: IQuickOpenHandlerRegistry): void {
|
|
440
|
+
handlers.registerHandler(this.quickOpenViewHandler, {
|
|
441
|
+
title: localize('layout.action.openView'),
|
|
442
|
+
commandId: LAYOUT_COMMANDS.QUICK_OPEN_VIEW.id,
|
|
443
|
+
order: 5,
|
|
444
|
+
hideTab: true,
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Injectable, Autowired, INJECTOR_TOKEN, Injector } from '@opensumi/di';
|
|
2
|
+
import { localize, formatLocalize, QuickOpenHandler, View } from '@opensumi/ide-core-browser';
|
|
3
|
+
import {
|
|
4
|
+
QuickOpenItem,
|
|
5
|
+
PrefixQuickOpenService,
|
|
6
|
+
QuickOpenModel,
|
|
7
|
+
QuickOpenItemOptions,
|
|
8
|
+
Mode,
|
|
9
|
+
} from '@opensumi/ide-core-browser/lib/quick-open';
|
|
10
|
+
|
|
11
|
+
import { IMainLayoutService } from '../common';
|
|
12
|
+
|
|
13
|
+
@Injectable()
|
|
14
|
+
export class ViewQuickOpenHandler implements QuickOpenHandler {
|
|
15
|
+
readonly prefix: string = 'view ';
|
|
16
|
+
readonly description: string = localize('layout.action.openView');
|
|
17
|
+
protected items: QuickOpenItem[];
|
|
18
|
+
|
|
19
|
+
@Autowired(PrefixQuickOpenService)
|
|
20
|
+
protected readonly quickOpenService: PrefixQuickOpenService;
|
|
21
|
+
|
|
22
|
+
@Autowired(IMainLayoutService)
|
|
23
|
+
private readonly layoutService: IMainLayoutService;
|
|
24
|
+
|
|
25
|
+
@Autowired(INJECTOR_TOKEN)
|
|
26
|
+
private readonly injector: Injector;
|
|
27
|
+
|
|
28
|
+
getModel(): QuickOpenModel {
|
|
29
|
+
return {
|
|
30
|
+
onType: (lookFor: string, acceptor: (items: QuickOpenItem[]) => void) => acceptor(this.getViewQuickOpenItems()),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getViewQuickOpenItems() {
|
|
35
|
+
const maps = this.layoutService.getAllAccordionService();
|
|
36
|
+
const containerIds = Array.from(maps.keys());
|
|
37
|
+
let items: (ContainerQuickOpenItem | ViewQuickOpenItem)[] = [];
|
|
38
|
+
items = items.concat(
|
|
39
|
+
containerIds.map((id, index) =>
|
|
40
|
+
this.injector.get(ContainerQuickOpenItem, [
|
|
41
|
+
id,
|
|
42
|
+
{
|
|
43
|
+
groupLabel: index === 0 ? localize('layout.openView.containerTitle') : '',
|
|
44
|
+
showBorder: false,
|
|
45
|
+
},
|
|
46
|
+
]),
|
|
47
|
+
),
|
|
48
|
+
);
|
|
49
|
+
for (const id of containerIds) {
|
|
50
|
+
const views = maps.get(id)?.views;
|
|
51
|
+
if (!views) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
for (let i = 0, len = views.length; i < len; i++) {
|
|
55
|
+
items.push(
|
|
56
|
+
this.injector.get(ViewQuickOpenItem, [
|
|
57
|
+
id,
|
|
58
|
+
views[i],
|
|
59
|
+
{
|
|
60
|
+
groupLabel: i === 0 ? formatLocalize('layout.openView.viewTitle', String(id).toUpperCase()) : '',
|
|
61
|
+
showBorder: false,
|
|
62
|
+
},
|
|
63
|
+
]),
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return items;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getOptions() {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
onClose() {}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@Injectable({ multiple: true })
|
|
78
|
+
export class ContainerQuickOpenItem extends QuickOpenItem {
|
|
79
|
+
@Autowired(IMainLayoutService)
|
|
80
|
+
private layoutService: IMainLayoutService;
|
|
81
|
+
|
|
82
|
+
constructor(private readonly containerId, protected readonly options: QuickOpenItemOptions) {
|
|
83
|
+
super(options);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
getLabel() {
|
|
87
|
+
return String(this.containerId).toLocaleUpperCase();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
isHidden(): boolean {
|
|
91
|
+
return super.isHidden();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
run(mode: Mode): boolean {
|
|
95
|
+
if (mode !== Mode.OPEN) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
const handler = this.layoutService.getTabbarHandler(this.containerId);
|
|
99
|
+
handler?.activate();
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@Injectable({ multiple: true })
|
|
105
|
+
export class ViewQuickOpenItem extends QuickOpenItem {
|
|
106
|
+
@Autowired(IMainLayoutService)
|
|
107
|
+
private layoutService: IMainLayoutService;
|
|
108
|
+
|
|
109
|
+
constructor(
|
|
110
|
+
private readonly containerId: string,
|
|
111
|
+
private readonly view: View,
|
|
112
|
+
protected readonly options: QuickOpenItemOptions,
|
|
113
|
+
) {
|
|
114
|
+
super(options);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
getLabel() {
|
|
118
|
+
return this.view.name?.toUpperCase();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
isHidden(): boolean {
|
|
122
|
+
return super.isHidden();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
run(mode: Mode): boolean {
|
|
126
|
+
if (mode !== Mode.OPEN) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
const handler = this.layoutService.getTabbarHandler(this.containerId);
|
|
130
|
+
if (handler) {
|
|
131
|
+
handler.activate();
|
|
132
|
+
if (handler.isCollapsed(this.view.id)) {
|
|
133
|
+
handler?.setCollapsed(this.view.id, false);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return true;
|
|
137
|
+
}
|
|
138
|
+
}
|