Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DocumentManager

The document manager.

Notes

The document manager is used to register model and widget creators, and the file browser uses the document manager to create widgets. The document manager maintains a context for each path and model type that is open, and a list of widgets for each context. The document manager is in control of the proper closing and disposal of the widgets and contexts.

Hierarchy

  • DocumentManager

Implements

Index

Constructors

constructor

  • Construct a new document manager.

    Parameters

    Returns DocumentManager

Properties

Private _activateRequested

_activateRequested: any

Private _autosave

_autosave: any

Private _autosaveInterval

_autosaveInterval: any

Private _collaborative

_collaborative: any

Private _contexts

_contexts: any

Private _contextsForPath

_contextsForPath: any

Get the contexts for a given path.

Notes

There may be more than one context for a given path if the path is open with multiple model factories (for example, a notebook can be open with a notebook model factory and a text model factory).

Private _createContext

_createContext: any

Create a context from a path and a model factory.

Private _createOrOpenDocument

_createOrOpenDocument: any

Creates a new document, or loads one from disk, depending on the which argument. If which==='create', then it creates a new document. If which==='open', then it loads the document from disk.

The two cases differ in how the document context is handled, but the creation of the widget and launching of the kernel are identical.

Private _dialogs

_dialogs: any

Private _docProviderFactory

_docProviderFactory: any

Private _findContext

_findContext: any

Find a context for a given path and factory name.

Private _isDisposed

_isDisposed: any

Private _lastModifiedCheckMargin

_lastModifiedCheckMargin: any

Private _onActivateRequested

_onActivateRequested: any

Handle an activateRequested signal from the widget manager.

Private _onContextDisposed

_onContextDisposed: any

Handle a context disposal.

Private _opener

_opener: any

Private _setBusy

_setBusy: any

Private _when

_when: any

Private _widgetFactoryFor

_widgetFactoryFor: any

Get the widget factory for a given widget name.

Private _widgetManager

_widgetManager: any

Readonly registry

The registry used by the manager.

Readonly services

services: IManager

The service manager used by the manager.

Protected translator

translator: ITranslator

Accessors

activateRequested

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

    Returns ISignal<this, string>

autosave

  • get autosave(): boolean
  • set autosave(value: boolean): void
  • Whether to autosave documents.

    Returns boolean

  • Whether to autosave documents.

    Parameters

    • value: boolean

    Returns void

autosaveInterval

  • get autosaveInterval(): number
  • set autosaveInterval(value: number): void
  • Determines the time interval for autosave in seconds.

    Returns number

  • Determines the time interval for autosave in seconds.

    Parameters

    • value: number

    Returns void

isDisposed

  • get isDisposed(): boolean
  • Get whether the document manager has been disposed.

    Returns boolean

lastModifiedCheckMargin

  • get lastModifiedCheckMargin(): number
  • set lastModifiedCheckMargin(value: number): void
  • Defines max acceptable difference, in milliseconds, between last modified timestamps on disk and client

    Returns number

  • Defines max acceptable difference, in milliseconds, between last modified timestamps on disk and client

    Parameters

    • value: number

    Returns void

Methods

cloneWidget

  • Clone a widget.

    Parameters

    • widget: Widget

      The source widget.

    Returns IDocumentWidget<Widget, IModel>

    A new widget or undefined.

    Notes

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

closeAll

  • closeAll(): Promise<void>
  • Close all of the open documents.

    Returns Promise<void>

    A promise resolving when the widgets are closed.

closeFile

  • closeFile(path: string): Promise<void>
  • Close the widgets associated with a given path.

    Parameters

    • path: string

      The target path.

    Returns Promise<void>

    A promise resolving when the widgets are closed.

contextForWidget

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

    Parameters

    • widget: Widget

      The widget of interest.

    Returns Context

    The context associated with the widget, or undefined if no such context exists.

copy

  • copy(fromFile: string, toDir: string): Promise<IModel>
  • Copy a file.

    Parameters

    • fromFile: string

      The full path of the original file.

    • toDir: string

      The full path to the target directory.

    Returns Promise<IModel>

    A promise which resolves to the contents of the file.

createNew

  • createNew(path: string, widgetName?: string, kernel?: Partial<IModel>): Widget
  • Create a new file and return the widget used to view it.

    Parameters

    • path: string

      The file path to create.

    • Optional widgetName: string

      The name of the widget factory to use. 'default' will use the default widget.

    • Optional kernel: Partial<IModel>

      An optional kernel name/id to override the default.

    Returns Widget

    The created widget, or undefined.

    Notes

    This function will return undefined if a valid widget factory cannot be found.

deleteFile

  • deleteFile(path: string): Promise<void>
  • Delete a file.

    Parameters

    • path: string

      The full path to the file to be deleted.

    Returns Promise<void>

    A promise which resolves when the file is deleted.

    Notes

    If there is a running session associated with the file and no other sessions are using the kernel, the session will be shut down.

dispose

  • dispose(): void
  • Dispose of the resources held by the document manager.

    Returns void

findWidget

  • See if a widget already exists for the given path and widget name.

    Parameters

    • path: string

      The file path to use.

    • Optional widgetName: string

      The name of the widget factory to use. 'default' will use the default widget.

    Returns IDocumentWidget<Widget, IModel>

    The found widget, or undefined.

    Notes

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

newUntitled

  • Create a new untitled file.

    Parameters

    Returns Promise<IModel>

open

  • Open a file and return the widget used to view it.

    Parameters

    • path: string

      The file path to open.

    • Optional widgetName: string

      The name of the widget factory to use. 'default' will use the default widget.

    • Optional kernel: Partial<IModel>

      An optional kernel name/id to override the default.

    • Optional options: IOpenOptions

    Returns IDocumentWidget<Widget, IModel>

    The created widget, or undefined.

    Notes

    This function will return undefined if a valid widget factory cannot be found.

openOrReveal

  • Open a file and return the widget used to view it. Reveals an already existing editor.

    Parameters

    • path: string

      The file path to open.

    • Optional widgetName: string

      The name of the widget factory to use. 'default' will use the default widget.

    • Optional kernel: Partial<IModel>

      An optional kernel name/id to override the default.

    • Optional options: IOpenOptions

    Returns IDocumentWidget<Widget, IModel>

    The created widget, or undefined.

    Notes

    This function will return undefined if a valid widget factory cannot be found.

overwrite

  • overwrite(oldPath: string, newPath: string): Promise<IModel>
  • Overwrite a file.

    Parameters

    • oldPath: string

      The full path to the original file.

    • newPath: string

      The full path to the new file.

    Returns Promise<IModel>

    A promise containing the new file contents model.

rename

  • rename(oldPath: string, newPath: string): Promise<IModel>
  • Rename a file or directory.

    Parameters

    • oldPath: string

      The full path to the original file.

    • newPath: string

      The full path to the new file.

    Returns Promise<IModel>

    A promise containing the new file contents model. The promise will reject if the newPath already exists. Use overwrite to overwrite a file.

Generated using TypeDoc