mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
parent
45245af3e9
commit
0ccc4d9479
|
@ -95,10 +95,6 @@ export class BaseActionViewItem extends Disposable implements IActionViewItem {
|
|||
this._actionRunner = actionRunner;
|
||||
}
|
||||
|
||||
getAction(): IAction {
|
||||
return this._action;
|
||||
}
|
||||
|
||||
isEnabled(): boolean {
|
||||
return this._action.enabled;
|
||||
}
|
||||
|
@ -214,7 +210,7 @@ export class BaseActionViewItem extends Disposable implements IActionViewItem {
|
|||
}
|
||||
|
||||
protected getTooltip(): string | undefined {
|
||||
return this.getAction().tooltip;
|
||||
return this.action.tooltip;
|
||||
}
|
||||
|
||||
protected updateTooltip(): void {
|
||||
|
@ -333,18 +329,18 @@ export class ActionViewItem extends BaseActionViewItem {
|
|||
|
||||
override updateLabel(): void {
|
||||
if (this.options.label && this.label) {
|
||||
this.label.textContent = this.getAction().label;
|
||||
this.label.textContent = this.action.label;
|
||||
}
|
||||
}
|
||||
|
||||
override getTooltip() {
|
||||
let title: string | null = null;
|
||||
|
||||
if (this.getAction().tooltip) {
|
||||
title = this.getAction().tooltip;
|
||||
if (this.action.tooltip) {
|
||||
title = this.action.tooltip;
|
||||
|
||||
} else if (!this.options.label && this.getAction().label && this.options.icon) {
|
||||
title = this.getAction().label;
|
||||
} else if (!this.options.label && this.action.label && this.options.icon) {
|
||||
title = this.action.label;
|
||||
|
||||
if (this.options.keybinding) {
|
||||
title = nls.localize({ key: 'titleLabel', comment: ['action title', 'action keybinding'] }, "{0} ({1})", title, this.options.keybinding);
|
||||
|
@ -359,7 +355,7 @@ export class ActionViewItem extends BaseActionViewItem {
|
|||
}
|
||||
|
||||
if (this.options.icon) {
|
||||
this.cssClass = this.getAction().class;
|
||||
this.cssClass = this.action.class;
|
||||
|
||||
if (this.label) {
|
||||
this.label.classList.add('codicon');
|
||||
|
@ -375,7 +371,7 @@ export class ActionViewItem extends BaseActionViewItem {
|
|||
}
|
||||
|
||||
override updateEnabled(): void {
|
||||
if (this.getAction().enabled) {
|
||||
if (this.action.enabled) {
|
||||
if (this.label) {
|
||||
this.label.removeAttribute('aria-disabled');
|
||||
this.label.classList.remove('disabled');
|
||||
|
@ -394,7 +390,7 @@ export class ActionViewItem extends BaseActionViewItem {
|
|||
|
||||
override updateChecked(): void {
|
||||
if (this.label) {
|
||||
if (this.getAction().checked) {
|
||||
if (this.action.checked) {
|
||||
this.label.classList.add('checked');
|
||||
} else {
|
||||
this.label.classList.remove('checked');
|
||||
|
|
|
@ -133,10 +133,10 @@ export class DropdownMenuActionViewItem extends BaseActionViewItem {
|
|||
override getTooltip(): string | undefined {
|
||||
let title: string | null = null;
|
||||
|
||||
if (this.getAction().tooltip) {
|
||||
title = this.getAction().tooltip;
|
||||
} else if (this.getAction().label) {
|
||||
title = this.getAction().label;
|
||||
if (this.action.tooltip) {
|
||||
title = this.action.tooltip;
|
||||
} else if (this.action.label) {
|
||||
title = this.action.label;
|
||||
}
|
||||
|
||||
return title ?? undefined;
|
||||
|
@ -159,7 +159,7 @@ export class DropdownMenuActionViewItem extends BaseActionViewItem {
|
|||
}
|
||||
|
||||
protected override updateEnabled(): void {
|
||||
const disabled = !this.getAction().enabled;
|
||||
const disabled = !this.action.enabled;
|
||||
this.actionItem?.classList.toggle('disabled', disabled);
|
||||
this.element?.classList.toggle('disabled', disabled);
|
||||
}
|
||||
|
|
|
@ -446,7 +446,7 @@ class BaseMenuActionViewItem extends BaseActionViewItem {
|
|||
|
||||
// Set mnemonic
|
||||
if (this.options.label && options.enableMnemonics) {
|
||||
const label = this.getAction().label;
|
||||
const label = this.action.label;
|
||||
if (label) {
|
||||
const matches = MENU_MNEMONIC_REGEX.exec(label);
|
||||
if (matches) {
|
||||
|
@ -572,7 +572,7 @@ class BaseMenuActionViewItem extends BaseActionViewItem {
|
|||
if (this.options.label) {
|
||||
clearNode(this.label);
|
||||
|
||||
let label = stripIcons(this.getAction().label);
|
||||
let label = stripIcons(this.action.label);
|
||||
if (label) {
|
||||
const cleanLabel = cleanMnemonic(label);
|
||||
if (!this.options.enableMnemonics) {
|
||||
|
@ -624,7 +624,7 @@ class BaseMenuActionViewItem extends BaseActionViewItem {
|
|||
this.item.classList.remove(...this.cssClass.split(' '));
|
||||
}
|
||||
if (this.options.icon && this.label) {
|
||||
this.cssClass = this.getAction().class || '';
|
||||
this.cssClass = this.action.class || '';
|
||||
this.label.classList.add('icon');
|
||||
if (this.cssClass) {
|
||||
this.label.classList.add(...this.cssClass.split(' '));
|
||||
|
@ -636,7 +636,7 @@ class BaseMenuActionViewItem extends BaseActionViewItem {
|
|||
}
|
||||
|
||||
override updateEnabled(): void {
|
||||
if (this.getAction().enabled) {
|
||||
if (this.action.enabled) {
|
||||
if (this.element) {
|
||||
this.element.classList.remove('disabled');
|
||||
this.element.removeAttribute('aria-disabled');
|
||||
|
@ -665,7 +665,7 @@ class BaseMenuActionViewItem extends BaseActionViewItem {
|
|||
return;
|
||||
}
|
||||
|
||||
const checked = this.getAction().checked;
|
||||
const checked = this.action.checked;
|
||||
this.item.classList.toggle('checked', !!checked);
|
||||
if (checked !== undefined) {
|
||||
this.item.setAttribute('role', 'menuitemcheckbox');
|
||||
|
|
|
@ -1684,10 +1684,10 @@ export class QuickInputController extends Disposable {
|
|||
if (enabled !== this.enabled) {
|
||||
this.enabled = enabled;
|
||||
for (const item of this.getUI().leftActionBar.viewItems) {
|
||||
(item as ActionViewItem).getAction().enabled = enabled;
|
||||
(item as ActionViewItem).action.enabled = enabled;
|
||||
}
|
||||
for (const item of this.getUI().rightActionBar.viewItems) {
|
||||
(item as ActionViewItem).getAction().enabled = enabled;
|
||||
(item as ActionViewItem).action.enabled = enabled;
|
||||
}
|
||||
this.getUI().checkAll.disabled = !enabled;
|
||||
// this.getUI().inputBox.enabled = enabled; Avoid loosing focus.
|
||||
|
|
|
@ -277,7 +277,7 @@ export class ActivityActionViewItem extends BaseActionViewItem {
|
|||
}
|
||||
|
||||
protected updateBadge(): void {
|
||||
const action = this.getAction();
|
||||
const action = this.action;
|
||||
if (!this.badge || !this.badgeContent || !(action instanceof ActivityAction)) {
|
||||
return;
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ export class ActivityActionViewItem extends BaseActionViewItem {
|
|||
}
|
||||
|
||||
if (!this.options.icon) {
|
||||
this.label.textContent = this.getAction().label;
|
||||
this.label.textContent = this.action.label;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,7 +370,7 @@ export class ActivityActionViewItem extends BaseActionViewItem {
|
|||
private computeTitle(): string {
|
||||
this.keybindingLabel = this.computeKeybindingLabel();
|
||||
let title = this.keybindingLabel ? localize('titleKeybinding', "{0} ({1})", this.activity.name, this.keybindingLabel) : this.activity.name;
|
||||
const badge = (this.getAction() as ActivityAction).getBadge();
|
||||
const badge = (this.action as ActivityAction).getBadge();
|
||||
if (badge?.getDescription()) {
|
||||
title = localize('badgeTitle', "{0} - {1}", title, badge.getDescription());
|
||||
}
|
||||
|
@ -605,8 +605,8 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
|
|||
|
||||
// Activate on drag over to reveal targets
|
||||
[this.badge, this.label].forEach(b => this._register(new DelayedDragHandler(b, () => {
|
||||
if (!this.getAction().checked) {
|
||||
this.getAction().run();
|
||||
if (!this.action.checked) {
|
||||
this.action.run();
|
||||
}
|
||||
})));
|
||||
|
||||
|
@ -692,7 +692,7 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
|
|||
}
|
||||
|
||||
protected override updateChecked(): void {
|
||||
if (this.getAction().checked) {
|
||||
if (this.action.checked) {
|
||||
this.container.classList.add('checked');
|
||||
this.container.setAttribute('aria-label', this.container.title);
|
||||
this.container.setAttribute('aria-expanded', 'true');
|
||||
|
@ -711,7 +711,7 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.getAction().enabled) {
|
||||
if (this.action.enabled) {
|
||||
this.element.classList.remove('disabled');
|
||||
} else {
|
||||
this.element.classList.add('disabled');
|
||||
|
|
|
@ -37,7 +37,7 @@ export class ReactionActionViewItem extends ActionViewItem {
|
|||
return;
|
||||
}
|
||||
|
||||
const action = this.getAction() as ReactionAction;
|
||||
const action = this.action as ReactionAction;
|
||||
if (action.class) {
|
||||
this.label.classList.add(action.class);
|
||||
}
|
||||
|
|
|
@ -498,7 +498,7 @@ export class QuickFixActionViewItem extends ActionViewItem {
|
|||
return;
|
||||
}
|
||||
const elementPosition = DOM.getDomNodePagePosition(this.element);
|
||||
const quickFixes = (<QuickFixAction>this.getAction()).quickFixes;
|
||||
const quickFixes = (<QuickFixAction>this.action).quickFixes;
|
||||
if (quickFixes.length) {
|
||||
this.contextMenuService.showContextMenu({
|
||||
getAnchor: () => ({ x: elementPosition.left + 10, y: elementPosition.top + elementPosition.height + 4 }),
|
||||
|
|
|
@ -300,10 +300,10 @@ export class SettingsTargetsWidget extends Widget {
|
|||
this.userRemoteSettings.checked = ConfigurationTarget.USER_REMOTE === this.settingsTarget;
|
||||
this.workspaceSettings.checked = ConfigurationTarget.WORKSPACE === this.settingsTarget;
|
||||
if (this.settingsTarget instanceof URI) {
|
||||
this.folderSettings.getAction().checked = true;
|
||||
this.folderSettings.action.checked = true;
|
||||
this.folderSettings.folder = this.contextService.getWorkspaceFolder(this.settingsTarget as URI);
|
||||
} else {
|
||||
this.folderSettings.getAction().checked = false;
|
||||
this.folderSettings.action.checked = false;
|
||||
}
|
||||
this.inUserTab.set(this.userLocalSettings.checked);
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ export class SettingsTargetsWidget extends Widget {
|
|||
this.settingsSwitcherBar.domNode.classList.toggle('empty-workbench', this.contextService.getWorkbenchState() === WorkbenchState.EMPTY);
|
||||
this.userRemoteSettings.enabled = !!(this.options.enableRemoteSettings && this.environmentService.remoteAuthority);
|
||||
this.workspaceSettings.enabled = this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY;
|
||||
this.folderSettings.getAction().enabled = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && this.contextService.getWorkspace().folders.length > 0;
|
||||
this.folderSettings.action.enabled = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && this.contextService.getWorkspace().folders.length > 0;
|
||||
|
||||
this.workspaceSettings.tooltip = (await this.preferencesService.getEditableSettingsURI(ConfigurationTarget.WORKSPACE))?.fsPath || '';
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ class StatusBarActionViewItem extends ActionViewItem {
|
|||
|
||||
override updateLabel(): void {
|
||||
if (this.options.label && this.label) {
|
||||
reset(this.label, ...renderLabelWithIcons(this.getAction().label));
|
||||
reset(this.label, ...renderLabelWithIcons(this.action.label));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue