提交 d90b2db9 编写于 作者: I isidor

fillInActionBarActions and fillInContextMenuActions for clarity

上级 172309ce
...@@ -79,13 +79,20 @@ class AlternativeKeyEmitter extends Emitter<boolean> { ...@@ -79,13 +79,20 @@ class AlternativeKeyEmitter extends Emitter<boolean> {
} }
} }
export function fillInActions(menu: IMenu, options: IMenuActionOptions, target: IAction[] | { primary: IAction[]; secondary: IAction[]; }, contextMenuService: IContextMenuService, isPrimaryGroup: (group: string) => boolean = group => group === 'navigation'): void { export function fillInContextMenuActions(menu: IMenu, options: IMenuActionOptions, target: IAction[] | { primary: IAction[]; secondary: IAction[]; }, contextMenuService: IContextMenuService, isPrimaryGroup?: (group: string) => boolean): void {
const groups = menu.getActions(options); const groups = menu.getActions(options);
if (groups.length === 0) { const getAlternativeActions = AlternativeKeyEmitter.getInstance(contextMenuService).isPressed;
return;
} fillInActions(groups, target, getAlternativeActions, isPrimaryGroup);
const getAlternativeActions = (!options || !options.ignoreAlternativeActions) && AlternativeKeyEmitter.getInstance(contextMenuService).isPressed; }
export function fillInActionBarActions(menu: IMenu, options: IMenuActionOptions, target: IAction[] | { primary: IAction[]; secondary: IAction[]; }, isPrimaryGroup?: (group: string) => boolean): void {
const groups = menu.getActions(options);
// Action bars handle alternative actions on their own so the alternative actions should be ignored
fillInActions(groups, target, false, isPrimaryGroup);
}
function fillInActions(groups: [string, MenuItemAction[]][], target: IAction[] | { primary: IAction[]; secondary: IAction[]; }, getAlternativeActions, isPrimaryGroup: (group: string) => boolean = group => group === 'navigation'): void {
for (let tuple of groups) { for (let tuple of groups) {
let [group, actions] = tuple; let [group, actions] = tuple;
if (getAlternativeActions) { if (getAlternativeActions) {
......
...@@ -68,8 +68,6 @@ export class MenuId { ...@@ -68,8 +68,6 @@ export class MenuId {
export interface IMenuActionOptions { export interface IMenuActionOptions {
arg?: any; arg?: any;
shouldForwardArgs?: boolean; shouldForwardArgs?: boolean;
// Some menu action clients (ActionBar) handle alternative actions on their own so the alternative actions should be ignored
ignoreAlternativeActions?: boolean;
} }
export interface IMenu extends IDisposable { export interface IMenu extends IDisposable {
......
...@@ -44,7 +44,7 @@ import { CLOSE_EDITOR_GROUP_COMMAND_ID } from 'vs/workbench/browser/parts/editor ...@@ -44,7 +44,7 @@ import { CLOSE_EDITOR_GROUP_COMMAND_ID } from 'vs/workbench/browser/parts/editor
import { NoTabsTitleControl } from 'vs/workbench/browser/parts/editor/noTabsTitleControl'; import { NoTabsTitleControl } from 'vs/workbench/browser/parts/editor/noTabsTitleControl';
import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions'; import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent'; import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem'; import { fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
export class EditorGroupView extends Themable implements IEditorGroupView { export class EditorGroupView extends Themable implements IEditorGroupView {
...@@ -268,7 +268,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { ...@@ -268,7 +268,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
// Fill in contributed actions // Fill in contributed actions
const actions: IAction[] = []; const actions: IAction[] = [];
fillInActions(menu, void 0, actions, this.contextMenuService); fillInContextMenuActions(menu, void 0, actions, this.contextMenuService);
// Show it // Show it
this.contextMenuService.showContextMenu({ this.contextMenuService.showContextMenu({
......
...@@ -24,7 +24,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; ...@@ -24,7 +24,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes'; import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { createActionItem, fillInActions } from 'vs/platform/actions/browser/menuItemActionItem'; import { createActionItem, fillInContextMenuActions, fillInActionBarActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IMenuService, MenuId, IMenu, ExecuteCommandAction } from 'vs/platform/actions/common/actions'; import { IMenuService, MenuId, IMenu, ExecuteCommandAction } from 'vs/platform/actions/common/actions';
import { ResourceContextKey } from 'vs/workbench/common/resources'; import { ResourceContextKey } from 'vs/workbench/common/resources';
import { IThemeService, registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService'; import { IThemeService, registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
...@@ -171,7 +171,7 @@ export abstract class TitleControl extends Themable { ...@@ -171,7 +171,7 @@ export abstract class TitleControl extends Themable {
this.updateEditorActionsToolbar(); this.updateEditorActionsToolbar();
})); }));
fillInActions(titleBarMenu, { arg: this.resourceContext.get(), shouldForwardArgs: true, ignoreAlternativeActions: true }, { primary, secondary }, this.contextMenuService); fillInActionBarActions(titleBarMenu, { arg: this.resourceContext.get(), shouldForwardArgs: true }, { primary, secondary });
} }
return { primary, secondary }; return { primary, secondary };
...@@ -267,7 +267,7 @@ export abstract class TitleControl extends Themable { ...@@ -267,7 +267,7 @@ export abstract class TitleControl extends Themable {
// Fill in contributed actions // Fill in contributed actions
const actions: IAction[] = []; const actions: IAction[] = [];
fillInActions(this.contextMenu, { shouldForwardArgs: true, arg: this.resourceContext.get() }, actions, this.contextMenuService); fillInContextMenuActions(this.contextMenu, { shouldForwardArgs: true, arg: this.resourceContext.get() }, actions, this.contextMenuService);
// Show it // Show it
this.contextMenuService.showContextMenu({ this.contextMenuService.showContextMenu({
......
...@@ -12,7 +12,7 @@ import { IAction, IActionItem } from 'vs/base/common/actions'; ...@@ -12,7 +12,7 @@ import { IAction, IActionItem } from 'vs/base/common/actions';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions'; import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
import { fillInActions, ContextAwareMenuItemActionItem } from 'vs/platform/actions/browser/menuItemActionItem'; import { ContextAwareMenuItemActionItem, fillInActionBarActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IViewsService, ITreeViewer } from 'vs/workbench/common/views'; import { IViewsService, ITreeViewer } from 'vs/workbench/common/views';
import { IViewletViewOptions, IViewOptions, ViewsViewletPanel } from 'vs/workbench/browser/parts/views/viewsViewlet'; import { IViewletViewOptions, IViewOptions, ViewsViewletPanel } from 'vs/workbench/browser/parts/views/viewsViewlet';
...@@ -103,7 +103,6 @@ export class Menus implements IDisposable { ...@@ -103,7 +103,6 @@ export class Menus implements IDisposable {
id: string, id: string,
@IContextKeyService private contextKeyService: IContextKeyService, @IContextKeyService private contextKeyService: IContextKeyService,
@IMenuService private menuService: IMenuService, @IMenuService private menuService: IMenuService,
@IContextMenuService private contextMenuService: IContextMenuService
) { ) {
if (this.titleDisposable) { if (this.titleDisposable) {
this.titleDisposable.dispose(); this.titleDisposable.dispose();
...@@ -117,7 +116,7 @@ export class Menus implements IDisposable { ...@@ -117,7 +116,7 @@ export class Menus implements IDisposable {
const updateActions = () => { const updateActions = () => {
this.titleActions = []; this.titleActions = [];
this.titleSecondaryActions = []; this.titleSecondaryActions = [];
fillInActions(titleMenu, { ignoreAlternativeActions: true }, { primary: this.titleActions, secondary: this.titleSecondaryActions }, this.contextMenuService); fillInActionBarActions(titleMenu, undefined, { primary: this.titleActions, secondary: this.titleSecondaryActions });
this._onDidChangeTitle.fire(); this._onDidChangeTitle.fire();
}; };
......
...@@ -26,7 +26,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur ...@@ -26,7 +26,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { IAction, ActionRunner } from 'vs/base/common/actions'; import { IAction, ActionRunner } from 'vs/base/common/actions';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions'; import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
import { fillInActions, ContextAwareMenuItemActionItem } from 'vs/platform/actions/browser/menuItemActionItem'; import { fillInContextMenuActions, ContextAwareMenuItemActionItem } from 'vs/platform/actions/browser/menuItemActionItem';
import { FileKind } from 'vs/platform/files/common/files'; import { FileKind } from 'vs/platform/files/common/files';
import { ICommandService } from 'vs/platform/commands/common/commands'; import { ICommandService } from 'vs/platform/commands/common/commands';
import { FileIconThemableWorkbenchTree } from 'vs/workbench/browser/parts/views/viewsViewlet'; import { FileIconThemableWorkbenchTree } from 'vs/workbench/browser/parts/views/viewsViewlet';
...@@ -642,7 +642,7 @@ class Menus extends Disposable implements IDisposable { ...@@ -642,7 +642,7 @@ class Menus extends Disposable implements IDisposable {
const primary: IAction[] = []; const primary: IAction[] = [];
const secondary: IAction[] = []; const secondary: IAction[] = [];
const result = { primary, secondary }; const result = { primary, secondary };
fillInActions(menu, { shouldForwardArgs: true }, result, this.contextMenuService, g => /^inline/.test(g)); fillInContextMenuActions(menu, { shouldForwardArgs: true }, result, this.contextMenuService, g => /^inline/.test(g));
menu.dispose(); menu.dispose();
contextKeyService.dispose(); contextKeyService.dispose();
......
...@@ -35,7 +35,7 @@ import { ipcRenderer as ipc, webFrame } from 'electron'; ...@@ -35,7 +35,7 @@ import { ipcRenderer as ipc, webFrame } from 'electron';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing'; import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
import { IMenuService, MenuId, IMenu, MenuItemAction, ICommandAction } from 'vs/platform/actions/common/actions'; import { IMenuService, MenuId, IMenu, MenuItemAction, ICommandAction } from 'vs/platform/actions/common/actions';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem'; import { fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { RunOnceScheduler } from 'vs/base/common/async'; import { RunOnceScheduler } from 'vs/base/common/async';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration'; import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
...@@ -349,7 +349,7 @@ export class ElectronWindow extends Themable { ...@@ -349,7 +349,7 @@ export class ElectronWindow extends Themable {
const actions: (MenuItemAction | Separator)[] = []; const actions: (MenuItemAction | Separator)[] = [];
// Fill actions into groups respecting order // Fill actions into groups respecting order
fillInActions(touchBarMenu, void 0, actions, this.contextMenuService); fillInContextMenuActions(touchBarMenu, void 0, actions, this.contextMenuService);
// Convert into command action multi array // Convert into command action multi array
const items: ICommandAction[][] = []; const items: ICommandAction[][] = [];
......
...@@ -16,7 +16,7 @@ import { once } from 'vs/base/common/functional'; ...@@ -16,7 +16,7 @@ import { once } from 'vs/base/common/functional';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions'; import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
import { IControllerOptions } from 'vs/base/parts/tree/browser/treeDefaults'; import { IControllerOptions } from 'vs/base/parts/tree/browser/treeDefaults';
import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem'; import { fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { KeyCode } from 'vs/base/common/keyCodes'; import { KeyCode } from 'vs/base/common/keyCodes';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { onUnexpectedError } from 'vs/base/common/errors'; import { onUnexpectedError } from 'vs/base/common/errors';
...@@ -221,7 +221,7 @@ export class BaseDebugController extends WorkbenchTreeController { ...@@ -221,7 +221,7 @@ export class BaseDebugController extends WorkbenchTreeController {
this.contextMenuService.showContextMenu({ this.contextMenuService.showContextMenu({
getAnchor: () => anchor, getAnchor: () => anchor,
getActions: () => this.actionProvider.getSecondaryActions(tree, element).then(actions => { getActions: () => this.actionProvider.getSecondaryActions(tree, element).then(actions => {
fillInActions(this.contributedContextMenu, { arg: this.getContext(element) }, actions, this.contextMenuService); fillInContextMenuActions(this.contributedContextMenu, { arg: this.getContext(element) }, actions, this.contextMenuService);
return actions; return actions;
}), }),
onHide: (wasCancelled?: boolean) => { onHide: (wasCancelled?: boolean) => {
......
...@@ -41,8 +41,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; ...@@ -41,8 +41,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { KeyCode } from 'vs/base/common/keyCodes'; import { KeyCode } from 'vs/base/common/keyCodes';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { IMenuService, IMenu, MenuId } from 'vs/platform/actions/common/actions'; import { IMenuService, IMenu, MenuId } from 'vs/platform/actions/common/actions';
import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { attachInputBoxStyler } from 'vs/platform/theme/common/styler'; import { attachInputBoxStyler } from 'vs/platform/theme/common/styler';
import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IThemeService } from 'vs/platform/theme/common/themeService';
import { IWindowService } from 'vs/platform/windows/common/windows'; import { IWindowService } from 'vs/platform/windows/common/windows';
...@@ -57,6 +55,8 @@ import { rtrim } from 'vs/base/common/strings'; ...@@ -57,6 +55,8 @@ import { rtrim } from 'vs/base/common/strings';
import { IDialogService, IConfirmationResult, IConfirmation, getConfirmMessage } from 'vs/platform/dialogs/common/dialogs'; import { IDialogService, IConfirmationResult, IConfirmation, getConfirmMessage } from 'vs/platform/dialogs/common/dialogs';
import { INotificationService } from 'vs/platform/notification/common/notification'; import { INotificationService } from 'vs/platform/notification/common/notification';
import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService'; import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
export class FileDataSource implements IDataSource { export class FileDataSource implements IDataSource {
constructor( constructor(
...@@ -525,7 +525,7 @@ export class FileController extends WorkbenchTreeController implements IDisposab ...@@ -525,7 +525,7 @@ export class FileController extends WorkbenchTreeController implements IDisposab
getAnchor: () => anchor, getAnchor: () => anchor,
getActions: () => { getActions: () => {
const actions: IAction[] = []; const actions: IAction[] = [];
fillInActions(this.contributedContextMenu, { arg: stat instanceof ExplorerItem ? stat.resource : {}, shouldForwardArgs: true }, actions, this.contextMenuService); fillInContextMenuActions(this.contributedContextMenu, { arg: stat instanceof ExplorerItem ? stat.resource : {}, shouldForwardArgs: true }, actions, this.contextMenuService);
return TPromise.as(actions); return TPromise.as(actions);
}, },
onHide: (wasCancelled?: boolean) => { onHide: (wasCancelled?: boolean) => {
......
...@@ -34,9 +34,9 @@ import { TPromise } from 'vs/base/common/winjs.base'; ...@@ -34,9 +34,9 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService'; import { IEditorService, SIDE_GROUP, ACTIVE_GROUP } from 'vs/workbench/services/editor/common/editorService';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem'; import { fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions'; import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
import { OpenEditorsGroupContext, DirtyEditorContext } from 'vs/workbench/parts/files/electron-browser/fileCommands'; import { DirtyEditorContext, OpenEditorsGroupContext } from 'vs/workbench/parts/files/electron-browser/fileCommands';
import { ResourceContextKey } from 'vs/workbench/common/resources'; import { ResourceContextKey } from 'vs/workbench/common/resources';
import { fillResourceDataTransfers, ResourcesDropHandler, LocalSelectionTransfer } from 'vs/workbench/browser/dnd'; import { fillResourceDataTransfers, ResourcesDropHandler, LocalSelectionTransfer } from 'vs/workbench/browser/dnd';
...@@ -373,7 +373,7 @@ export class OpenEditorsView extends ViewsViewletPanel { ...@@ -373,7 +373,7 @@ export class OpenEditorsView extends ViewsViewletPanel {
getAnchor: () => e.anchor, getAnchor: () => e.anchor,
getActions: () => { getActions: () => {
const actions: IAction[] = []; const actions: IAction[] = [];
fillInActions(this.contributedContextMenu, { shouldForwardArgs: true, arg: element instanceof OpenEditor ? element.editor.getResource() : {} }, actions, this.contextMenuService); fillInContextMenuActions(this.contributedContextMenu, { shouldForwardArgs: true, arg: element instanceof OpenEditor ? element.editor.getResource() : {} }, actions, this.contextMenuService);
return TPromise.as(actions); return TPromise.as(actions);
}, },
getActionsContext: () => element instanceof OpenEditor ? { groupId: element.groupId, editorIndex: element.editorIndex } : { groupId: element.id } getActionsContext: () => element instanceof OpenEditor ? { groupId: element.groupId, editorIndex: element.editorIndex } : { groupId: element.id }
......
...@@ -42,7 +42,7 @@ import { IActionBarOptions, ActionsOrientation, IActionItem } from 'vs/base/brow ...@@ -42,7 +42,7 @@ import { IActionBarOptions, ActionsOrientation, IActionItem } from 'vs/base/brow
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { basename } from 'vs/base/common/paths'; import { basename } from 'vs/base/common/paths';
import { MenuId, IMenuService, IMenu, MenuItemAction } from 'vs/platform/actions/common/actions'; import { MenuId, IMenuService, IMenu, MenuItemAction } from 'vs/platform/actions/common/actions';
import { fillInActions, MenuItemActionItem } from 'vs/platform/actions/browser/menuItemActionItem'; import { MenuItemActionItem, fillInActionBarActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IChange, IEditorModel, ScrollType, IEditorContribution } from 'vs/editor/common/editorCommon'; import { IChange, IEditorModel, ScrollType, IEditorContribution } from 'vs/editor/common/editorCommon';
import { OverviewRulerLane, ITextModel, IModelDecorationOptions } from 'vs/editor/common/model'; import { OverviewRulerLane, ITextModel, IModelDecorationOptions } from 'vs/editor/common/model';
import { sortedDiff, firstIndex } from 'vs/base/common/arrays'; import { sortedDiff, firstIndex } from 'vs/base/common/arrays';
...@@ -272,7 +272,7 @@ class DirtyDiffWidget extends PeekViewWidget { ...@@ -272,7 +272,7 @@ class DirtyDiffWidget extends PeekViewWidget {
this._actionbarWidget.push([previous, next], { label: false, icon: true }); this._actionbarWidget.push([previous, next], { label: false, icon: true });
const actions: IAction[] = []; const actions: IAction[] = [];
fillInActions(this.menu, { shouldForwardArgs: true, ignoreAlternativeActions: true }, actions, this.contextMenuService); fillInActionBarActions(this.menu, { shouldForwardArgs: true }, actions);
this._actionbarWidget.push(actions, { label: false, icon: true }); this._actionbarWidget.push(actions, { label: false, icon: true });
} }
......
...@@ -11,7 +11,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; ...@@ -11,7 +11,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions'; import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
import { IAction } from 'vs/base/common/actions'; import { IAction } from 'vs/base/common/actions';
import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem'; import { fillInContextMenuActions, fillInActionBarActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { ISCMProvider, ISCMResource, ISCMResourceGroup } from 'vs/workbench/services/scm/common/scm'; import { ISCMProvider, ISCMResource, ISCMResourceGroup } from 'vs/workbench/services/scm/common/scm';
import { getSCMResourceContextKey } from './scmUtil'; import { getSCMResourceContextKey } from './scmUtil';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
...@@ -54,7 +54,7 @@ export class SCMMenus implements IDisposable { ...@@ -54,7 +54,7 @@ export class SCMMenus implements IDisposable {
this.titleActions = []; this.titleActions = [];
this.titleSecondaryActions = []; this.titleSecondaryActions = [];
// TODO@joao: second arg used to be null // TODO@joao: second arg used to be null
fillInActions(this.titleMenu, { shouldForwardArgs: true, ignoreAlternativeActions: true }, { primary: this.titleActions, secondary: this.titleSecondaryActions }, this.contextMenuService); fillInActionBarActions(this.titleMenu, { shouldForwardArgs: true }, { primary: this.titleActions, secondary: this.titleSecondaryActions });
this._onDidChangeTitle.fire(); this._onDidChangeTitle.fire();
} }
...@@ -90,7 +90,7 @@ export class SCMMenus implements IDisposable { ...@@ -90,7 +90,7 @@ export class SCMMenus implements IDisposable {
const primary: IAction[] = []; const primary: IAction[] = [];
const secondary: IAction[] = []; const secondary: IAction[] = [];
const result = { primary, secondary }; const result = { primary, secondary };
fillInActions(menu, { shouldForwardArgs: true }, result, this.contextMenuService, g => /^inline/.test(g)); fillInContextMenuActions(menu, { shouldForwardArgs: true }, result, this.contextMenuService, g => /^inline/.test(g));
menu.dispose(); menu.dispose();
contextKeyService.dispose(); contextKeyService.dispose();
......
...@@ -30,7 +30,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands'; ...@@ -30,7 +30,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { MenuItemAction, IMenuService, MenuId } from 'vs/platform/actions/common/actions'; import { MenuItemAction, IMenuService, MenuId } from 'vs/platform/actions/common/actions';
import { IAction, Action, IActionItem, ActionRunner } from 'vs/base/common/actions'; import { IAction, Action, IActionItem, ActionRunner } from 'vs/base/common/actions';
import { fillInActions, ContextAwareMenuItemActionItem } from 'vs/platform/actions/browser/menuItemActionItem'; import { fillInContextMenuActions, ContextAwareMenuItemActionItem, fillInActionBarActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { SCMMenus } from './scmMenus'; import { SCMMenus } from './scmMenus';
import { ActionBar, IActionItemProvider, Separator, ActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { ActionBar, IActionItemProvider, Separator, ActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IThemeService, LIGHT } from 'vs/platform/theme/common/themeService'; import { IThemeService, LIGHT } from 'vs/platform/theme/common/themeService';
...@@ -311,7 +311,7 @@ class MainPanel extends ViewletPanel { ...@@ -311,7 +311,7 @@ class MainPanel extends ViewletPanel {
const secondary: IAction[] = []; const secondary: IAction[] = [];
const result = { primary, secondary }; const result = { primary, secondary };
fillInActions(menu, { shouldForwardArgs: true }, result, this.contextMenuService, g => g === 'inline'); fillInContextMenuActions(menu, { shouldForwardArgs: true }, result, this.contextMenuService, g => g === 'inline');
menu.dispose(); menu.dispose();
contextKeyService.dispose(); contextKeyService.dispose();
...@@ -381,7 +381,6 @@ class ResourceGroupRenderer implements IRenderer<ISCMResourceGroup, ResourceGrou ...@@ -381,7 +381,6 @@ class ResourceGroupRenderer implements IRenderer<ISCMResourceGroup, ResourceGrou
private actionItemProvider: IActionItemProvider, private actionItemProvider: IActionItemProvider,
private themeService: IThemeService, private themeService: IThemeService,
private contextKeyService: IContextKeyService, private contextKeyService: IContextKeyService,
private contextMenuService: IContextMenuService,
private menuService: IMenuService private menuService: IMenuService
) { } ) { }
...@@ -425,7 +424,7 @@ class ResourceGroupRenderer implements IRenderer<ISCMResourceGroup, ResourceGrou ...@@ -425,7 +424,7 @@ class ResourceGroupRenderer implements IRenderer<ISCMResourceGroup, ResourceGrou
const primary: IAction[] = []; const primary: IAction[] = [];
const secondary: IAction[] = []; const secondary: IAction[] = [];
const result = { primary, secondary }; const result = { primary, secondary };
fillInActions(menu, { shouldForwardArgs: true, ignoreAlternativeActions: true }, result, this.contextMenuService, g => /^inline/.test(g)); fillInActionBarActions(menu, { shouldForwardArgs: true }, result, g => /^inline/.test(g));
template.actionBar.clear(); template.actionBar.clear();
template.actionBar.push(primary, { icon: true, label: false }); template.actionBar.push(primary, { icon: true, label: false });
...@@ -489,7 +488,6 @@ class ResourceRenderer implements IRenderer<ISCMResource, ResourceTemplate> { ...@@ -489,7 +488,6 @@ class ResourceRenderer implements IRenderer<ISCMResource, ResourceTemplate> {
private themeService: IThemeService, private themeService: IThemeService,
private instantiationService: IInstantiationService, private instantiationService: IInstantiationService,
private contextKeyService: IContextKeyService, private contextKeyService: IContextKeyService,
private contextMenuService: IContextMenuService,
private menuService: IMenuService private menuService: IMenuService
) { } ) { }
...@@ -537,7 +535,7 @@ class ResourceRenderer implements IRenderer<ISCMResource, ResourceTemplate> { ...@@ -537,7 +535,7 @@ class ResourceRenderer implements IRenderer<ISCMResource, ResourceTemplate> {
const primary: IAction[] = []; const primary: IAction[] = [];
const secondary: IAction[] = []; const secondary: IAction[] = [];
const result = { primary, secondary }; const result = { primary, secondary };
fillInActions(menu, { shouldForwardArgs: true, ignoreAlternativeActions: true }, result, this.contextMenuService, g => /^inline/.test(g)); fillInActionBarActions(menu, { shouldForwardArgs: true }, result, g => /^inline/.test(g));
template.actionBar.clear(); template.actionBar.clear();
template.actionBar.push(primary, { icon: true, label: false }); template.actionBar.push(primary, { icon: true, label: false });
...@@ -872,8 +870,8 @@ export class RepositoryPanel extends ViewletPanel { ...@@ -872,8 +870,8 @@ export class RepositoryPanel extends ViewletPanel {
const actionItemProvider = (action: IAction) => this.getActionItem(action); const actionItemProvider = (action: IAction) => this.getActionItem(action);
const renderers = [ const renderers = [
new ResourceGroupRenderer(actionItemProvider, this.themeService, this.contextKeyService, this.contextMenuService, this.menuService), new ResourceGroupRenderer(actionItemProvider, this.themeService, this.contextKeyService, this.menuService),
new ResourceRenderer(actionItemProvider, () => this.getSelectedResources(), this.themeService, this.instantiationService, this.contextKeyService, this.contextMenuService, this.menuService) new ResourceRenderer(actionItemProvider, () => this.getSelectedResources(), this.themeService, this.instantiationService, this.contextKeyService, this.menuService)
]; ];
this.list = this.instantiationService.createInstance(WorkbenchList, this.listContainer, delegate, renderers, { this.list = this.instantiationService.createInstance(WorkbenchList, this.listContainer, delegate, renderers, {
......
...@@ -26,7 +26,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur ...@@ -26,7 +26,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions'; import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
import { WorkbenchTreeController, WorkbenchTree } from 'vs/platform/list/browser/listService'; import { WorkbenchTreeController, WorkbenchTree } from 'vs/platform/list/browser/listService';
import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem'; import { fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
export class SearchDataSource implements IDataSource { export class SearchDataSource implements IDataSource {
...@@ -372,7 +372,7 @@ export class SearchTreeController extends WorkbenchTreeController { ...@@ -372,7 +372,7 @@ export class SearchTreeController extends WorkbenchTreeController {
getActions: () => { getActions: () => {
const actions: IAction[] = []; const actions: IAction[] = [];
fillInActions(this.contextMenu, { shouldForwardArgs: true }, actions, this.contextMenuService); fillInContextMenuActions(this.contextMenu, { shouldForwardArgs: true }, actions, this.contextMenuService);
return TPromise.as(actions); return TPromise.as(actions);
}, },
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册