Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DocumentWidgetManager

A class that maintains the lifecycle of file-backed widgets. A namespace for document widget manager statics.

Hierarchy

  • DocumentWidgetManager

Implements

  • IDisposable

Index

Constructors

constructor

Properties

Private _activateRequested

_activateRequested: Signal<this, string> = new Signal<this, string>(this)

Private _isDisposed

_isDisposed: boolean = false

Private _registry

_registry: DocumentRegistry

Accessors

activateRequested

  • get activateRequested(): ISignal<this, string>
  • A signal emitted when one of the documents is activated.

    Returns ISignal<this, string>

isDisposed

  • get isDisposed(): boolean
  • Test whether the document widget manager is disposed.

    Returns boolean

Methods

Private _initializeWidget

  • _initializeWidget(widget: IDocumentWidget, factory: DocumentRegistry.WidgetFactory, context: DocumentRegistry.Context): void
  • When a new widget is created, we need to hook it up with some signals, update the widget extensions (for this kind of widget) in the docregistry, among other things.

    Parameters

    • widget: IDocumentWidget
    • factory: DocumentRegistry.WidgetFactory
    • context: DocumentRegistry.Context

    Returns void

Private _maybeClose

  • _maybeClose(widget: Widget): Promise<boolean>
  • Ask the user whether to close an unsaved file.

    Parameters

    • widget: Widget

    Returns Promise<boolean>

Private _onFileChanged

  • _onFileChanged(context: DocumentRegistry.Context): void
  • Handle a file changed signal for a context.

    Parameters

    • context: DocumentRegistry.Context

    Returns void

Private _onPathChanged

  • _onPathChanged(context: DocumentRegistry.Context): void
  • Handle a path changed signal for a context.

    Parameters

    • context: DocumentRegistry.Context

    Returns void

Private _onWidgetDisposed

  • _onWidgetDisposed(widget: Widget): void
  • Handle the disposal of a widget.

    Parameters

    • widget: Widget

    Returns void

Private _widgetDisposed

  • _widgetDisposed(widget: Widget): void
  • Handle the disposal of a widget.

    Parameters

    • widget: Widget

    Returns void

adoptWidget

  • adoptWidget(context: DocumentRegistry.Context, widget: IDocumentWidget): void
  • Install the message hook for the widget and add to list of known widgets.

    Parameters

    • context: DocumentRegistry.Context

      The document context object.

    • widget: IDocumentWidget

      The widget to adopt.

    Returns void

cloneWidget

  • cloneWidget(widget: Widget): IDocumentWidget | undefined
  • Clone a widget.

    Parameters

    • widget: Widget

      The source widget.

    Returns IDocumentWidget | undefined

    A new widget or undefined.

    Notes

    Uses the same widget factory and context as the source, or throws if the source widget is not managed by this manager.

closeWidgets

  • closeWidgets(context: DocumentRegistry.Context): Promise<void>
  • Close the widgets associated with a given context.

    Parameters

    • context: DocumentRegistry.Context

      The document context object.

    Returns Promise<void>

contextForWidget

  • contextForWidget(widget: Widget): DocumentRegistry.Context | undefined
  • Get the document context for a widget.

    Parameters

    • widget: Widget

      The widget of interest.

    Returns DocumentRegistry.Context | undefined

    The context associated with the widget, or undefined.

createWidget

  • createWidget(factory: DocumentRegistry.WidgetFactory, context: DocumentRegistry.Context): IDocumentWidget
  • Create a widget for a document and handle its lifecycle.

    throws

    If the factory is not registered.

    Parameters

    • factory: DocumentRegistry.WidgetFactory

      The widget factory.

    • context: DocumentRegistry.Context

      The document context object.

    Returns IDocumentWidget

    A widget created by the factory.

deleteWidgets

  • deleteWidgets(context: DocumentRegistry.Context): Promise<void>
  • Dispose of the widgets associated with a given context regardless of the widget's dirty state.

    Parameters

    • context: DocumentRegistry.Context

      The document context object.

    Returns Promise<void>

dispose

  • dispose(): void
  • Dispose of the resources used by the widget manager.

    Returns void

findWidget

  • findWidget(context: DocumentRegistry.Context, widgetName: string): IDocumentWidget | undefined
  • See if a widget already exists for the given context and widget name.

    Parameters

    • context: DocumentRegistry.Context

      The document context object.

    • widgetName: string

    Returns IDocumentWidget | undefined

    The found widget, or undefined.

    Notes

    This can be used to use an existing widget instead of opening a new widget.

messageHook

  • messageHook(handler: IMessageHandler, msg: Message): boolean
  • Filter a message sent to a message handler.

    Parameters

    • handler: IMessageHandler

      The target handler of the message.

    • msg: Message

      The message dispatched to the handler.

    Returns boolean

    false if the message should be filtered, of true if the message should be dispatched to the handler as normal.

Protected onClose

  • onClose(widget: Widget): Promise<boolean>
  • Handle 'close-request' messages.

    Parameters

    • widget: Widget

      The target widget.

    Returns Promise<boolean>

    A promise that resolves with whether the widget was closed.

Protected onDelete

  • onDelete(widget: Widget): Promise<void>
  • Dispose of widget regardless of widget's dirty state.

    Parameters

    • widget: Widget

      The target widget.

    Returns Promise<void>

Protected setCaption

  • setCaption(widget: Widget): Promise<void>
  • Set the caption for widget title.

    Parameters

    • widget: Widget

      The target widget.

    Returns Promise<void>

Generated using TypeDoc