提交 16e4888a 编写于 作者: J Johannes Rieken

add ICommandAction#precondition, #41103

上级 3698d323
......@@ -25,6 +25,7 @@ export interface ICommandAction {
category?: string | ILocalizedString;
iconClass?: string;
iconPath?: string;
precondition?: ContextKeyExpr;
}
export interface IMenuItem {
......@@ -175,15 +176,16 @@ export class MenuItemAction extends ExecuteCommandAction {
item: ICommandAction,
alt: ICommandAction,
options: IMenuActionOptions,
@IContextKeyService contextKeyService: IContextKeyService,
@ICommandService commandService: ICommandService
) {
typeof item.title === 'string' ? super(item.id, item.title, commandService) : super(item.id, item.title.value, commandService);
this._cssClass = item.iconClass;
this._enabled = true;
this._enabled = !item.precondition || contextKeyService.contextMatchesRules(item.precondition);
this._options = options || {};
this.item = item;
this.alt = alt ? new MenuItemAction(alt, undefined, this._options, commandService) : undefined;
this.alt = alt ? new MenuItemAction(alt, undefined, this._options, contextKeyService, commandService) : undefined;
}
run(...args: any[]): TPromise<any> {
......
......@@ -73,7 +73,7 @@ export class Menu implements IMenu {
const activeActions: MenuItemAction[] = [];
for (const item of items) {
if (this._contextKeyService.contextMatchesRules(item.when)) {
const action = new MenuItemAction(item.command, item.alt, options, this._commandService);
const action = new MenuItemAction(item.command, item.alt, options, this._contextKeyService, this._commandService);
action.order = item.order; //TODO@Ben order is menu item property, not an action property
activeActions.push(action);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册