|
@@ -208,6 +208,19 @@ class DocumentWidgetManager implements IDisposable {
|
|
|
).then(() => undefined);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Dispose of the widgets associated with a given context
|
|
|
+ * regardless of the widget's dirty state.
|
|
|
+ *
|
|
|
+ * @param context - The document context object.
|
|
|
+ */
|
|
|
+ deleteWidgets(context: DocumentRegistry.Context): Promise<void> {
|
|
|
+ let widgets = Private.widgetsProperty.get(context);
|
|
|
+ return Promise.all(
|
|
|
+ toArray(map(widgets, widget => this.onDelete(widget)))
|
|
|
+ ).then(() => undefined);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Filter a message sent to a message handler.
|
|
|
*
|
|
@@ -292,6 +305,16 @@ class DocumentWidgetManager implements IDisposable {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Dispose of widget regardless of widget's dirty state.
|
|
|
+ *
|
|
|
+ * @param widget - The target widget.
|
|
|
+ */
|
|
|
+ protected onDelete(widget: Widget): Promise<void> {
|
|
|
+ widget.dispose();
|
|
|
+ return Promise.resolve(void 0);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Ask the user whether to close an unsaved file.
|
|
|
*/
|