1 | import { Disposable } from '../disposable';
|
2 | import { CommandRegistry, Command } from '../command';
|
3 | import { ContributionProvider } from '../contribution-provider';
|
4 | import { CompositeMenuNode } from './composite-menu-node';
|
5 | import { CompoundMenuNode, MenuAction, MenuNode, MenuPath, MutableCompoundMenuNode, SubMenuOptions } from './menu-types';
|
6 | export declare const MenuContribution: unique symbol;
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | export interface MenuContribution {
|
34 | |
35 |
|
36 |
|
37 |
|
38 | registerMenus(menus: MenuModelRegistry): void;
|
39 | }
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | export declare class MenuModelRegistry {
|
46 | protected readonly contributions: ContributionProvider<MenuContribution>;
|
47 | protected readonly commands: CommandRegistry;
|
48 | protected readonly root: CompositeMenuNode;
|
49 | protected readonly independentSubmenus: Map<string, MutableCompoundMenuNode>;
|
50 | constructor(contributions: ContributionProvider<MenuContribution>, commands: CommandRegistry);
|
51 | onStart(): void;
|
52 | /**
|
53 | * Adds the given menu action to the menu denoted by the given path.
|
54 | *
|
55 | * @returns a disposable which, when called, will remove the menu action again.
|
56 | */
|
57 | registerMenuAction(menuPath: MenuPath, item: MenuAction): Disposable;
|
58 | /**
|
59 | * Adds the given menu node to the menu denoted by the given path.
|
60 | *
|
61 | * @returns a disposable which, when called, will remove the menu node again.
|
62 | */
|
63 | registerMenuNode(menuPath: MenuPath | string, menuNode: MenuNode, group?: string): Disposable;
|
64 | getMenuNode(menuPath: MenuPath | string, group?: string): MutableCompoundMenuNode;
|
65 | /**
|
66 | * Register a new menu at the given path with the given label.
|
67 | * (If the menu already exists without a label, iconClass or order this method can be used to set them.)
|
68 | *
|
69 | * @param menuPath the path for which a new submenu shall be registered.
|
70 | * @param label the label to be used for the new submenu.
|
71 | * @param options optionally allows to set an icon class and specify the order of the new menu.
|
72 | *
|
73 | * @returns if the menu was successfully created a disposable will be returned which,
|
74 | * when called, will remove the menu again. If the menu already existed a no-op disposable
|
75 | * will be returned.
|
76 | *
|
77 | * Note that if the menu already existed and was registered with a different label an error
|
78 | * will be thrown.
|
79 | */
|
80 | registerSubmenu(menuPath: MenuPath, label: string, options?: SubMenuOptions): Disposable;
|
81 | registerIndependentSubmenu(id: string, label: string, options?: SubMenuOptions): Disposable;
|
82 | linkSubmenu(parentPath: MenuPath | string, childId: string | MenuPath, options?: SubMenuOptions, group?: string): Disposable;
|
83 | /**
|
84 | * Unregister all menu nodes with the same id as the given menu action.
|
85 | *
|
86 | * @param item the item whose id will be used.
|
87 | * @param menuPath if specified only nodes within the path will be unregistered.
|
88 | */
|
89 | unregisterMenuAction(item: MenuAction, menuPath?: MenuPath): void;
|
90 | /**
|
91 | * Unregister all menu nodes with the same id as the given command.
|
92 | *
|
93 | * @param command the command whose id will be used.
|
94 | * @param menuPath if specified only nodes within the path will be unregistered.
|
95 | */
|
96 | unregisterMenuAction(command: Command, menuPath?: MenuPath): void;
|
97 | /**
|
98 | * Unregister all menu nodes with the given id.
|
99 | *
|
100 | * @param id the id which shall be removed.
|
101 | * @param menuPath if specified only nodes within the path will be unregistered.
|
102 | */
|
103 | unregisterMenuAction(id: string, menuPath?: MenuPath): void;
|
104 | /**
|
105 | * Recurse all menus, removing any menus matching the `id`.
|
106 | *
|
107 | * @param id technical identifier of the `MenuNode`.
|
108 | */
|
109 | unregisterMenuNode(id: string): void;
|
110 | /**
|
111 | * Finds a submenu as a descendant of the `root` node.
|
112 | * See {@link MenuModelRegistry.findSubMenu findSubMenu}.
|
113 | */
|
114 | protected findGroup(menuPath: MenuPath, options?: SubMenuOptions): MutableCompoundMenuNode;
|
115 | |
116 |
|
117 |
|
118 |
|
119 | protected findSubMenu(current: MutableCompoundMenuNode, menuId: string, options?: SubMenuOptions): MutableCompoundMenuNode;
|
120 | |
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 | getMenu(menuPath?: MenuPath): MutableCompoundMenuNode;
|
129 | |
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 | removeSingleRootNode(fullMenuModel: MutableCompoundMenuNode, menuPath: MenuPath): CompoundMenuNode;
|
138 | protected allChildrenCompound(children: ReadonlyArray<MenuNode>): boolean;
|
139 | protected isEmpty(children: ReadonlyArray<MenuNode>): boolean;
|
140 | |
141 |
|
142 |
|
143 |
|
144 | getPath(node: MenuNode): MenuPath | undefined;
|
145 | }
|
146 |
|
\ | No newline at end of file |