Add CellProgressBar
fix issue where progress bar doesn't appear when collapsing input while cell is running. Also small cleanup to cell dnd in renderer #131808
This commit is contained in:
parent
8cb22ea15f
commit
333a215cb8
|
@ -15,8 +15,8 @@ import { cellRangesToIndexes, ICellRange } from 'vs/workbench/contrib/notebook/c
|
||||||
|
|
||||||
const $ = DOM.$;
|
const $ = DOM.$;
|
||||||
|
|
||||||
export const DRAGGING_CLASS = 'cell-dragging';
|
const DRAGGING_CLASS = 'cell-dragging';
|
||||||
export const GLOBAL_DRAG_CLASS = 'global-drag-active';
|
const GLOBAL_DRAG_CLASS = 'global-drag-active';
|
||||||
|
|
||||||
type DragImageProvider = () => HTMLElement;
|
type DragImageProvider = () => HTMLElement;
|
||||||
|
|
||||||
|
@ -97,6 +97,14 @@ export class CellDragAndDropController extends Disposable {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
renderElement(element: ICellViewModel, templateData: BaseCellRenderTemplate): void {
|
||||||
|
if (element.dragging) {
|
||||||
|
templateData.container.classList.add(DRAGGING_CLASS);
|
||||||
|
} else {
|
||||||
|
templateData.container.classList.remove(DRAGGING_CLASS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private setInsertIndicatorVisibility(visible: boolean) {
|
private setInsertIndicatorVisibility(visible: boolean) {
|
||||||
this.listInsertionIndicator.style.opacity = visible ? '1' : '0';
|
this.listInsertionIndicator.style.opacity = visible ? '1' : '0';
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
|
||||||
|
import { Disposable } from 'vs/base/common/lifecycle';
|
||||||
|
import { CellViewModelStateChangeEvent } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||||
|
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
|
||||||
|
import { NotebookCellExecutionState, NotebookCellInternalMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||||
|
|
||||||
|
export class CellProgressBar extends Disposable {
|
||||||
|
private readonly _progressBar: ProgressBar;
|
||||||
|
private readonly _collapsedProgressBar: ProgressBar;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
editorContainer: HTMLElement,
|
||||||
|
collapsedInputContainer: HTMLElement) {
|
||||||
|
super();
|
||||||
|
|
||||||
|
this._progressBar = this._register(new ProgressBar(editorContainer));
|
||||||
|
this._progressBar.hide();
|
||||||
|
|
||||||
|
this._collapsedProgressBar = this._register(new ProgressBar(collapsedInputContainer));
|
||||||
|
this._collapsedProgressBar.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateForInternalMetadata(element: CodeCellViewModel, internalMetadata: NotebookCellInternalMetadata): void {
|
||||||
|
const progressBar = element.isInputCollapsed ? this._collapsedProgressBar : this._progressBar;
|
||||||
|
if (internalMetadata.runState === NotebookCellExecutionState.Executing && !internalMetadata.isPaused) {
|
||||||
|
showProgressBar(progressBar);
|
||||||
|
} else {
|
||||||
|
progressBar.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateForCellState(e: CellViewModelStateChangeEvent, element: CodeCellViewModel): void {
|
||||||
|
if (e.inputCollapsedChanged) {
|
||||||
|
if (element.isInputCollapsed) {
|
||||||
|
this._progressBar.hide();
|
||||||
|
if (element.internalMetadata.runState === NotebookCellExecutionState.Executing) {
|
||||||
|
showProgressBar(this._collapsedProgressBar);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this._collapsedProgressBar.hide();
|
||||||
|
if (element.internalMetadata.runState === NotebookCellExecutionState.Executing) {
|
||||||
|
showProgressBar(this._progressBar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showProgressBar(progressBar: ProgressBar): void {
|
||||||
|
progressBar.infinite().show(500);
|
||||||
|
}
|
|
@ -3,27 +3,27 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import { FastDomNode } from 'vs/base/browser/fastDomNode';
|
||||||
import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
|
import { IMouseWheelEvent } from 'vs/base/browser/mouseEvent';
|
||||||
import { IListContextMenuEvent, IListEvent, IListMouseEvent } from 'vs/base/browser/ui/list/list';
|
import { IListContextMenuEvent, IListEvent, IListMouseEvent } from 'vs/base/browser/ui/list/list';
|
||||||
import { IListOptions, IListStyles } from 'vs/base/browser/ui/list/listWidget';
|
import { IListOptions, IListStyles } from 'vs/base/browser/ui/list/listWidget';
|
||||||
import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
|
|
||||||
import { ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
|
import { ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
|
||||||
import { Event } from 'vs/base/common/event';
|
import { Event } from 'vs/base/common/event';
|
||||||
import { FastDomNode } from 'vs/base/browser/fastDomNode';
|
|
||||||
import { DisposableStore } from 'vs/base/common/lifecycle';
|
import { DisposableStore } from 'vs/base/common/lifecycle';
|
||||||
import { ScrollEvent } from 'vs/base/common/scrollable';
|
import { ScrollEvent } from 'vs/base/common/scrollable';
|
||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||||
import { Range } from 'vs/editor/common/core/range';
|
import { Range } from 'vs/editor/common/core/range';
|
||||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||||
|
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||||
|
import type { INotebookCellActionContext } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
|
||||||
|
import { ICellOutputViewModel, ICellViewModel, IGenericCellViewModel, INotebookCellOutputLayoutInfo, INotebookEditorCreationOptions, IRenderOutput, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||||
|
import { CellProgressBar } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellProgressBar';
|
||||||
|
import { BetweenCellToolbar, CellTitleToolbarPart } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars';
|
||||||
|
import { CellEditorStatusBar } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellWidgets';
|
||||||
import { CellViewModel, NotebookViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel';
|
import { CellViewModel, NotebookViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel';
|
||||||
import { IOutputItemDto } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
import { IOutputItemDto } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||||
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
|
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
|
||||||
import { CellEditorStatusBar } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellWidgets';
|
|
||||||
import { ICellOutputViewModel, ICellViewModel, IGenericCellViewModel, INotebookCellOutputLayoutInfo, INotebookEditorCreationOptions, IRenderOutput, RenderOutputType } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
|
||||||
import type { INotebookCellActionContext } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
|
|
||||||
import { BetweenCellToolbar, CellTitleToolbarPart } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars';
|
|
||||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
|
||||||
|
|
||||||
export interface INotebookCellList {
|
export interface INotebookCellList {
|
||||||
isDisposed: boolean;
|
isDisposed: boolean;
|
||||||
|
@ -130,8 +130,7 @@ export interface CodeCellRenderTemplate extends BaseCellRenderTemplate {
|
||||||
outputShowMoreContainer: FastDomNode<HTMLElement>;
|
outputShowMoreContainer: FastDomNode<HTMLElement>;
|
||||||
focusSinkElement: HTMLElement;
|
focusSinkElement: HTMLElement;
|
||||||
editor: ICodeEditor;
|
editor: ICodeEditor;
|
||||||
progressBar: ProgressBar;
|
progressBar: CellProgressBar;
|
||||||
collapsedProgressBar: ProgressBar;
|
|
||||||
focusIndicatorRight: FastDomNode<HTMLElement>;
|
focusIndicatorRight: FastDomNode<HTMLElement>;
|
||||||
focusIndicatorBottom: FastDomNode<HTMLElement>;
|
focusIndicatorBottom: FastDomNode<HTMLElement>;
|
||||||
dragHandle: FastDomNode<HTMLElement>;
|
dragHandle: FastDomNode<HTMLElement>;
|
||||||
|
|
|
@ -7,7 +7,6 @@ import { getPixelRatio, getZoomLevel } from 'vs/base/browser/browser';
|
||||||
import * as DOM from 'vs/base/browser/dom';
|
import * as DOM from 'vs/base/browser/dom';
|
||||||
import { FastDomNode } from 'vs/base/browser/fastDomNode';
|
import { FastDomNode } from 'vs/base/browser/fastDomNode';
|
||||||
import { IListRenderer, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
|
import { IListRenderer, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
|
||||||
import { ProgressBar } from 'vs/base/browser/ui/progressbar/progressbar';
|
|
||||||
import { IAction } from 'vs/base/common/actions';
|
import { IAction } from 'vs/base/common/actions';
|
||||||
import { Codicon, CSSIcon } from 'vs/base/common/codicons';
|
import { Codicon, CSSIcon } from 'vs/base/common/codicons';
|
||||||
import { Color } from 'vs/base/common/color';
|
import { Color } from 'vs/base/common/color';
|
||||||
|
@ -36,8 +35,9 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||||
import { INotebookCellActionContext, INotebookCellToolbarActionContext } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
|
import { INotebookCellActionContext, INotebookCellToolbarActionContext } from 'vs/workbench/contrib/notebook/browser/controller/coreActions';
|
||||||
import { CodeCellLayoutInfo, EXPAND_CELL_OUTPUT_COMMAND_ID, ICellViewModel, INotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
import { CodeCellLayoutInfo, EXPAND_CELL_OUTPUT_COMMAND_ID, ICellViewModel, INotebookEditorDelegate } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||||
import { CellContextKeyManager } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellContextKeys';
|
import { CellContextKeyManager } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellContextKeys';
|
||||||
import { CellDragAndDropController, DRAGGING_CLASS } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellDnd';
|
import { CellDragAndDropController } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellDnd';
|
||||||
import { CellEditorOptions } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellEditorOptions';
|
import { CellEditorOptions } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellEditorOptions';
|
||||||
|
import { CellProgressBar } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellProgressBar';
|
||||||
import { BetweenCellToolbar, CellTitleToolbarPart } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars';
|
import { BetweenCellToolbar, CellTitleToolbarPart } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellToolbars';
|
||||||
import { CellEditorStatusBar } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellWidgets';
|
import { CellEditorStatusBar } from 'vs/workbench/contrib/notebook/browser/view/cellParts/cellWidgets';
|
||||||
import { CodeCell } from 'vs/workbench/contrib/notebook/browser/view/cellParts/codeCell';
|
import { CodeCell } from 'vs/workbench/contrib/notebook/browser/view/cellParts/codeCell';
|
||||||
|
@ -47,7 +47,7 @@ import { BaseCellRenderTemplate, CodeCellRenderTemplate, MarkdownCellRenderTempl
|
||||||
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
|
import { CodeCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel';
|
||||||
import { MarkupCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel';
|
import { MarkupCellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/markupCellViewModel';
|
||||||
import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel';
|
import { CellViewModel } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel';
|
||||||
import { CellKind, NotebookCellExecutionState, NotebookCellInternalMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
import { CellKind, NotebookCellInternalMetadata } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||||
|
|
||||||
const $ = DOM.$;
|
const $ = DOM.$;
|
||||||
|
|
||||||
|
@ -157,11 +157,7 @@ abstract class AbstractCellRenderer {
|
||||||
|
|
||||||
generateCellTopDecorations();
|
generateCellTopDecorations();
|
||||||
|
|
||||||
if (element.dragging) {
|
this.dndController?.renderElement(element, templateData);
|
||||||
templateData.container.classList.add(DRAGGING_CLASS);
|
|
||||||
} else {
|
|
||||||
templateData.container.classList.remove(DRAGGING_CLASS);
|
|
||||||
}
|
|
||||||
|
|
||||||
templateData.elementDisposables.add(templateData.instantiationService.createInstance(CellContextKeyManager, this.notebookEditor, element));
|
templateData.elementDisposables.add(templateData.instantiationService.createInstance(CellContextKeyManager, this.notebookEditor, element));
|
||||||
}
|
}
|
||||||
|
@ -484,13 +480,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
|
||||||
|
|
||||||
templateDisposables.add(editor);
|
templateDisposables.add(editor);
|
||||||
|
|
||||||
const progressBar = new ProgressBar(editorPart);
|
const progressBar = templateDisposables.add(new CellProgressBar(editorPart, cellInputCollapsedContainer));
|
||||||
progressBar.hide();
|
|
||||||
templateDisposables.add(progressBar);
|
|
||||||
|
|
||||||
const collapsedProgressBar = new ProgressBar(cellInputCollapsedContainer);
|
|
||||||
collapsedProgressBar.hide();
|
|
||||||
templateDisposables.add(collapsedProgressBar);
|
|
||||||
|
|
||||||
const statusBar = templateDisposables.add(this.instantiationService.createInstance(CellEditorStatusBar, editorPart));
|
const statusBar = templateDisposables.add(this.instantiationService.createInstance(CellEditorStatusBar, editorPart));
|
||||||
|
|
||||||
|
@ -527,7 +517,6 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
|
||||||
decorationContainer,
|
decorationContainer,
|
||||||
cellContainer,
|
cellContainer,
|
||||||
progressBar,
|
progressBar,
|
||||||
collapsedProgressBar,
|
|
||||||
statusBar,
|
statusBar,
|
||||||
focusIndicatorLeft: focusIndicator,
|
focusIndicatorLeft: focusIndicator,
|
||||||
focusIndicatorRight,
|
focusIndicatorRight,
|
||||||
|
@ -664,13 +653,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
|
||||||
|
|
||||||
const internalMetadata = element.internalMetadata;
|
const internalMetadata = element.internalMetadata;
|
||||||
this.updateExecutionOrder(internalMetadata, templateData);
|
this.updateExecutionOrder(internalMetadata, templateData);
|
||||||
|
templateData.progressBar.updateForInternalMetadata(element, internalMetadata);
|
||||||
const progressBar = element.isInputCollapsed ? templateData.collapsedProgressBar : templateData.progressBar;
|
|
||||||
if (internalMetadata.runState === NotebookCellExecutionState.Executing && !internalMetadata.isPaused) {
|
|
||||||
progressBar.infinite().show(500);
|
|
||||||
} else {
|
|
||||||
progressBar.hide();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateForKernel(element: CodeCellViewModel, templateData: CodeCellRenderTemplate): void {
|
private updateForKernel(element: CodeCellViewModel, templateData: CodeCellRenderTemplate): void {
|
||||||
|
@ -779,13 +762,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
|
||||||
cellEditorOptions.setLineNumbers(element.lineNumbers);
|
cellEditorOptions.setLineNumbers(element.lineNumbers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.inputCollapsedChanged) {
|
templateData.progressBar.updateForCellState(e, element);
|
||||||
if (element.isInputCollapsed) {
|
|
||||||
templateData.progressBar.hide();
|
|
||||||
} else {
|
|
||||||
templateData.collapsedProgressBar.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.updateForOutputs(element, templateData);
|
this.updateForOutputs(element, templateData);
|
||||||
|
|
Loading…
Reference in a new issue