mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
@@ -25,7 +25,7 @@ export class ContextSubMenu extends SubmenuAction {
|
||||
export interface IContextMenuDelegate {
|
||||
getAnchor(): HTMLElement | { x: number; y: number; width?: number; height?: number; };
|
||||
getActions(): Array<IAction | ContextSubMenu>;
|
||||
getActionItem?(action: IAction): IActionItem | null;
|
||||
getActionItem?(action: IAction): IActionItem | undefined;
|
||||
getActionsContext?(event?: IContextMenuEvent): any;
|
||||
getKeyBinding?(action: IAction): ResolvedKeybinding | undefined;
|
||||
getMenuClassName?(): string;
|
||||
|
||||
@@ -364,7 +364,7 @@ export interface ActionTrigger {
|
||||
}
|
||||
|
||||
export interface IActionItemProvider {
|
||||
(action: IAction): IActionItem | null;
|
||||
(action: IAction): IActionItem | undefined;
|
||||
}
|
||||
|
||||
export interface IActionBarOptions {
|
||||
@@ -609,7 +609,7 @@ export class ActionBar extends Disposable implements IActionRunner {
|
||||
e.stopPropagation();
|
||||
}));
|
||||
|
||||
let item: IActionItem | null = null;
|
||||
let item: IActionItem | undefined;
|
||||
|
||||
if (this.options.actionItemProvider) {
|
||||
item = this.options.actionItemProvider(action);
|
||||
|
||||
@@ -247,7 +247,7 @@ export class DropdownMenu extends BaseDropdown {
|
||||
getAnchor: () => this.element,
|
||||
getActions: () => this.actions,
|
||||
getActionsContext: () => this.menuOptions ? this.menuOptions.context : null,
|
||||
getActionItem: action => this.menuOptions && this.menuOptions.actionItemProvider ? this.menuOptions.actionItemProvider(action) : null,
|
||||
getActionItem: action => this.menuOptions && this.menuOptions.actionItemProvider ? this.menuOptions.actionItemProvider(action) : undefined,
|
||||
getKeyBinding: action => this.menuOptions && this.menuOptions.getKeyBinding ? this.menuOptions.getKeyBinding(action) : undefined,
|
||||
getMenuClassName: () => this.menuClassName,
|
||||
onHide: () => this.onHide(),
|
||||
|
||||
@@ -75,10 +75,10 @@ export class ToolBar extends Disposable {
|
||||
);
|
||||
this.toggleMenuActionItem!.setActionContext(this.actionBar.context);
|
||||
|
||||
return this.toggleMenuActionItem || null;
|
||||
return this.toggleMenuActionItem;
|
||||
}
|
||||
|
||||
return options.actionItemProvider ? options.actionItemProvider(action) : null;
|
||||
return options.actionItemProvider ? options.actionItemProvider(action) : undefined;
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -300,8 +300,8 @@ class NoActionProvider implements IActionProvider {
|
||||
return null;
|
||||
}
|
||||
|
||||
getActionItem(tree: ITree, element: any, action: Action): IActionItem | null {
|
||||
return null;
|
||||
getActionItem(tree: ITree, element: any, action: Action): IActionItem | undefined {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -736,5 +736,5 @@ export interface IActionProvider {
|
||||
/**
|
||||
* Returns an action item to render an action.
|
||||
*/
|
||||
getActionItem(tree: ITree, element: any, action: IAction): IActionItem | null;
|
||||
getActionItem(tree: ITree, element: any, action: IAction): IActionItem | undefined;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ export class ContributableActionProvider implements IActionProvider {
|
||||
return prepareActions(actions);
|
||||
}
|
||||
|
||||
getActionItem(tree: ITree, element: any, action: Action): BaseActionItem | null {
|
||||
getActionItem(tree: ITree, element: any, action: Action): BaseActionItem | undefined {
|
||||
const contributors = this.registry.getActionBarContributors(Scope.VIEWER);
|
||||
const context = this.toContext(tree, element);
|
||||
|
||||
@@ -143,7 +143,7 @@ export class ContributableActionProvider implements IActionProvider {
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -166,11 +166,11 @@ export abstract class Composite extends Component implements IComposite {
|
||||
/**
|
||||
* For any of the actions returned by this composite, provide an IActionItem in
|
||||
* cases where the implementor of the composite wants to override the presentation
|
||||
* of an action. Returns null to indicate that the action is not rendered through
|
||||
* of an action. Returns undefined to indicate that the action is not rendered through
|
||||
* an action item.
|
||||
*/
|
||||
getActionItem(action: IAction): IActionItem | null {
|
||||
return null;
|
||||
getActionItem(action: IAction): IActionItem | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,7 +50,7 @@ export class CompositeBar extends Widget implements ICompositeBar {
|
||||
|
||||
private compositeSwitcherBar: ActionBar;
|
||||
private compositeOverflowAction: CompositeOverflowActivityAction | null;
|
||||
private compositeOverflowActionItem: CompositeOverflowActivityActionItem | null;
|
||||
private compositeOverflowActionItem: CompositeOverflowActivityActionItem | undefined;
|
||||
|
||||
private model: CompositeBarModel;
|
||||
private visibleComposites: string[];
|
||||
@@ -345,7 +345,7 @@ export class CompositeBar extends Widget implements ICompositeBar {
|
||||
if (this.compositeOverflowActionItem) {
|
||||
this.compositeOverflowActionItem.dispose();
|
||||
}
|
||||
this.compositeOverflowActionItem = null;
|
||||
this.compositeOverflowActionItem = undefined;
|
||||
}
|
||||
|
||||
// Pull out composites that overflow or got hidden
|
||||
|
||||
@@ -432,14 +432,14 @@ export abstract class CompositePart<T extends Composite> extends Part {
|
||||
this.titleLabel.updateStyles();
|
||||
}
|
||||
|
||||
protected actionItemProvider(action: Action): IActionItem | null {
|
||||
protected actionItemProvider(action: Action): IActionItem | undefined {
|
||||
|
||||
// Check Active Composite
|
||||
if (this.activeComposite) {
|
||||
return this.activeComposite.getActionItem(action);
|
||||
}
|
||||
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
protected actionsContextProvider(): any {
|
||||
|
||||
@@ -39,7 +39,6 @@ import { Themable } from 'vs/workbench/common/theme';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { withUndefinedAsNull } from 'vs/base/common/types';
|
||||
|
||||
export interface IToolbarActions {
|
||||
primary: IAction[];
|
||||
@@ -155,18 +154,18 @@ export abstract class TitleControl extends Themable {
|
||||
}));
|
||||
}
|
||||
|
||||
private actionItemProvider(action: Action): IActionItem | null {
|
||||
private actionItemProvider(action: Action): IActionItem | undefined {
|
||||
const activeControl = this.group.activeControl;
|
||||
|
||||
// Check Active Editor
|
||||
let actionItem: IActionItem | null = null;
|
||||
let actionItem: IActionItem | undefined = undefined;
|
||||
if (activeControl instanceof BaseEditor) {
|
||||
actionItem = activeControl.getActionItem(action);
|
||||
}
|
||||
|
||||
// Check extensions
|
||||
if (!actionItem) {
|
||||
actionItem = withUndefinedAsNull(createActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService));
|
||||
actionItem = createActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService);
|
||||
}
|
||||
|
||||
return actionItem;
|
||||
|
||||
@@ -227,7 +227,7 @@ export class NotificationRenderer implements IListRenderer<INotificationViewItem
|
||||
return item;
|
||||
}
|
||||
|
||||
return null;
|
||||
return undefined;
|
||||
},
|
||||
actionRunner: this.actionRunner
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ export class CustomTreeViewPanel extends ViewletPanel {
|
||||
return [...this.treeView.getSecondaryActions()];
|
||||
}
|
||||
|
||||
getActionItem(action: IAction): IActionItem | null {
|
||||
return action instanceof MenuItemAction ? new ContextAwareMenuItemActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService) : null;
|
||||
getActionItem(action: IAction): IActionItem | undefined {
|
||||
return action instanceof MenuItemAction ? new ContextAwareMenuItemActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService) : undefined;
|
||||
}
|
||||
|
||||
getOptimalWidth(): number {
|
||||
@@ -378,7 +378,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
|
||||
}
|
||||
|
||||
private createTree() {
|
||||
const actionItemProvider = (action: IAction) => action instanceof MenuItemAction ? this.instantiationService.createInstance(ContextAwareMenuItemActionItem, action) : null;
|
||||
const actionItemProvider = (action: IAction) => action instanceof MenuItemAction ? this.instantiationService.createInstance(ContextAwareMenuItemActionItem, action) : undefined;
|
||||
const menus = this._register(this.instantiationService.createInstance(TreeMenus, this.id));
|
||||
this.treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this));
|
||||
const dataSource = this.instantiationService.createInstance(TreeDataSource, this, <T>(task: Promise<T>) => this.progressService.withProgress({ location: this.viewContainer.id }, () => task));
|
||||
@@ -814,7 +814,7 @@ class TreeController extends WorkbenchTreeController {
|
||||
if (keybinding) {
|
||||
return new ActionItem(action, action, { label: true, keybinding: keybinding.getLabel() });
|
||||
}
|
||||
return null;
|
||||
return undefined;
|
||||
},
|
||||
|
||||
onHide: (wasCancelled?: boolean) => {
|
||||
|
||||
@@ -174,8 +174,8 @@ export abstract class ViewletPanel extends Panel implements IView {
|
||||
return [];
|
||||
}
|
||||
|
||||
getActionItem(action: IAction): IActionItem | null {
|
||||
return null;
|
||||
getActionItem(action: IAction): IActionItem | undefined {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getActionsContext(): any {
|
||||
@@ -282,7 +282,7 @@ export class PanelViewlet extends Viewlet {
|
||||
return [];
|
||||
}
|
||||
|
||||
getActionItem(action: IAction): IActionItem | null {
|
||||
getActionItem(action: IAction): IActionItem | undefined {
|
||||
if (this.isSingleView()) {
|
||||
return this.panelItems[0].panel.getActionItem(action);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export interface IComposite {
|
||||
/**
|
||||
* Returns the action item for a specific action.
|
||||
*/
|
||||
getActionItem(action: IAction): IActionItem | null;
|
||||
getActionItem(action: IAction): IActionItem | undefined;
|
||||
|
||||
/**
|
||||
* Returns the underlying control of this composite.
|
||||
|
||||
@@ -95,7 +95,7 @@ export class DebugToolbar extends Themable implements IWorkbenchContribution {
|
||||
return new MenuItemActionItem(action, this.keybindingService, this.notificationService, contextMenuService);
|
||||
}
|
||||
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ export class DebugViewlet extends ViewContainerViewlet {
|
||||
return [this.selectAndStartAction, this.configureAction, this.toggleReplAction];
|
||||
}
|
||||
|
||||
getActionItem(action: IAction): IActionItem | null {
|
||||
getActionItem(action: IAction): IActionItem | undefined {
|
||||
if (action.id === StartAction.ID) {
|
||||
this.startDebugActionItem = this.instantiationService.createInstance(StartDebugActionItem, null, action);
|
||||
return this.startDebugActionItem;
|
||||
@@ -141,7 +141,7 @@ export class DebugViewlet extends ViewContainerViewlet {
|
||||
return new MenuItemActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService);
|
||||
}
|
||||
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
focusView(id: string): void {
|
||||
|
||||
@@ -309,12 +309,12 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
|
||||
this.replInput.focus();
|
||||
}
|
||||
|
||||
getActionItem(action: IAction): IActionItem | null {
|
||||
getActionItem(action: IAction): IActionItem | undefined {
|
||||
if (action.id === SelectReplAction.ID) {
|
||||
return this.instantiationService.createInstance(SelectReplActionItem, this.selectReplAction);
|
||||
}
|
||||
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getActions(): IAction[] {
|
||||
|
||||
@@ -254,7 +254,7 @@ export class ExtensionEditor extends BaseEditor {
|
||||
if (action instanceof ExtensionEditorDropDownAction) {
|
||||
return action.createActionItem();
|
||||
}
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -628,7 +628,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
|
||||
if (keybinding) {
|
||||
return new ActionItem(action, action, { label: true, keybinding: keybinding.getLabel() });
|
||||
}
|
||||
return null;
|
||||
return undefined;
|
||||
},
|
||||
onHide: (wasCancelled?: boolean) => {
|
||||
if (wasCancelled) {
|
||||
@@ -670,7 +670,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController {
|
||||
return this.tree.getFocus()[0];
|
||||
}
|
||||
|
||||
public getActionItem(action: IAction): IActionItem | null {
|
||||
public getActionItem(action: IAction): IActionItem | undefined {
|
||||
if (action.id === MarkersFilterAction.ID) {
|
||||
this.filterInputActionItem = this.instantiationService.createInstance(MarkersFilterActionItem, this.filterAction, this);
|
||||
return this.filterInputActionItem;
|
||||
|
||||
@@ -253,7 +253,7 @@ class MarkerWidget extends Disposable {
|
||||
) {
|
||||
super();
|
||||
this.actionBar = this._register(new ActionBar(dom.append(parent, dom.$('.actions')), {
|
||||
actionItemProvider: (action) => action.id === QuickFixAction.ID ? instantiationService.createInstance(QuickFixActionItem, action) : null
|
||||
actionItemProvider: (action) => action.id === QuickFixAction.ID ? instantiationService.createInstance(QuickFixActionItem, action) : undefined
|
||||
}));
|
||||
this.icon = dom.append(parent, dom.$('.icon'));
|
||||
this.multilineActionbar = this._register(new ActionBar(dom.append(parent, dom.$('.multiline-actions'))));
|
||||
|
||||
@@ -75,7 +75,7 @@ export class OutputPanel extends AbstractTextResourceEditor {
|
||||
return this.actions;
|
||||
}
|
||||
|
||||
public getActionItem(action: Action): IActionItem | null {
|
||||
public getActionItem(action: Action): IActionItem | undefined {
|
||||
if (action.id === SwitchOutputAction.ID) {
|
||||
return this.instantiationService.createInstance(SwitchOutputActionItem, action);
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor
|
||||
if (action.id === this.recordKeysAction.id) {
|
||||
return new CheckboxActionItem(null, action);
|
||||
}
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@@ -424,7 +424,7 @@ export class FolderSettingsActionItem extends BaseActionItem {
|
||||
this.contextMenuService.showContextMenu({
|
||||
getAnchor: () => this.container,
|
||||
getActions: () => this.getDropdownMenuActions(),
|
||||
getActionItem: () => null,
|
||||
getActionItem: () => undefined,
|
||||
onHide: () => {
|
||||
this.anchorElement.blur();
|
||||
}
|
||||
@@ -495,7 +495,7 @@ export class SettingsTargetsWidget extends Widget {
|
||||
orientation: ActionsOrientation.HORIZONTAL,
|
||||
ariaLabel: localize('settingsSwitcherBarAriaLabel', "Settings Switcher"),
|
||||
animated: false,
|
||||
actionItemProvider: (action: Action) => action.id === 'folderSettings' ? this.folderSettings : null
|
||||
actionItemProvider: (action: Action) => action.id === 'folderSettings' ? this.folderSettings : undefined
|
||||
}));
|
||||
|
||||
this.userSettings = new Action('userSettings', localize('userSettings', "User Settings"), '.settings-tab', true, () => this.updateTarget(ConfigurationTarget.USER));
|
||||
|
||||
@@ -294,9 +294,9 @@ class DirtyDiffWidget extends PeekViewWidget {
|
||||
};
|
||||
}
|
||||
|
||||
getActionItem(action: IAction): IActionItem | null {
|
||||
getActionItem(action: IAction): IActionItem | undefined {
|
||||
if (!(action instanceof MenuItemAction)) {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return new DiffMenuItemActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService);
|
||||
|
||||
@@ -918,9 +918,9 @@ export class RepositoryPanel extends ViewletPanel {
|
||||
return this.menus.getTitleSecondaryActions();
|
||||
}
|
||||
|
||||
getActionItem(action: IAction): IActionItem | null {
|
||||
getActionItem(action: IAction): IActionItem | undefined {
|
||||
if (!(action instanceof MenuItemAction)) {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return new ContextAwareMenuItemActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService);
|
||||
@@ -1221,9 +1221,9 @@ export class SCMViewlet extends ViewContainerViewlet implements IViewModel {
|
||||
}
|
||||
}
|
||||
|
||||
getActionItem(action: IAction): IActionItem | null {
|
||||
getActionItem(action: IAction): IActionItem | undefined {
|
||||
if (!(action instanceof MenuItemAction)) {
|
||||
return null;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return new ContextAwareMenuItemActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService);
|
||||
|
||||
@@ -161,7 +161,7 @@ export class TerminalPanel extends Panel {
|
||||
return this._contextMenuActions;
|
||||
}
|
||||
|
||||
public getActionItem(action: Action): IActionItem | null {
|
||||
public getActionItem(action: Action): IActionItem | undefined {
|
||||
if (action.id === SwitchTerminalAction.ID) {
|
||||
return this._instantiationService.createInstance(SwitchTerminalActionItem, action);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user