use WorkbenchToolBar in notebook diff land

This commit is contained in:
Johannes 2022-09-16 15:02:43 +02:00
parent fa89b71d8a
commit 0d067d86df
No known key found for this signature in database
GPG key ID: 6DEF802A22264FCA
3 changed files with 13 additions and 10 deletions

View file

@ -40,6 +40,8 @@ import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IDiffEditorConstructionOptions } from 'vs/editor/browser/editorBrowser';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { WorkbenchToolBar } from 'vs/platform/actions/browser/toolbar';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
const fixedEditorPadding = {
top: 12,
@ -104,7 +106,7 @@ class PropertyHeader extends Disposable {
protected _foldingIndicator!: HTMLElement;
protected _statusSpan!: HTMLElement;
protected _description!: HTMLElement;
protected _toolbar!: ToolBar;
protected _toolbar!: WorkbenchToolBar;
protected _menu!: IMenu;
protected _propertyExpanded?: IContextKey<boolean>;
@ -128,6 +130,7 @@ class PropertyHeader extends Disposable {
@IMenuService readonly menuService: IMenuService,
@IContextKeyService readonly contextKeyService: IContextKeyService,
@IThemeService readonly themeService: IThemeService,
@ITelemetryService readonly telemetryService: ITelemetryService,
) {
super();
}
@ -156,7 +159,7 @@ class PropertyHeader extends Disposable {
}
const cellToolbarContainer = DOM.append(this.propertyHeaderContainer, DOM.$('div.property-toolbar'));
this._toolbar = new ToolBar(cellToolbarContainer, this.contextMenuService, {
this._toolbar = new WorkbenchToolBar(cellToolbarContainer, {
actionViewItemProvider: action => {
if (action instanceof MenuItemAction) {
const item = new CodiconActionViewItem(action, undefined, this.keybindingService, this.notificationService, this.contextKeyService, this.themeService, this.contextMenuService);
@ -165,7 +168,7 @@ class PropertyHeader extends Disposable {
return undefined;
}
});
}, this.menuService, this.contextKeyService, this.contextMenuService, this.keybindingService, this.telemetryService);
this._register(this._toolbar);
this._toolbar.context = {
cell: this.cell
@ -1567,11 +1570,11 @@ export class ModifiedElement extends AbstractElementRenderer {
}
}));
this._menu = this.menuService.createMenu(MenuId.NotebookDiffCellInputTitle, scopedContextKeyService);
this._register(this._menu);
const menu = this.menuService.createMenu(MenuId.NotebookDiffCellInputTitle, scopedContextKeyService);
const actions: IAction[] = [];
createAndFillInActionBarActions(this._menu, { shouldForwardArgs: true }, actions);
createAndFillInActionBarActions(menu, { shouldForwardArgs: true }, actions);
this._toolbar.setActions(actions);
menu.dispose();
}
private async _initializeSourceDiffEditor() {

View file

@ -11,11 +11,11 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
import { ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { NotebookOptions } from 'vs/workbench/contrib/notebook/common/notebookOptions';
import { NotebookLayoutInfo } from 'vs/workbench/contrib/notebook/browser/notebookViewEvents';
import { WorkbenchToolBar } from 'vs/platform/actions/browser/toolbar';
export enum DiffSide {
Original = 0,
@ -83,7 +83,7 @@ export interface CellDiffSideBySideRenderTemplate extends CellDiffCommonRenderTe
readonly sourceEditor: DiffEditorWidget;
readonly editorContainer: HTMLElement;
readonly inputToolbarContainer: HTMLElement;
readonly toolbar: ToolBar;
readonly toolbar: WorkbenchToolBar;
readonly metadataHeaderContainer: HTMLElement;
readonly metadataInfoContainer: HTMLElement;
readonly outputHeaderContainer: HTMLElement;

View file

@ -20,7 +20,6 @@ import { isMacintosh } from 'vs/base/common/platform';
import { DeletedElement, fixedDiffEditorOptions, fixedEditorOptions, getOptimizedNestedCodeEditorWidgetOptions, InsertElement, ModifiedElement } from 'vs/workbench/contrib/notebook/browser/diff/diffComponents';
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
import { ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
import { IMenuService, MenuItemAction } from 'vs/platform/actions/common/actions';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { INotificationService } from 'vs/platform/notification/common/notification';
@ -29,6 +28,7 @@ import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { BareFontInfo } from 'vs/editor/common/config/fontInfo';
import { PixelRatio } from 'vs/base/browser/browser';
import { WorkbenchToolBar } from 'vs/platform/actions/browser/toolbar';
export class NotebookCellTextDiffListDelegate implements IListVirtualDelegate<DiffElementViewModelBase> {
private readonly lineHeight: number;
@ -184,7 +184,7 @@ export class CellDiffSideBySideRenderer implements IListRenderer<SideBySideDiffE
const inputToolbarContainer = DOM.append(sourceContainer, DOM.$('.editor-input-toolbar-container'));
const cellToolbarContainer = DOM.append(inputToolbarContainer, DOM.$('div.property-toolbar'));
const toolbar = new ToolBar(cellToolbarContainer, this.contextMenuService, {
const toolbar = this.instantiationService.createInstance(WorkbenchToolBar, cellToolbarContainer, {
actionViewItemProvider: action => {
if (action instanceof MenuItemAction) {
const item = new CodiconActionViewItem(action, undefined, this.keybindingService, this.notificationService, this.contextKeyService, this.themeService, this.contextMenuService);