mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Delete unused cell renderer parts
This commit is contained in:
parent
b5253894dd
commit
ffae23b5f1
|
@ -5,15 +5,12 @@
|
|||
|
||||
import { getPixelRatio, getZoomLevel } from 'vs/base/browser/browser';
|
||||
import * as DOM from 'vs/base/browser/dom';
|
||||
import * as aria from 'vs/base/browser/ui/aria/aria';
|
||||
import { renderIcon } from 'vs/base/browser/ui/iconLabel/iconLabels';
|
||||
import { IListRenderer, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
|
||||
import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
|
||||
import { ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
|
||||
import { Action, IAction } from 'vs/base/common/actions';
|
||||
import * as Codicons from 'vs/base/common/codicons';
|
||||
import { Color } from 'vs/base/common/color';
|
||||
import { combinedDisposable, Disposable, DisposableStore, IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { combinedDisposable, Disposable, DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { MarshalledId } from 'vs/base/common/marshalling';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
@ -37,11 +34,10 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
|
|||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { syncing } from 'vs/platform/theme/common/iconRegistry';
|
||||
import { ThemeIcon } from 'vs/platform/theme/common/themeService';
|
||||
import { DeleteCellAction, INotebookActionContext, INotebookCellActionContext } from 'vs/workbench/contrib/notebook/browser/contrib/coreActions';
|
||||
import { BaseCellRenderTemplate, CodeCellLayoutInfo, CodeCellRenderTemplate, EXPAND_CELL_INPUT_COMMAND_ID, ICellViewModel, INotebookEditor, isCodeCellRenderTemplate, MarkdownCellRenderTemplate, NOTEBOOK_CELL_EXECUTION_STATE, NOTEBOOK_CELL_LIST_FOCUSED, NOTEBOOK_CELL_TYPE, NOTEBOOK_EDITOR_FOCUSED } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { errorStateIcon, successStateIcon, unfoldIcon } from 'vs/workbench/contrib/notebook/browser/notebookIcons';
|
||||
import { unfoldIcon } from 'vs/workbench/contrib/notebook/browser/notebookIcons';
|
||||
import { CodiconActionViewItem } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellActionView';
|
||||
import { CellContextKeyManager } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellContextKeys';
|
||||
import { CellDragAndDropController, DRAGGING_CLASS } from 'vs/workbench/contrib/notebook/browser/view/renderers/cellDnd';
|
||||
|
@ -1045,122 +1041,6 @@ export function getCodeCellExecutionContextKeyService(contextKeyService: IContex
|
|||
return executionContextKeyService;
|
||||
}
|
||||
|
||||
export class TimerRenderer {
|
||||
constructor(private readonly container: HTMLElement) {
|
||||
DOM.hide(container);
|
||||
}
|
||||
|
||||
private intervalTimer: number | undefined;
|
||||
|
||||
start(startTime: number, adjustment: number): IDisposable {
|
||||
this.stop();
|
||||
DOM.show(this.container);
|
||||
const intervalTimer = setInterval(() => {
|
||||
const duration = Date.now() - startTime + adjustment;
|
||||
this.container.textContent = this.formatDuration(duration);
|
||||
}, 100);
|
||||
this.intervalTimer = intervalTimer as unknown as number | undefined;
|
||||
|
||||
return toDisposable(() => {
|
||||
clearInterval(intervalTimer);
|
||||
});
|
||||
}
|
||||
|
||||
stop() {
|
||||
if (this.intervalTimer) {
|
||||
clearInterval(this.intervalTimer);
|
||||
}
|
||||
}
|
||||
|
||||
show(duration: number) {
|
||||
this.stop();
|
||||
|
||||
DOM.show(this.container);
|
||||
this.container.textContent = this.formatDuration(duration);
|
||||
}
|
||||
|
||||
clear() {
|
||||
DOM.hide(this.container);
|
||||
this.stop();
|
||||
this.container.textContent = '';
|
||||
}
|
||||
|
||||
private formatDuration(duration: number) {
|
||||
const seconds = Math.floor(duration / 1000);
|
||||
const tenths = String(duration - seconds * 1000).charAt(0);
|
||||
|
||||
return `${seconds}.${tenths}s`;
|
||||
}
|
||||
}
|
||||
|
||||
export class RunStateRenderer {
|
||||
private static readonly MIN_SPINNER_TIME = 200;
|
||||
|
||||
private spinnerTimer: any | undefined;
|
||||
private lastRunState: NotebookCellExecutionState | undefined;
|
||||
private pendingNewState: NotebookCellExecutionState | undefined;
|
||||
private pendingLastRunSuccess: boolean | undefined;
|
||||
|
||||
constructor(private readonly element: HTMLElement) {
|
||||
DOM.hide(element);
|
||||
}
|
||||
|
||||
clear() {
|
||||
if (this.spinnerTimer) {
|
||||
clearTimeout(this.spinnerTimer);
|
||||
this.spinnerTimer = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
renderState(runState: NotebookCellExecutionState | undefined, getCellIndex: () => number, lastRunSuccess: boolean | undefined = undefined) {
|
||||
if (this.spinnerTimer) {
|
||||
this.pendingNewState = runState;
|
||||
this.pendingLastRunSuccess = lastRunSuccess;
|
||||
return;
|
||||
}
|
||||
|
||||
let runStateTooltip: string | undefined;
|
||||
if (!runState && lastRunSuccess) {
|
||||
aria.alert(`Code cell at ${getCellIndex()} finishes running successfully`);
|
||||
DOM.reset(this.element, renderIcon(successStateIcon));
|
||||
} else if (!runState && !lastRunSuccess) {
|
||||
aria.alert(`Code cell at ${getCellIndex()} finishes running with errors`);
|
||||
DOM.reset(this.element, renderIcon(errorStateIcon));
|
||||
} else if (runState === NotebookCellExecutionState.Executing) {
|
||||
runStateTooltip = localize('runStateExecuting', "Executing");
|
||||
if (this.lastRunState !== NotebookCellExecutionState.Executing) {
|
||||
aria.alert(`Code cell at ${getCellIndex()} starts running`);
|
||||
}
|
||||
DOM.reset(this.element, renderIcon(syncing));
|
||||
this.spinnerTimer = setTimeout(() => {
|
||||
this.spinnerTimer = undefined;
|
||||
if (this.pendingNewState && this.pendingNewState !== runState) {
|
||||
this.renderState(this.pendingNewState, getCellIndex, this.pendingLastRunSuccess);
|
||||
this.pendingNewState = undefined;
|
||||
}
|
||||
}, RunStateRenderer.MIN_SPINNER_TIME);
|
||||
} else if (runState === NotebookCellExecutionState.Pending) {
|
||||
// Not spinning
|
||||
runStateTooltip = localize('runStatePending', "Pending");
|
||||
DOM.reset(this.element, renderIcon(Codicons.Codicon.clock));
|
||||
} else {
|
||||
this.element.innerText = '';
|
||||
}
|
||||
|
||||
if (!runState && typeof lastRunSuccess !== 'boolean') {
|
||||
DOM.hide(this.element);
|
||||
} else {
|
||||
this.element.style.display = 'flex';
|
||||
}
|
||||
|
||||
if (runStateTooltip) {
|
||||
this.element.setAttribute('title', runStateTooltip);
|
||||
}
|
||||
|
||||
this.lastRunState = runState;
|
||||
}
|
||||
}
|
||||
|
||||
export class ListTopCellToolbar extends Disposable {
|
||||
private topCellToolbar: HTMLElement;
|
||||
private menu: IMenu;
|
||||
|
|
Loading…
Reference in a new issue