1 | import { Disposable } from './disposable';
|
2 | import { CommandRegistry, Command } from './command';
|
3 | import { ContributionProvider } from './contribution-provider';
|
4 |
|
5 |
|
6 |
|
7 | export interface MenuAction {
|
8 | |
9 |
|
10 |
|
11 | commandId: string;
|
12 | |
13 |
|
14 |
|
15 |
|
16 | alt?: string;
|
17 | |
18 |
|
19 |
|
20 | label?: string;
|
21 | |
22 |
|
23 |
|
24 |
|
25 | icon?: string;
|
26 | |
27 |
|
28 |
|
29 |
|
30 | order?: string;
|
31 | |
32 |
|
33 |
|
34 |
|
35 | when?: string;
|
36 | }
|
37 | export declare namespace MenuAction {
|
38 | function is(arg: MenuAction | any): arg is MenuAction;
|
39 | }
|
40 |
|
41 |
|
42 |
|
43 | export interface SubMenuOptions {
|
44 | |
45 |
|
46 |
|
47 | iconClass?: string;
|
48 | |
49 |
|
50 |
|
51 |
|
52 | order?: string;
|
53 | }
|
54 | export declare type MenuPath = string[];
|
55 | export declare const MAIN_MENU_BAR: MenuPath;
|
56 | export declare const SETTINGS_MENU: MenuPath;
|
57 | export declare const ACCOUNTS_MENU: MenuPath;
|
58 | export declare const ACCOUNTS_SUBMENU: string[];
|
59 | export declare const MenuContribution: unique symbol;
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | export interface MenuContribution {
|
87 | |
88 |
|
89 |
|
90 |
|
91 | registerMenus(menus: MenuModelRegistry): void;
|
92 | }
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 | export declare class MenuModelRegistry {
|
99 | protected readonly contributions: ContributionProvider<MenuContribution>;
|
100 | protected readonly commands: CommandRegistry;
|
101 | protected readonly root: CompositeMenuNode;
|
102 | constructor(contributions: ContributionProvider<MenuContribution>, commands: CommandRegistry);
|
103 | onStart(): void;
|
104 | /**
|
105 | * Adds the given menu action to the menu denoted by the given path.
|
106 | *
|
107 | * @returns a disposable which, when called, will remove the menu action again.
|
108 | */
|
109 | registerMenuAction(menuPath: MenuPath, item: MenuAction): Disposable;
|
110 | /**
|
111 | * Adds the given menu node to the menu denoted by the given path.
|
112 | *
|
113 | * @returns a disposable which, when called, will remove the menu node again.
|
114 | */
|
115 | registerMenuNode(menuPath: MenuPath, menuNode: MenuNode): Disposable;
|
116 | /**
|
117 | * Register a new menu at the given path with the given label.
|
118 | * (If the menu already exists without a label, iconClass or order this method can be used to set them.)
|
119 | *
|
120 | * @param menuPath the path for which a new submenu shall be registered.
|
121 | * @param label the label to be used for the new submenu.
|
122 | * @param options optionally allows to set an icon class and specify the order of the new menu.
|
123 | *
|
124 | * @returns if the menu was successfully created a disposable will be returned which,
|
125 | * when called, will remove the menu again. If the menu already existed a no-op disposable
|
126 | * will be returned.
|
127 | *
|
128 | * Note that if the menu already existed and was registered with a different label an error
|
129 | * will be thrown.
|
130 | */
|
131 | registerSubmenu(menuPath: MenuPath, label: string, options?: SubMenuOptions): Disposable;
|
132 | /**
|
133 | * Unregister all menu nodes with the same id as the given menu action.
|
134 | *
|
135 | * @param item the item whose id will be used.
|
136 | * @param menuPath if specified only nodes within the path will be unregistered.
|
137 | */
|
138 | unregisterMenuAction(item: MenuAction, menuPath?: MenuPath): void;
|
139 | /**
|
140 | * Unregister all menu nodes with the same id as the given command.
|
141 | *
|
142 | * @param command the command whose id will be used.
|
143 | * @param menuPath if specified only nodes within the path will be unregistered.
|
144 | */
|
145 | unregisterMenuAction(command: Command, menuPath?: MenuPath): void;
|
146 | /**
|
147 | * Unregister all menu nodes with the given id.
|
148 | *
|
149 | * @param id the id which shall be removed.
|
150 | * @param menuPath if specified only nodes within the path will be unregistered.
|
151 | */
|
152 | unregisterMenuAction(id: string, menuPath?: MenuPath): void;
|
153 | /**
|
154 | * Recurse all menus, removing any menus matching the `id`.
|
155 | *
|
156 | * @param id technical identifier of the `MenuNode`.
|
157 | */
|
158 | unregisterMenuNode(id: string): void;
|
159 | protected findGroup(menuPath: MenuPath, options?: SubMenuOptions): CompositeMenuNode;
|
160 | protected findSubMenu(current: CompositeMenuNode, menuId: string, options?: SubMenuOptions): CompositeMenuNode;
|
161 | /**
|
162 | * Returns the menu at the given path.
|
163 | *
|
164 | * @param menuPath the path specifying the menu to return. If not given the empty path will be used.
|
165 | *
|
166 | * @returns the root menu when `menuPath` is empty. If `menuPath` is not empty the specified menu is
|
167 | * returned if it exists, otherwise an error is thrown.
|
168 | */
|
169 | getMenu(menuPath?: MenuPath): CompositeMenuNode;
|
170 | }
|
171 | /**
|
172 | * Base interface of the nodes used in the menu tree structure.
|
173 | */
|
174 | export interface MenuNode {
|
175 | |
176 |
|
177 |
|
178 | readonly label?: string;
|
179 | |
180 |
|
181 |
|
182 | readonly id: string;
|
183 | |
184 |
|
185 |
|
186 | readonly sortString: string;
|
187 | }
|
188 |
|
189 |
|
190 |
|
191 | export declare class CompositeMenuNode implements MenuNode {
|
192 | readonly id: string;
|
193 | label?: string | undefined;
|
194 | protected readonly _children: MenuNode[];
|
195 | iconClass?: string;
|
196 | order?: string;
|
197 | constructor(id: string, label?: string | undefined, options?: SubMenuOptions);
|
198 | get children(): ReadonlyArray<MenuNode>;
|
199 | /**
|
200 | * Inserts the given node at the position indicated by `sortString`.
|
201 | *
|
202 | * @returns a disposable which, when called, will remove the given node again.
|
203 | */
|
204 | addNode(node: MenuNode): Disposable;
|
205 | /**
|
206 | * Removes the first node with the given id.
|
207 | *
|
208 | * @param id node id.
|
209 | */
|
210 | removeNode(id: string): void;
|
211 | get sortString(): string;
|
212 | get isSubmenu(): boolean;
|
213 | /**
|
214 | * Indicates whether the given node is the special `navigation` menu.
|
215 | *
|
216 | * @param node the menu node to check.
|
217 | * @returns `true` when the given node is a {@link CompositeMenuNode} with id `navigation`,
|
218 | * `false` otherwise.
|
219 | */
|
220 | static isNavigationGroup(node: MenuNode): node is CompositeMenuNode;
|
221 | }
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 | export declare class ActionMenuNode implements MenuNode {
|
228 | readonly action: MenuAction;
|
229 | protected readonly commands: CommandRegistry;
|
230 | readonly altNode: ActionMenuNode | undefined;
|
231 | constructor(action: MenuAction, commands: CommandRegistry);
|
232 | get id(): string;
|
233 | get label(): string;
|
234 | get icon(): string | undefined;
|
235 | get sortString(): string;
|
236 | }
|
237 | //# sourceMappingURL=menu.d.ts.map |
\ | No newline at end of file |