|
@@ -204,12 +204,6 @@ class DocumentWidgetManager {
|
|
protected onClose(widget: Widget): void {
|
|
protected onClose(widget: Widget): void {
|
|
// Handle dirty state.
|
|
// Handle dirty state.
|
|
this._maybeClose(widget).then(result => {
|
|
this._maybeClose(widget).then(result => {
|
|
- if (result) {
|
|
|
|
- // Perform close tasks.
|
|
|
|
- return this._actuallyClose(widget);
|
|
|
|
- }
|
|
|
|
- return result;
|
|
|
|
- }).then(result => {
|
|
|
|
if (result) {
|
|
if (result) {
|
|
this._closeGuard = true;
|
|
this._closeGuard = true;
|
|
widget.close();
|
|
widget.close();
|
|
@@ -245,41 +239,6 @@ class DocumentWidgetManager {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * Perform closing tasks for the widget.
|
|
|
|
- */
|
|
|
|
- private _actuallyClose(widget: Widget): Promise<boolean> {
|
|
|
|
- let id = Private.idProperty.get(widget);
|
|
|
|
- let context = this._contextManager.getContext(id);
|
|
|
|
- // Check for a dangling kernel.
|
|
|
|
- let widgets = this._widgets[id];
|
|
|
|
- let kernelId = context.kernel ? context.kernel.id : '';
|
|
|
|
- if (!kernelId || widgets.length > 1) {
|
|
|
|
- return Promise.resolve(true);
|
|
|
|
- }
|
|
|
|
- for (let otherId in this._widgets) {
|
|
|
|
- if (otherId === id) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- let otherContext = this._contextManager.getContext(id);
|
|
|
|
- let kId = otherContext.kernel || otherContext.kernel.id;
|
|
|
|
- if (kId === kernelId) {
|
|
|
|
- return Promise.resolve(true);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- return showDialog({
|
|
|
|
- title: 'Shut down kernel?',
|
|
|
|
- body: `Shut down ${context.kernel.name}?`,
|
|
|
|
- host: widget.node
|
|
|
|
- }).then(value => {
|
|
|
|
- if (value && value.text === 'OK') {
|
|
|
|
- return context.changeKernel(null);
|
|
|
|
- }
|
|
|
|
- }).then(() => {
|
|
|
|
- return true;
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private _closeGuard = false;
|
|
private _closeGuard = false;
|
|
private _contextManager: ContextManager = null;
|
|
private _contextManager: ContextManager = null;
|
|
private _registry: DocumentRegistry = null;
|
|
private _registry: DocumentRegistry = null;
|