提交 8a806778 编写于 作者: B Benjamin Pasero

fix #49465

上级 a97e8c31
......@@ -25,6 +25,7 @@ export class ContextSubMenu extends SubmenuAction {
export interface IContextMenuDelegate {
getAnchor(): HTMLElement | { x: number; y: number; width?: number; height?: number; };
getActions(): ReadonlyArray<IAction | ContextSubMenu>;
getCheckedActionsRepresentation?(action: IAction): 'radio' | 'checkbox';
getActionViewItem?(action: IAction): IActionViewItem | undefined;
getActionsContext?(event?: IContextMenuEvent): any;
getKeyBinding?(action: IAction): ResolvedKeybinding | undefined;
......
......@@ -224,7 +224,6 @@ export class Separator extends Action {
constructor(label?: string) {
super(Separator.ID, label, label ? 'separator text' : 'separator');
this.checked = false;
this.radio = false;
this.enabled = false;
}
}
......
......@@ -29,7 +29,6 @@ export interface IAction extends IDisposable {
class: string | undefined;
enabled: boolean;
checked: boolean;
radio: boolean;
run(event?: any): Promise<any>;
}
......@@ -54,7 +53,6 @@ export interface IActionChangeEvent {
readonly class?: string;
readonly enabled?: boolean;
readonly checked?: boolean;
readonly radio?: boolean;
}
export class Action extends Disposable implements IAction {
......@@ -68,7 +66,6 @@ export class Action extends Disposable implements IAction {
protected _cssClass: string | undefined;
protected _enabled: boolean = true;
protected _checked: boolean = false;
protected _radio: boolean = false;
protected readonly _actionCallback?: (event?: any) => Promise<any>;
constructor(id: string, label: string = '', cssClass: string = '', enabled: boolean = true, actionCallback?: (event?: any) => Promise<any>) {
......@@ -152,14 +149,6 @@ export class Action extends Disposable implements IAction {
this._setChecked(value);
}
get radio(): boolean {
return this._radio;
}
set radio(value: boolean) {
this._setRadio(value);
}
protected _setChecked(value: boolean): void {
if (this._checked !== value) {
this._checked = value;
......@@ -167,13 +156,6 @@ export class Action extends Disposable implements IAction {
}
}
protected _setRadio(value: boolean): void {
if (this._radio !== value) {
this._radio = value;
this._onDidChange.fire({ radio: value });
}
}
run(event?: any, _data?: ITelemetryData): Promise<any> {
if (this._actionCallback) {
return this._actionCallback(event);
......
......@@ -30,11 +30,12 @@ export interface ICompositeBarItem {
}
export interface ICompositeBarOptions {
icon: boolean;
orientation: ActionsOrientation;
colors: (theme: ITheme) => ICompositeBarColors;
compositeSize: number;
overflowActionSize: number;
readonly icon: boolean;
readonly orientation: ActionsOrientation;
readonly colors: (theme: ITheme) => ICompositeBarColors;
readonly compositeSize: number;
readonly overflowActionSize: number;
getActivityAction: (compositeId: string) => ActivityAction;
getCompositePinnedAction: (compositeId: string) => Action;
getOnCompositeClickAction: (compositeId: string) => Action;
......
......@@ -383,6 +383,7 @@ export class CompositeOverflowActivityActionViewItem extends ActivityActionViewI
this.contextMenuService.showContextMenu({
getAnchor: () => this.container,
getActions: () => this.actions,
getCheckedActionsRepresentation: () => 'radio',
onHide: () => dispose(this.actions)
});
}
......@@ -390,7 +391,7 @@ export class CompositeOverflowActivityActionViewItem extends ActivityActionViewI
private getActions(): Action[] {
return this.getOverflowingComposites().map(composite => {
const action = this.getCompositeOpenAction(composite.id);
action.radio = this.getActiveCompositeId() === action.id;
action.checked = this.getActiveCompositeId() === action.id;
const badge = this.getBadge(composite.id);
let suffix: string | number | undefined;
......@@ -614,8 +615,8 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
this.contextMenuService.showContextMenu({
getAnchor: () => anchor,
getActionsContext: () => this.activity.id,
getActions: () => actions
getActions: () => actions,
getActionsContext: () => this.activity.id
});
}
......
......@@ -138,10 +138,19 @@ class NativeContextMenuService extends Disposable implements IContextMenuService
// Normal Menu Item
else {
let type: 'radio' | 'checkbox' | undefined = undefined;
if (!!entry.checked) {
if (typeof delegate.getCheckedActionsRepresentation === 'function') {
type = delegate.getCheckedActionsRepresentation(entry);
} else {
type = 'checkbox';
}
}
const item: IContextMenuItem = {
label: unmnemonicLabel(entry.label),
checked: !!entry.checked || !!entry.radio,
type: !!entry.checked ? 'checkbox' : !!entry.radio ? 'radio' : undefined,
checked: !!entry.checked,
type,
enabled: !!entry.enabled,
click: event => {
......@@ -188,4 +197,4 @@ class NativeContextMenuService extends Disposable implements IContextMenuService
}
}
registerSingleton(IContextMenuService, ContextMenuService, true);
\ No newline at end of file
registerSingleton(IContextMenuService, ContextMenuService, true);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册