1 | import { BoxLayout, BoxPanel, DockLayout, DockPanel, FocusTracker, Layout, Panel, SplitLayout, TabBar, Widget, Title } from '@phosphor/widgets';
|
2 | import { Message } from '@phosphor/messaging';
|
3 | import { IDragEvent } from '@phosphor/dragdrop';
|
4 | import { RecursivePartial, Event as CommonEvent, DisposableCollection } from '../../common';
|
5 | import { SaveOptions } from '../saveable';
|
6 | import { StatusBarImpl } from '../status-bar/status-bar';
|
7 | import { TheiaDockPanel } from './theia-dock-panel';
|
8 | import { SidePanelHandler, SidePanel } from './side-panel-handler';
|
9 | import { TabBarRendererFactory, ToolbarAwareTabBar } from './tab-bars';
|
10 | import { SplitPositionHandler } from './split-panels';
|
11 | import { FrontendApplicationStateService } from '../frontend-application-state';
|
12 | import { TabBarToolbarRegistry, TabBarToolbarFactory } from './tab-bar-toolbar';
|
13 | import { ContextKeyService } from '../context-key-service';
|
14 | import { Emitter } from '../../common/event';
|
15 | import { CorePreferences } from '../core-preferences';
|
16 | import { BreadcrumbsRendererFactory } from '../breadcrumbs/breadcrumbs-renderer';
|
17 | import { SaveResourceService } from '../save-resource-service';
|
18 | import { SecondaryWindowHandler } from '../secondary-window-handler';
|
19 | import URI from '../../common/uri';
|
20 | import { OpenerService } from '../opener-service';
|
21 | export declare type ApplicationShellLayoutVersion =
|
22 |
|
23 | 2.0 |
|
24 |
|
25 | 3.0 |
|
26 |
|
27 | 4.0 |
|
28 |
|
29 | 5.0 |
|
30 |
|
31 | 6.0;
|
32 |
|
33 |
|
34 |
|
35 | export declare const applicationShellLayoutVersion: ApplicationShellLayoutVersion;
|
36 | export declare const ApplicationShellOptions: unique symbol;
|
37 | export declare const DockPanelRendererFactory: unique symbol;
|
38 | export interface DockPanelRendererFactory {
|
39 | (): DockPanelRenderer;
|
40 | }
|
41 |
|
42 |
|
43 |
|
44 | export declare class DockPanelRenderer implements DockLayout.IRenderer {
|
45 | protected readonly tabBarRendererFactory: TabBarRendererFactory;
|
46 | protected readonly tabBarToolbarRegistry: TabBarToolbarRegistry;
|
47 | protected readonly tabBarToolbarFactory: TabBarToolbarFactory;
|
48 | protected readonly breadcrumbsRendererFactory: BreadcrumbsRendererFactory;
|
49 | protected readonly dockPanelFactory: TheiaDockPanel.Factory;
|
50 | readonly tabBarClasses: string[];
|
51 | private readonly onDidCreateTabBarEmitter;
|
52 | constructor(tabBarRendererFactory: TabBarRendererFactory, tabBarToolbarRegistry: TabBarToolbarRegistry, tabBarToolbarFactory: TabBarToolbarFactory, breadcrumbsRendererFactory: BreadcrumbsRendererFactory);
|
53 | get onDidCreateTabBar(): CommonEvent<TabBar<Widget>>;
|
54 | createTabBar(): TabBar<Widget>;
|
55 | createHandle(): HTMLDivElement;
|
56 | protected onCurrentTabChanged(sender: ToolbarAwareTabBar, { currentIndex }: TabBar.ICurrentChangedArgs<Widget>): void;
|
57 | }
|
58 | /**
|
59 | * The application shell manages the top-level widgets of the application. Use this class to
|
60 | * add, remove, or activate a widget.
|
61 | */
|
62 | export declare class ApplicationShell extends Widget {
|
63 | protected dockPanelRendererFactory: () => DockPanelRenderer;
|
64 | protected readonly statusBar: StatusBarImpl;
|
65 | protected readonly sidePanelHandlerFactory: () => SidePanelHandler;
|
66 | protected splitPositionHandler: SplitPositionHandler;
|
67 | protected readonly applicationStateService: FrontendApplicationStateService;
|
68 | protected readonly corePreferences: CorePreferences;
|
69 | protected readonly saveResourceService: SaveResourceService;
|
70 | protected readonly secondaryWindowHandler: SecondaryWindowHandler;
|
71 | |
72 |
|
73 |
|
74 | mainPanel: TheiaDockPanel;
|
75 | |
76 |
|
77 |
|
78 |
|
79 | bottomPanel: TheiaDockPanel;
|
80 | |
81 |
|
82 |
|
83 |
|
84 | leftPanelHandler: SidePanelHandler;
|
85 | |
86 |
|
87 |
|
88 |
|
89 | rightPanelHandler: SidePanelHandler;
|
90 | |
91 |
|
92 |
|
93 | protected options: ApplicationShell.Options;
|
94 | |
95 |
|
96 |
|
97 | topPanel: Panel;
|
98 | |
99 |
|
100 |
|
101 | protected readonly bottomPanelState: SidePanel.State;
|
102 | private readonly tracker;
|
103 | private dragState?;
|
104 | additionalDraggedUris: URI[] | undefined;
|
105 | protected readonly contextKeyService: ContextKeyService;
|
106 | protected readonly openerService: OpenerService;
|
107 | protected readonly onDidAddWidgetEmitter: Emitter<Widget>;
|
108 | readonly onDidAddWidget: CommonEvent<Widget>;
|
109 | protected fireDidAddWidget(widget: Widget): void;
|
110 | protected readonly onDidRemoveWidgetEmitter: Emitter<Widget>;
|
111 | readonly onDidRemoveWidget: CommonEvent<Widget>;
|
112 | protected fireDidRemoveWidget(widget: Widget): void;
|
113 | protected readonly onDidChangeActiveWidgetEmitter: Emitter<FocusTracker.IChangedArgs<Widget>>;
|
114 | readonly onDidChangeActiveWidget: CommonEvent<FocusTracker.IChangedArgs<Widget>>;
|
115 | protected readonly onDidChangeCurrentWidgetEmitter: Emitter<FocusTracker.IChangedArgs<Widget>>;
|
116 | readonly onDidChangeCurrentWidget: CommonEvent<FocusTracker.IChangedArgs<Widget>>;
|
117 | protected readonly dockPanelFactory: TheiaDockPanel.Factory;
|
118 | private _mainPanelRenderer;
|
119 | get mainPanelRenderer(): DockPanelRenderer;
|
120 | |
121 |
|
122 |
|
123 | constructor(dockPanelRendererFactory: () => DockPanelRenderer, statusBar: StatusBarImpl, sidePanelHandlerFactory: () => SidePanelHandler, splitPositionHandler: SplitPositionHandler, applicationStateService: FrontendApplicationStateService, options: RecursivePartial<ApplicationShell.Options> | undefined, corePreferences: CorePreferences, saveResourceService: SaveResourceService, secondaryWindowHandler: SecondaryWindowHandler);
|
124 | protected init(): void;
|
125 | protected initializeShell(): void;
|
126 | protected initSidebarVisibleKeyContext(): void;
|
127 | protected initFocusKeyContexts(): void;
|
128 | protected setTopPanelVisibility(preference: string): void;
|
129 | protected onBeforeAttach(msg: Message): void;
|
130 | protected onAfterDetach(msg: Message): void;
|
131 | handleEvent(event: Event): void;
|
132 | protected onDragEnter({ mimeData }: IDragEvent): void;
|
133 | protected onDragOver(event: IDragEvent): void;
|
134 | /**
|
135 | * This method is called after a side panel has been expanded while dragging a widget. It fires
|
136 | * a `mousemove` event so that the drag overlay markers are updated correctly in all dock panels.
|
137 | */
|
138 | private dispatchMouseMove;
|
139 | protected onDrop(event: IDragEvent): void;
|
140 | protected onDragLeave(event: IDragEvent): void;
|
141 | /**
|
142 | * Create the dock panel in the main shell area.
|
143 | */
|
144 | protected createMainPanel(): TheiaDockPanel;
|
145 | addAdditionalDraggedEditorUris(uris: URI[]): void;
|
146 | clearAdditionalDraggedEditorUris(): void;
|
147 | protected static getDraggedEditorUris(dataTransfer: DataTransfer): URI[];
|
148 | static setDraggedEditorUris(dataTransfer: DataTransfer, uris: URI[]): void;
|
149 | /**
|
150 | * Create the dock panel in the bottom shell area.
|
151 | */
|
152 | protected createBottomPanel(): TheiaDockPanel;
|
153 | /**
|
154 | * Create the top panel, which is used to hold the main menu.
|
155 | */
|
156 | protected createTopPanel(): Panel;
|
157 | /**
|
158 | * Create a box layout to assemble the application shell layout.
|
159 | */
|
160 | protected createBoxLayout(widgets: Widget[], stretch?: number[], options?: BoxPanel.IOptions): BoxLayout;
|
161 | /**
|
162 | * Create a split layout to assemble the application shell layout.
|
163 | */
|
164 | protected createSplitLayout(widgets: Widget[], stretch?: number[], options?: Partial<SplitLayout.IOptions>): SplitLayout;
|
165 | /**
|
166 | * Assemble the application shell layout. Override this method in order to change the arrangement
|
167 | * of the main area and the side panels.
|
168 | */
|
169 | protected createLayout(): Layout;
|
170 | /**
|
171 | * Create an object that describes the current shell layout. This object may contain references
|
172 | * to widgets; these need to be transformed before the layout can be serialized.
|
173 | */
|
174 | getLayoutData(): ApplicationShell.LayoutData;
|
175 | getPinnedMainWidgets(): boolean[];
|
176 | getPinnedBottomWidgets(): boolean[];
|
177 | /**
|
178 | * Compute the current height of the bottom panel. This implementation assumes that the container
|
179 | * of the bottom panel is a `SplitPanel`.
|
180 | */
|
181 | protected getBottomPanelSize(): number | undefined;
|
182 | /**
|
183 | * Determine the default size to apply when the bottom panel is expanded for the first time.
|
184 | */
|
185 | protected getDefaultBottomPanelSize(): number | undefined;
|
186 | /**
|
187 | * Apply a shell layout that has been previously created with `getLayoutData`.
|
188 | */
|
189 | setLayoutData(layoutData: ApplicationShell.LayoutData): Promise<void>;
|
190 | /**
|
191 | * Modify the height of the bottom panel. This implementation assumes that the container of the
|
192 | * bottom panel is a `SplitPanel`.
|
193 | */
|
194 | protected setBottomPanelSize(size: number): Promise<void>;
|
195 | /**
|
196 | * A promise that is resolved when all currently pending updates are done.
|
197 | */
|
198 | get pendingUpdates(): Promise<void>;
|
199 | /**
|
200 | * Track all widgets that are referenced by the given layout data.
|
201 | */
|
202 | protected registerWithFocusTracker(data: DockLayout.ITabAreaConfig | DockLayout.ISplitAreaConfig | SidePanel.LayoutData | null): void;
|
203 | /**
|
204 | * Add a widget to the application shell. The given widget must have a unique `id` property,
|
205 | * which will be used as the DOM id.
|
206 | *
|
207 | * Widgets are removed from the shell by calling their `close` or `dispose` methods.
|
208 | *
|
209 | * Widgets added to the top area are not tracked regarding the _current_ and _active_ states.
|
210 | */
|
211 | addWidget(widget: Widget, options?: Readonly<ApplicationShell.WidgetOptions>): Promise<void>;
|
212 | getInsertionOptions(options?: Readonly<ApplicationShell.WidgetOptions>): {
|
213 | area: string;
|
214 | addOptions: DockLayout.IAddOptions;
|
215 | };
|
216 | |
217 |
|
218 |
|
219 | getWidgets(area: ApplicationShell.Area): Widget[];
|
220 | |
221 |
|
222 |
|
223 |
|
224 |
|
225 | findWidgetForElement(element: HTMLElement): Widget | undefined;
|
226 | private findWidgetForNode;
|
227 | |
228 |
|
229 |
|
230 |
|
231 |
|
232 | findTitle(tabBar: TabBar<Widget>, event?: Event): Title<Widget> | undefined;
|
233 | |
234 |
|
235 |
|
236 |
|
237 | findTabBar(event?: Event): TabBar<Widget> | undefined;
|
238 | |
239 |
|
240 |
|
241 | findTargetedWidget(event?: Event): Widget | undefined;
|
242 | |
243 |
|
244 |
|
245 |
|
246 | get currentWidget(): Widget | undefined;
|
247 | |
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 | get activeWidget(): Widget | undefined;
|
256 | |
257 |
|
258 |
|
259 | getCurrentWidget(area: ApplicationShell.Area): Widget | undefined;
|
260 | |
261 |
|
262 |
|
263 | private onCurrentChanged;
|
264 | protected readonly toDisposeOnActiveChanged: DisposableCollection;
|
265 | |
266 |
|
267 |
|
268 | private onActiveChanged;
|
269 | |
270 |
|
271 |
|
272 | private setZIndex;
|
273 | |
274 |
|
275 |
|
276 | protected track(widget: Widget): void;
|
277 | |
278 |
|
279 |
|
280 |
|
281 |
|
282 | protected toTrackedStack(id: string): Widget[];
|
283 | |
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 | activateWidget(id: string): Promise<Widget | undefined>;
|
294 | waitForActivation(id: string): Promise<void>;
|
295 | |
296 |
|
297 |
|
298 | protected doActivateWidget(id: string): Widget | undefined;
|
299 | |
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 | private checkActivation;
|
307 | private readonly activationTimeout;
|
308 | private readonly toDisposeOnActivationCheck;
|
309 | private assertActivated;
|
310 | |
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 | revealWidget(id: string): Promise<Widget | undefined>;
|
317 | |
318 |
|
319 |
|
320 | protected doRevealWidget(id: string): Widget | undefined;
|
321 | |
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 | expandPanel(area: ApplicationShell.Area): void;
|
328 | |
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 | resize(size: number, area: ApplicationShell.Area): void;
|
335 | |
336 |
|
337 |
|
338 | protected expandBottomPanel(): void;
|
339 | |
340 |
|
341 |
|
342 |
|
343 | collapsePanel(area: ApplicationShell.Area): Promise<void>;
|
344 | |
345 |
|
346 |
|
347 |
|
348 | protected collapseBottomPanel(): Promise<void>;
|
349 | |
350 |
|
351 |
|
352 |
|
353 | protected refreshBottomPanelToggleButton(): void;
|
354 | |
355 |
|
356 |
|
357 | isExpanded(area: ApplicationShell.Area): boolean;
|
358 | |
359 |
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 | closeTabs(tabBarOrArea: TabBar<Widget> | ApplicationShell.Area, filter?: (title: Title<Widget>, index: number) => boolean): Promise<void>;
|
367 | saveTabs(tabBarOrArea: TabBar<Widget> | ApplicationShell.Area, filter?: (title: Title<Widget>, index: number) => boolean): void;
|
368 | |
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 | protected getWidgetTitles(tabBarOrArea: TabBar<Widget> | ApplicationShell.Area, filter?: (title: Title<Widget>, index: number) => boolean): Title<Widget>[];
|
376 | |
377 |
|
378 |
|
379 |
|
380 | closeMany(targets: Widget[], options?: ApplicationShell.CloseOptions): Promise<Widget[]>;
|
381 | |
382 |
|
383 |
|
384 |
|
385 |
|
386 | closeWidget(id: string, options?: ApplicationShell.CloseOptions): Promise<Widget | undefined>;
|
387 | |
388 |
|
389 |
|
390 | get currentTabArea(): ApplicationShell.Area | undefined;
|
391 | |
392 |
|
393 |
|
394 |
|
395 | getAreaFor(input: TabBar<Widget> | Widget): ApplicationShell.Area | undefined;
|
396 | protected getAreaPanelFor(input: Widget): DockPanel | undefined;
|
397 | |
398 |
|
399 |
|
400 | get currentTabBar(): TabBar<Widget> | undefined;
|
401 | |
402 |
|
403 |
|
404 | getTabBarFor(widgetOrArea: Widget | ApplicationShell.Area): TabBar<Widget> | undefined;
|
405 | |
406 |
|
407 |
|
408 |
|
409 | get mainAreaTabBars(): TabBar<Widget>[];
|
410 | |
411 |
|
412 |
|
413 |
|
414 | get bottomAreaTabBars(): TabBar<Widget>[];
|
415 | |
416 |
|
417 |
|
418 | get allTabBars(): TabBar<Widget>[];
|
419 | activateNextTabInTabBar(current?: TabBar<Widget> | undefined): boolean;
|
420 | nextTabIndexInTabBar(current?: TabBar<Widget> | undefined): number;
|
421 | activateNextTab(): boolean;
|
422 | activateNextTabBar(current?: TabBar<Widget> | undefined): boolean;
|
423 | |
424 |
|
425 |
|
426 | nextTabBar(current?: TabBar<Widget> | undefined): TabBar<Widget> | undefined;
|
427 | activatePreviousTabInTabBar(current?: TabBar<Widget> | undefined): boolean;
|
428 | previousTabIndexInTabBar(current?: TabBar<Widget> | undefined): number;
|
429 | activatePreviousTab(): boolean;
|
430 | activatePreviousTabBar(current?: TabBar<Widget> | undefined): boolean;
|
431 | |
432 |
|
433 |
|
434 | previousTabBar(current?: TabBar<Widget> | undefined): TabBar<Widget> | undefined;
|
435 | |
436 |
|
437 |
|
438 | canSave(): boolean;
|
439 | |
440 |
|
441 |
|
442 | save(options?: SaveOptions): Promise<void>;
|
443 | |
444 |
|
445 |
|
446 | canSaveAll(): boolean;
|
447 | |
448 |
|
449 |
|
450 | saveAll(options?: SaveOptions): Promise<void>;
|
451 | |
452 |
|
453 |
|
454 | get widgets(): ReadonlyArray<Widget>;
|
455 | getWidgetById(id: string): Widget | undefined;
|
456 | canToggleMaximized(widget?: Widget | undefined): boolean;
|
457 | toggleMaximized(widget?: Widget | undefined): void;
|
458 | }
|
459 |
|
460 |
|
461 |
|
462 | export declare namespace ApplicationShell {
|
463 | |
464 |
|
465 |
|
466 | type Area = 'main' | 'top' | 'left' | 'right' | 'bottom' | 'secondaryWindow';
|
467 | const areaLabels: Record<Area, string>;
|
468 | |
469 |
|
470 |
|
471 |
|
472 | function isSideArea(area?: string): area is 'left' | 'right' | 'bottom';
|
473 | function isValidArea(area?: unknown): area is ApplicationShell.Area;
|
474 | |
475 |
|
476 |
|
477 |
|
478 | interface Options extends Widget.IOptions {
|
479 | bottomPanel: BottomPanelOptions;
|
480 | leftPanel: SidePanel.Options;
|
481 | rightPanel: SidePanel.Options;
|
482 | }
|
483 | interface BottomPanelOptions extends SidePanel.Options {
|
484 | }
|
485 | |
486 |
|
487 |
|
488 | const DEFAULT_OPTIONS: Readonly<Options>;
|
489 | |
490 |
|
491 |
|
492 | type OpenToSideMode = 'open-to-left' | 'open-to-right';
|
493 | function isOpenToSideMode(mode: unknown): mode is OpenToSideMode;
|
494 | |
495 |
|
496 |
|
497 | interface WidgetOptions extends SidePanel.WidgetOptions {
|
498 | |
499 |
|
500 |
|
501 | area?: Area;
|
502 | |
503 |
|
504 |
|
505 |
|
506 |
|
507 | mode?: DockLayout.InsertMode | OpenToSideMode;
|
508 | |
509 |
|
510 |
|
511 |
|
512 |
|
513 | ref?: Widget;
|
514 | }
|
515 | interface CloseOptions {
|
516 | |
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 | save?: boolean | undefined;
|
523 | }
|
524 | |
525 |
|
526 |
|
527 | interface LayoutData {
|
528 | version?: string | ApplicationShellLayoutVersion;
|
529 | mainPanel?: DockPanel.ILayoutConfig;
|
530 | mainPanelPinned?: boolean[];
|
531 | bottomPanel?: BottomPanelLayoutData;
|
532 | leftPanel?: SidePanel.LayoutData;
|
533 | rightPanel?: SidePanel.LayoutData;
|
534 | activeWidgetId?: string;
|
535 | }
|
536 | |
537 |
|
538 |
|
539 | interface BottomPanelLayoutData {
|
540 | config?: DockPanel.ILayoutConfig;
|
541 | size?: number;
|
542 | expanded?: boolean;
|
543 | pinned?: boolean[];
|
544 | }
|
545 | |
546 |
|
547 |
|
548 | interface TrackableWidgetProvider {
|
549 | getTrackableWidgets(): Widget[];
|
550 | readonly onDidChangeTrackableWidgets?: CommonEvent<Widget[]>;
|
551 | |
552 |
|
553 |
|
554 |
|
555 | activateWidget?(id: string): Widget | undefined;
|
556 | |
557 |
|
558 |
|
559 |
|
560 | revealWidget?(id: string): Widget | undefined;
|
561 | }
|
562 | namespace TrackableWidgetProvider {
|
563 | function is(widget: unknown): widget is TrackableWidgetProvider;
|
564 | }
|
565 | }
|
566 |
|
\ | No newline at end of file |