提交 005ff605 编写于 作者: I isidor

open editors: introduce contributable menu id

上级 58b51562
...@@ -43,6 +43,7 @@ export class MenuId { ...@@ -43,6 +43,7 @@ export class MenuId {
static readonly EditorTitleContext = new MenuId(); static readonly EditorTitleContext = new MenuId();
static readonly EditorContext = new MenuId(); static readonly EditorContext = new MenuId();
static readonly ExplorerContext = new MenuId(); static readonly ExplorerContext = new MenuId();
static readonly OpenEditorsContext = new MenuId();
static readonly ProblemsPanelContext = new MenuId(); static readonly ProblemsPanelContext = new MenuId();
static readonly DebugVariablesContext = new MenuId(); static readonly DebugVariablesContext = new MenuId();
static readonly DebugWatchContext = new MenuId(); static readonly DebugWatchContext = new MenuId();
......
...@@ -1209,7 +1209,7 @@ export class CompareResourcesAction extends Action { ...@@ -1209,7 +1209,7 @@ export class CompareResourcesAction extends Action {
constructor( constructor(
resource: URI, resource: URI,
@IWorkbenchEditorService private commandService: ICommandService, @ICommandService private commandService: ICommandService,
@IWorkspaceContextService contextService: IWorkspaceContextService, @IWorkspaceContextService contextService: IWorkspaceContextService,
@IEnvironmentService environmentService: IEnvironmentService @IEnvironmentService environmentService: IEnvironmentService
) { ) {
......
...@@ -40,6 +40,8 @@ import { KeyCode } from 'vs/base/common/keyCodes'; ...@@ -40,6 +40,8 @@ import { KeyCode } from 'vs/base/common/keyCodes';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ContributableActionProvider } from 'vs/workbench/browser/actions'; import { ContributableActionProvider } from 'vs/workbench/browser/actions';
import { memoize } from 'vs/base/common/decorators'; import { memoize } from 'vs/base/common/decorators';
import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
const $ = dom.$; const $ = dom.$;
...@@ -55,6 +57,7 @@ export class OpenEditorsView extends ViewsViewletPanel { ...@@ -55,6 +57,7 @@ export class OpenEditorsView extends ViewsViewletPanel {
private listRefreshScheduler: RunOnceScheduler; private listRefreshScheduler: RunOnceScheduler;
private structuralRefreshDelay: number; private structuralRefreshDelay: number;
private list: WorkbenchList<OpenEditor | IEditorGroup>; private list: WorkbenchList<OpenEditor | IEditorGroup>;
private contributedContextMenu: IMenu;
private needsRefresh: boolean; private needsRefresh: boolean;
constructor( constructor(
...@@ -70,7 +73,8 @@ export class OpenEditorsView extends ViewsViewletPanel { ...@@ -70,7 +73,8 @@ export class OpenEditorsView extends ViewsViewletPanel {
@IUntitledEditorService private untitledEditorService: IUntitledEditorService, @IUntitledEditorService private untitledEditorService: IUntitledEditorService,
@IContextKeyService private contextKeyService: IContextKeyService, @IContextKeyService private contextKeyService: IContextKeyService,
@IThemeService private themeService: IThemeService, @IThemeService private themeService: IThemeService,
@ITelemetryService private telemetryService: ITelemetryService @ITelemetryService private telemetryService: ITelemetryService,
@IMenuService menuService: IMenuService
) { ) {
super({ super({
...(options as IViewOptions), ...(options as IViewOptions),
...@@ -89,6 +93,7 @@ export class OpenEditorsView extends ViewsViewletPanel { ...@@ -89,6 +93,7 @@ export class OpenEditorsView extends ViewsViewletPanel {
} }
this.needsRefresh = false; this.needsRefresh = false;
}, this.structuralRefreshDelay); }, this.structuralRefreshDelay);
this.contributedContextMenu = menuService.createMenu(MenuId.OpenEditorsContext, contextKeyService);
// update on model changes // update on model changes
this.disposables.push(this.model.onModelChanged(e => this.onEditorStacksModelChanged(e))); this.disposables.push(this.model.onModelChanged(e => this.onEditorStacksModelChanged(e)));
...@@ -266,10 +271,14 @@ export class OpenEditorsView extends ViewsViewletPanel { ...@@ -266,10 +271,14 @@ export class OpenEditorsView extends ViewsViewletPanel {
private onListContextMenu(e: IListContextMenuEvent<OpenEditor | IEditorGroup>): void { private onListContextMenu(e: IListContextMenuEvent<OpenEditor | IEditorGroup>): void {
const element = e.element; const element = e.element;
const getActionsContext = () => element instanceof OpenEditor ? { group: element.editorGroup, editor: element.editorInput, resource: element.editorInput.getResource() } : { group: element };
this.contextMenuService.showContextMenu({ this.contextMenuService.showContextMenu({
getAnchor: () => e.anchor, getAnchor: () => e.anchor,
getActions: () => this.actionProvider.getSecondaryActions(element), getActions: () => this.actionProvider.getSecondaryActions(element).then(actions => {
getActionsContext: () => element instanceof OpenEditor ? { group: element.editorGroup, editor: element.editorInput } : { group: element } fillInActions(this.contributedContextMenu, { arg: getActionsContext() }, actions);
return actions;
}),
getActionsContext
}); });
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册