Options
All
  • Public
  • Public/Protected
  • All
Menu

The document manager. A namespace for document manager statics.

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

Implements

  • IDisposable

Index

Constructors

constructor

Properties

Private _activateRequested

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

Private _contexts

_contexts: IContext[] = []

Private _isDisposed

_isDisposed: boolean = false

Private _modelDBFactory

_modelDBFactory: IFactory | null = null

Private _opener

_opener: IWidgetOpener

Private _widgetManager

_widgetManager: DocumentWidgetManager

registry

The registry used by the manager.

services

services: IManager

The service manager used by the manager.

Accessors

activateRequested

  • get activateRequested(): ISignal<this, string>

isDisposed

  • get isDisposed(): boolean

Methods

Private _contextForPath

  • _contextForPath(path: string): IContext | undefined

Private _createContext

Private _createOrOpenDocument

  • _createOrOpenDocument(which: "open" | "create", path: string, widgetName?: string, kernel?: Partial<IModel>): Widget | undefined
  • 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.

    Parameters

    • which: "open" | "create"
    • path: string
    • Default value widgetName: string = "default"
    • Optional kernel: Partial<IModel>

    Returns Widget | undefined

Private _findContext

  • _findContext(path: string, factoryName: string): IContext | undefined
  • Find a context for a given path and factory name.

    Parameters

    • path: string
    • factoryName: string

    Returns IContext | undefined

Private _onActivateRequested

Private _onContextDisposed

  • _onContextDisposed(context: IContext): void

Private _widgetFactoryFor

  • _widgetFactoryFor(path: string, widgetName: string): WidgetFactory | undefined

cloneWidget

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

    Parameters

    • widget: Widget

      The source widget.

    Returns Widget | undefined

    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>

closeFile

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

    Parameters

    • path: string

      The target path.

    Returns Promise<void>

contextForWidget

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

    Parameters

    • widget: Widget

      The widget of interest.

    Returns Context | undefined

    The context associated with the widget, or undefined.

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.

    • Default value widgetName: string = "default"

      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

findWidget

  • findWidget(path: string, widgetName?: string): Widget | undefined
  • See if a widget already exists for the given path and widget name.

    Parameters

    • path: string

      The file path to use.

    • Default value widgetName: string = "default"

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

    Returns Widget | undefined

    The found widget, or undefined.

    Notes

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

newUntitled

open

  • open(path: string, widgetName?: string, kernel?: Partial<IModel>): Widget | undefined
  • Open a file and return the widget used to view it.

    Parameters

    • path: string

      The file path to open.

    • Default value widgetName: string = "default"

      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 | undefined

    The created widget, or undefined.

    Notes

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

openOrReveal

  • openOrReveal(path: string, widgetName?: string, kernel?: Partial<IModel>): Widget | undefined
  • Open a file and return the widget used to view it. Reveals an already existing editor.

    Parameters

    • path: string

      The file path to open.

    • Default value widgetName: string = "default"

      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 | undefined

    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