1 | import { IChangedArgs } from '@jupyterlab/coreutils';
|
2 | import { DocumentRegistry, IDocumentWidget } from '@jupyterlab/docregistry';
|
3 | import { ITranslator } from '@jupyterlab/translation';
|
4 | import { IDisposable } from '@lumino/disposable';
|
5 | import { IMessageHandler, Message } from '@lumino/messaging';
|
6 | import { ISignal } from '@lumino/signaling';
|
7 | import { Widget } from '@lumino/widgets';
|
8 | import { IRecentsManager } from './tokens';
|
9 |
|
10 |
|
11 |
|
12 | export declare class DocumentWidgetManager implements IDisposable {
|
13 | |
14 |
|
15 |
|
16 | constructor(options: DocumentWidgetManager.IOptions);
|
17 | /**
|
18 | * A signal emitted when one of the documents is activated.
|
19 | */
|
20 | get activateRequested(): ISignal<this, string>;
|
21 | /**
|
22 | * Whether to ask confirmation to close a tab or not.
|
23 | */
|
24 | get confirmClosingDocument(): boolean;
|
25 | set confirmClosingDocument(v: boolean);
|
26 | /**
|
27 | * Signal triggered when an attribute changes.
|
28 | */
|
29 | get stateChanged(): ISignal<DocumentWidgetManager, IChangedArgs<any>>;
|
30 | /**
|
31 | * Test whether the document widget manager is disposed.
|
32 | */
|
33 | get isDisposed(): boolean;
|
34 | /**
|
35 | * Dispose of the resources used by the widget manager.
|
36 | */
|
37 | dispose(): void;
|
38 | /**
|
39 | * Create a widget for a document and handle its lifecycle.
|
40 | *
|
41 | * @param factory - The widget factory.
|
42 | *
|
43 | * @param context - The document context object.
|
44 | *
|
45 | * @returns A widget created by the factory.
|
46 | *
|
47 | * @throws If the factory is not registered.
|
48 | */
|
49 | createWidget(factory: DocumentRegistry.WidgetFactory, context: DocumentRegistry.Context): IDocumentWidget;
|
50 | /**
|
51 | * When a new widget is created, we need to hook it up
|
52 | * with some signals, update the widget extensions (for
|
53 | * this kind of widget) in the docregistry, among
|
54 | * other things.
|
55 | */
|
56 | private _initializeWidget;
|
57 | /**
|
58 | * Install the message hook for the widget and add to list
|
59 | * of known widgets.
|
60 | *
|
61 | * @param context - The document context object.
|
62 | *
|
63 | * @param widget - The widget to adopt.
|
64 | */
|
65 | adoptWidget(context: DocumentRegistry.Context, widget: IDocumentWidget): void;
|
66 | /**
|
67 | * See if a widget already exists for the given context and widget name.
|
68 | *
|
69 | * @param context - The document context object.
|
70 | *
|
71 | * @returns The found widget, or `undefined`.
|
72 | *
|
73 | * #### Notes
|
74 | * This can be used to use an existing widget instead of opening
|
75 | * a new widget.
|
76 | */
|
77 | findWidget(context: DocumentRegistry.Context, widgetName: string): IDocumentWidget | undefined;
|
78 | /**
|
79 | * Get the document context for a widget.
|
80 | *
|
81 | * @param widget - The widget of interest.
|
82 | *
|
83 | * @returns The context associated with the widget, or `undefined`.
|
84 | */
|
85 | contextForWidget(widget: Widget): DocumentRegistry.Context | undefined;
|
86 | /**
|
87 | * Clone a widget.
|
88 | *
|
89 | * @param widget - The source widget.
|
90 | *
|
91 | * @returns A new widget or `undefined`.
|
92 | *
|
93 | * #### Notes
|
94 | * Uses the same widget factory and context as the source, or throws
|
95 | * if the source widget is not managed by this manager.
|
96 | */
|
97 | cloneWidget(widget: Widget): IDocumentWidget | undefined;
|
98 | /**
|
99 | * Close the widgets associated with a given context.
|
100 | *
|
101 | * @param context - The document context object.
|
102 | */
|
103 | closeWidgets(context: DocumentRegistry.Context): Promise<void>;
|
104 | /**
|
105 | * Dispose of the widgets associated with a given context
|
106 | * regardless of the widget's dirty state.
|
107 | *
|
108 | * @param context - The document context object.
|
109 | */
|
110 | deleteWidgets(context: DocumentRegistry.Context): Promise<void>;
|
111 | /**
|
112 | * Filter a message sent to a message handler.
|
113 | *
|
114 | * @param handler - The target handler of the message.
|
115 | *
|
116 | * @param msg - The message dispatched to the handler.
|
117 | *
|
118 | * @returns `false` if the message should be filtered, of `true`
|
119 | * if the message should be dispatched to the handler as normal.
|
120 | */
|
121 | messageHook(handler: IMessageHandler, msg: Message): boolean;
|
122 | /**
|
123 | * Set the caption for widget title.
|
124 | *
|
125 | * @param widget - The target widget.
|
126 | */
|
127 | protected setCaption(widget: Widget): Promise<void>;
|
128 | /**
|
129 | * Handle `'close-request'` messages.
|
130 | *
|
131 | * @param widget - The target widget.
|
132 | *
|
133 | * @returns A promise that resolves with whether the widget was closed.
|
134 | */
|
135 | protected onClose(widget: Widget): Promise<boolean>;
|
136 | /**
|
137 | * Dispose of widget regardless of widget's dirty state.
|
138 | *
|
139 | * @param widget - The target widget.
|
140 | */
|
141 | protected onDelete(widget: Widget): Promise<void>;
|
142 | /**
|
143 | * Record the activated file, and its parent directory, as recently opened.
|
144 | */
|
145 | private _recordAsRecentlyOpened;
|
146 | /**
|
147 | * Record the activated file, and its parent directory, as recently opened.
|
148 | */
|
149 | private _recordAsRecentlyClosed;
|
150 | /**
|
151 | * Ask the user whether to close an unsaved file.
|
152 | */
|
153 | private _maybeClose;
|
154 | /**
|
155 | * Handle the disposal of a widget.
|
156 | */
|
157 | private _widgetDisposed;
|
158 | /**
|
159 | * Handle the disposal of a widget.
|
160 | */
|
161 | private _onWidgetDisposed;
|
162 | /**
|
163 | * Handle a file changed signal for a context.
|
164 | */
|
165 | private _onFileChanged;
|
166 | /**
|
167 | * Handle a path changed signal for a context.
|
168 | */
|
169 | private _onPathChanged;
|
170 | protected translator: ITranslator;
|
171 | private _registry;
|
172 | private _activateRequested;
|
173 | private _confirmClosingTab;
|
174 | private _isDisposed;
|
175 | private _stateChanged;
|
176 | private _recentsManager;
|
177 | }
|
178 | /**
|
179 | * A namespace for document widget manager statics.
|
180 | */
|
181 | export declare namespace DocumentWidgetManager {
|
182 | |
183 |
|
184 |
|
185 | interface IOptions {
|
186 | |
187 |
|
188 |
|
189 | registry: DocumentRegistry;
|
190 | |
191 |
|
192 |
|
193 | recentsManager?: IRecentsManager;
|
194 | |
195 |
|
196 |
|
197 | translator?: ITranslator;
|
198 | }
|
199 | }
|