提交 07e9f2e6 编写于 作者: S Sandeep Somavarapu

#28634 Use ContextAwareMenuActionItem

上级 00a339eb
......@@ -237,3 +237,17 @@ export class MenuItemActionItem extends ActionItem {
super.dispose();
}
}
// Need to subclass MenuItemActionItem in order to respect
// the action context coming from any action bar, without breaking
// existing users
export class ContextAwareMenuItemActionItem extends MenuItemActionItem {
onClick(event: MouseEvent): void {
event.preventDefault();
event.stopPropagation();
this.actionRunner.run(this._commandAction, this._context)
.done(undefined, err => this._messageService.show(Severity.Error, err));
}
}
\ No newline at end of file
......@@ -17,7 +17,7 @@ import { IContextMenuService } from 'vs/platform/contextview/browser/contextView
import { ClickBehavior } from 'vs/base/parts/tree/browser/treeDefaults';
import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
import { IThemeService, LIGHT } from 'vs/platform/theme/common/themeService';
import { createActionItem, fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { fillInActions, ContextAwareMenuItemActionItem } from 'vs/platform/actions/browser/menuItemActionItem';
import { IProgressService } from 'vs/platform/progress/common/progress';
import { ITree, IDataSource, IRenderer, ContextMenuEvent } from 'vs/base/parts/tree/browser/tree';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
......@@ -112,7 +112,10 @@ export class TreeView extends TreeViewsViewletPanel {
}
getActionItem(action: IAction): IActionItem {
return createActionItem(action, this.keybindingService, this.messageService, this.contextMenuService);
if (!(action instanceof MenuItemAction)) {
return undefined;
}
return new ContextAwareMenuItemActionItem(action, this.keybindingService, this.messageService, this.contextMenuService);
}
private setInput(): TPromise<void> {
......
......@@ -33,13 +33,12 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IMessageService } from 'vs/platform/message/common/message';
import { MenuItemAction, IMenuService, MenuId } from 'vs/platform/actions/common/actions';
import { IAction, Action, IActionItem, ActionRunner } from 'vs/base/common/actions';
import { MenuItemActionItem, fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { fillInActions, ContextAwareMenuItemActionItem } from 'vs/platform/actions/browser/menuItemActionItem';
import { SCMMenus } from './scmMenus';
import { ActionBar, IActionItemProvider, Separator, ActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IThemeService, LIGHT } from 'vs/platform/theme/common/themeService';
import { isSCMResource } from './scmUtil';
import { attachBadgeStyler, attachInputBoxStyler } from 'vs/platform/theme/common/styler';
import Severity from 'vs/base/common/severity';
import { IExtensionService } from 'vs/platform/extensions/common/extensions';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IStorageService } from 'vs/platform/storage/common/storage';
......@@ -59,21 +58,6 @@ import { WorkbenchList } from 'vs/platform/list/browser/listService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ThrottledDelayer } from 'vs/base/common/async';
// TODO@Joao
// Need to subclass MenuItemActionItem in order to respect
// the action context coming from any action bar, without breaking
// existing users
class SCMMenuItemActionItem extends MenuItemActionItem {
onClick(event: MouseEvent): void {
event.preventDefault();
event.stopPropagation();
this.actionRunner.run(this._commandAction, this._context)
.done(undefined, err => this._messageService.show(Severity.Error, err));
}
}
export interface ISpliceEvent<T> {
index: number;
deleteCount: number;
......@@ -898,7 +882,7 @@ export class RepositoryPanel extends ViewletPanel {
return undefined;
}
return new SCMMenuItemActionItem(action, this.keybindingService, this.messageService, this.contextMenuService);
return new ContextAwareMenuItemActionItem(action, this.keybindingService, this.messageService, this.contextMenuService);
}
getActionsContext(): any {
......@@ -1169,7 +1153,7 @@ export class SCMViewlet extends PanelViewlet implements IViewModel {
return undefined;
}
return new SCMMenuItemActionItem(action, this.keybindingService, this.messageService, this.contextMenuService);
return new ContextAwareMenuItemActionItem(action, this.keybindingService, this.messageService, this.contextMenuService);
}
layout(dimension: Dimension): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册