From 2e92a903c7a77bc81c5a18b1364ab0cb731bbc50 Mon Sep 17 00:00:00 2001 From: Charles Gagnon Date: Mon, 23 Aug 2021 14:17:34 -0700 Subject: [PATCH] Remove optimized table setting (#16857) * Remove optimized table option * comment out * completely remove * one more --- .../contrib/query/browser/gridPanel.ts | 18 +- .../query/browser/highPerfGridPanel.ts | 165 ------------------ .../query/browser/query.contribution.ts | 5 - 3 files changed, 5 insertions(+), 183 deletions(-) delete mode 100644 src/sql/workbench/contrib/query/browser/highPerfGridPanel.ts diff --git a/src/sql/workbench/contrib/query/browser/gridPanel.ts b/src/sql/workbench/contrib/query/browser/gridPanel.ts index c6b99a55cf..762128f75a 100644 --- a/src/sql/workbench/contrib/query/browser/gridPanel.ts +++ b/src/sql/workbench/contrib/query/browser/gridPanel.ts @@ -20,7 +20,6 @@ import { escape } from 'sql/base/common/strings'; import { hyperLinkFormatter, textFormatter } from 'sql/base/browser/ui/table/formatters'; import { AdditionalKeyBindings } from 'sql/base/browser/ui/table/plugins/additionalKeyBindings.plugin'; import { CopyKeybind } from 'sql/base/browser/ui/table/plugins/copyKeybind.plugin'; -import { GridTable as HighPerfGridTable } from 'sql/workbench/contrib/query/browser/highPerfGridPanel'; import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; @@ -69,17 +68,15 @@ const MIN_GRID_HEIGHT = (MIN_GRID_HEIGHT_ROWS * ROW_HEIGHT) + HEADER_HEIGHT + ES export class GridPanel extends Disposable { private container = document.createElement('div'); private scrollableView: ScrollableView; - private tables: Array | HighPerfGridTable> = []; + private tables: Array> = []; private tableDisposable = this._register(new DisposableStore()); private queryRunnerDisposables = this._register(new DisposableStore()); private runner: QueryRunner; - private maximizedGrid: GridTable | HighPerfGridTable; + private maximizedGrid: GridTable; private _state: GridPanelState | undefined; - private readonly optimized = this.configurationService.getValue('queryEditor').results.optimizedTable; - constructor( @IConfigurationService private readonly configurationService: IConfigurationService, @IInstantiationService private readonly instantiationService: IInstantiationService, @@ -87,7 +84,7 @@ export class GridPanel extends Disposable { @IThemeService private readonly themeService: IThemeService, ) { super(); - this.scrollableView = new ScrollableView(this.container, { scrollDebouce: this.optimized ? 0 : undefined }); + this.scrollableView = new ScrollableView(this.container); this.scrollableView.onDidScroll(e => { if (this.state && this.scrollableView.length !== 0) { this.state.scrollPosition = e.scrollTop; @@ -204,7 +201,7 @@ export class GridPanel extends Disposable { } private addResultSet(resultSet: ResultSetSummary[]) { - const tables: Array | HighPerfGridTable> = []; + const tables: Array> = []; for (const set of resultSet) { // ensure we aren't adding a resultSet that is already visible @@ -221,12 +218,7 @@ export class GridPanel extends Disposable { this.state.tableStates.push(tableState); } } - let table: GridTable | HighPerfGridTable; - if (this.optimized) { - table = this.instantiationService.createInstance(HighPerfGridTable, this.runner, set, tableState); - } else { - table = this.instantiationService.createInstance(GridTable, this.runner, set, tableState); - } + const table = this.instantiationService.createInstance(GridTable, this.runner, set, tableState); this.tableDisposable.add(tableState.onMaximizedChange(e => { if (e) { this.maximizeTable(table.id); diff --git a/src/sql/workbench/contrib/query/browser/highPerfGridPanel.ts b/src/sql/workbench/contrib/query/browser/highPerfGridPanel.ts deleted file mode 100644 index 3ea65ea95d..0000000000 --- a/src/sql/workbench/contrib/query/browser/highPerfGridPanel.ts +++ /dev/null @@ -1,165 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import 'vs/css!./media/optimizedGridPanel'; - -import { ITableRenderer, ITableColumn } from 'sql/base/browser/ui/table/highPerf/table'; -import { VirtualizedWindow } from 'sql/base/browser/ui/table/highPerf/virtualizedWindow'; -import { attachHighPerfTableStyler } from 'sql/platform/theme/common/styler'; -import QueryRunner from 'sql/workbench/services/query/common/queryRunner'; -import { GridTableState } from 'sql/workbench/common/editor/query/gridTableState'; -import { ResultSetSummary } from 'sql/workbench/services/query/common/query'; - -import { append, $ } from 'vs/base/browser/dom'; -import { Disposable } from 'vs/base/common/lifecycle'; -import { Emitter, Event } from 'vs/base/common/event'; -import { generateUuid } from 'vs/base/common/uuid'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { IThemeService } from 'vs/platform/theme/common/themeService'; -import { WorkbenchTable } from 'sql/platform/table/browser/tableService'; -import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IView } from 'sql/base/browser/ui/scrollableView/scrollableView'; - -type ICellTemplate = HTMLElement; - -class TableFormatter implements ITableRenderer { - renderTemplate(container: HTMLElement): ICellTemplate { - return append(container, $('.cell')); - } - - renderCell(element: T, index: number, cellIndex: number, columnId: string, templateData: ICellTemplate, width: number): void { - templateData.innerText = element[columnId]; - } - - disposeCell?(element: T, index: number, cellIndex: number, columnId: string, templateData: ICellTemplate, width: number): void { - templateData.innerText = ''; - } - - disposeTemplate(templateData: ICellTemplate): void { - } - -} - -const ROW_HEIGHT = 22; -const HEADER_HEIGHT = 22; -const MIN_GRID_HEIGHT_ROWS = 8; -const ESTIMATED_SCROLL_BAR_SIZE = 10; -const BOTTOM_PADDING = 15; - -// this handles min size if rows is greater than the min grid visible rows -const MIN_GRID_HEIGHT = (MIN_GRID_HEIGHT_ROWS * ROW_HEIGHT) + HEADER_HEIGHT + ESTIMATED_SCROLL_BAR_SIZE; - -export class GridTable extends Disposable implements IView { - - private _onDidChange = new Emitter(); - public readonly onDidChange: Event = this._onDidChange.event; - - private virtWindow: VirtualizedWindow; - private table: WorkbenchTable; - private tableContainer: HTMLElement; - private columns: ITableColumn[]; - - public id = generateUuid(); - readonly element = $('.grid-panel.optimized'); - - private _state: GridTableState; - - private rowHeight: number; - - public get resultSet(): ResultSetSummary { - return this._resultSet; - } - - // this handles if the row count is small, like 4-5 rows - private get maxSize(): number { - return ((this.resultSet.rowCount) * this.rowHeight) + HEADER_HEIGHT + ESTIMATED_SCROLL_BAR_SIZE; - } - - // worthless for this table - public isOnlyTable: boolean; - - constructor( - private readonly runner: QueryRunner, - private _resultSet: ResultSetSummary, - state: GridTableState, - @IConfigurationService private readonly configurationService: IConfigurationService, - @IThemeService private readonly themeService: IThemeService, - @IInstantiationService private readonly instantiationService: IInstantiationService - ) { - super(); - this.tableContainer = append(this.element, $('.table-panel')); - let config = this.configurationService.getValue<{ rowHeight: number }>('resultsGrid'); - this.rowHeight = config && config.rowHeight ? config.rowHeight : ROW_HEIGHT; - this.state = state; - - this.columns = this.resultSet.columnInfo.map>((c, i) => ({ - id: i.toString(), - name: c.columnName === 'Microsoft SQL Server 2005 XML Showplan' - ? 'XML Showplan' - : escape(c.columnName), - renderer: new TableFormatter(), - width: this.state.columnSizes && this.state.columnSizes[i] ? this.state.columnSizes[i] : undefined - })); - - this.virtWindow = new VirtualizedWindow(50, this.resultSet.rowCount, (offset, count) => { - return Promise.resolve(this.runner.getQueryRows(offset, count, this._resultSet.batchId, this._resultSet.id).then(r => { - return r.rows.map(c => c.reduce((p, c, i) => { - p[this.columns[i].id] = c.displayValue; - return p; - }, Object.create(null))); - })); - }); - - this.table = this._register(this.instantiationService.createInstance(WorkbenchTable, 'gridPanel', this.tableContainer, this.columns, { - getRow: index => this.virtWindow.getIndex(index) - }, { rowHeight: this.rowHeight, headerHeight: HEADER_HEIGHT, rowCountColumn: false }) as WorkbenchTable); - - this.table.length = this.resultSet.rowCount; - - this._register(attachHighPerfTableStyler(this.table, this.themeService)); - } - - public get state(): GridTableState { - return this._state; - } - - public set state(val: GridTableState) { - this._state = val; - } - - public updateResult(resultSet: ResultSetSummary) { - this._resultSet = resultSet; - if (this.table) { - this.virtWindow.length = resultSet.rowCount; - this.table.length = resultSet.rowCount; - } - this._onDidChange.fire(undefined); - } - - public layout(height: number, width: number): void { - this.tableContainer.style.width = `${width - ESTIMATED_SCROLL_BAR_SIZE}px`; - this.table.layout(height, width - ESTIMATED_SCROLL_BAR_SIZE); - } - - public get minimumSize(): number { - // clamp between ensuring we can show the actionbar, while also making sure we don't take too much space - // if there is only one table then allow a minimum size of ROW_HEIGHT - return Math.max(Math.min(this.maxSize, MIN_GRID_HEIGHT), BOTTOM_PADDING); - } - - public get maximumSize(): number { - return Math.max(this.maxSize, BOTTOM_PADDING); - } - - public override dispose() { - this.element.remove(); - super.dispose(); - } - - public style(): void { - } - - public focus() { } -} diff --git a/src/sql/workbench/contrib/query/browser/query.contribution.ts b/src/sql/workbench/contrib/query/browser/query.contribution.ts index 54f6087904..6747fb4b1f 100644 --- a/src/sql/workbench/contrib/query/browser/query.contribution.ts +++ b/src/sql/workbench/contrib/query/browser/query.contribution.ts @@ -392,11 +392,6 @@ const queryEditorConfiguration: IConfigurationNode = { 'description': localize('queryEditor.results.copyRemoveNewLine', "Configuration options for copying multi-line results from the Results View"), 'default': true }, - 'queryEditor.results.optimizedTable': { - 'type': 'boolean', - 'description': localize('queryEditor.results.optimizedTable', "(Experimental) Use a optimized table in the results out. Some functionality might be missing and in the works."), - 'default': false - }, 'queryEditor.results.inMemoryDataProcessingThreshold': { 'type': 'number', 'default': 5000,