UNPKG

2.27 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2022 Ericsson and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.ActionMenuNode = void 0;
19/**
20 * Node representing an action in the menu tree structure.
21 * It's based on {@link MenuAction} for which it tries to determine the
22 * best label, icon and sortString with the given data.
23 */
24class ActionMenuNode {
25 constructor(action, commands) {
26 this.action = action;
27 this.commands = commands;
28 if (action.alt) {
29 this.altNode = new ActionMenuNode({ commandId: action.alt }, commands);
30 }
31 }
32 get command() { return this.action.commandId; }
33 ;
34 get when() { return this.action.when; }
35 get id() { return this.action.commandId; }
36 get label() {
37 if (this.action.label) {
38 return this.action.label;
39 }
40 const cmd = this.commands.getCommand(this.action.commandId);
41 if (!cmd) {
42 console.debug(`No label for action menu node: No command "${this.action.commandId}" exists.`);
43 return '';
44 }
45 return cmd.label || cmd.id;
46 }
47 get icon() {
48 if (this.action.icon) {
49 return this.action.icon;
50 }
51 const command = this.commands.getCommand(this.action.commandId);
52 return command && command.iconClass;
53 }
54 get sortString() { return this.action.order || this.label; }
55}
56exports.ActionMenuNode = ActionMenuNode;
57//# sourceMappingURL=action-menu-node.js.map
\No newline at end of file