1 |
|
2 |
|
3 |
|
4 | import { IRankedMenu, RankedMenu } from '@jupyterlab/ui-components';
|
5 | import { find } from '@lumino/algorithm';
|
6 | import { SemanticCommand } from '@jupyterlab/apputils';
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export interface IFileMenu extends IRankedMenu {
|
12 | |
13 |
|
14 |
|
15 | quitEntry: boolean;
|
16 |
|
17 | |
18 |
|
19 |
|
20 | readonly newMenu: IRankedMenu;
|
21 |
|
22 | |
23 |
|
24 |
|
25 | readonly closeAndCleaners: SemanticCommand;
|
26 |
|
27 | |
28 |
|
29 |
|
30 | readonly consoleCreators: SemanticCommand;
|
31 | }
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | export class FileMenu extends RankedMenu implements IFileMenu {
|
37 | constructor(options: IRankedMenu.IOptions) {
|
38 | super(options);
|
39 | this.quitEntry = false;
|
40 |
|
41 | this.closeAndCleaners = new SemanticCommand();
|
42 | this.consoleCreators = new SemanticCommand();
|
43 | }
|
44 |
|
45 | |
46 |
|
47 |
|
48 | get newMenu(): RankedMenu {
|
49 | if (!this._newMenu) {
|
50 | this._newMenu =
|
51 | (find(this.items, menu => menu.submenu?.id === 'jp-mainmenu-file-new')
|
52 | ?.submenu as RankedMenu) ??
|
53 | new RankedMenu({
|
54 | commands: this.commands
|
55 | });
|
56 | }
|
57 | return this._newMenu;
|
58 | }
|
59 |
|
60 | |
61 |
|
62 |
|
63 | readonly closeAndCleaners: SemanticCommand;
|
64 |
|
65 | |
66 |
|
67 |
|
68 | readonly consoleCreators: SemanticCommand;
|
69 |
|
70 | |
71 |
|
72 |
|
73 | dispose(): void {
|
74 | this._newMenu?.dispose();
|
75 | super.dispose();
|
76 | }
|
77 |
|
78 | |
79 |
|
80 |
|
81 | public quitEntry: boolean;
|
82 |
|
83 | private _newMenu: RankedMenu;
|
84 | }
|