Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ApplicationShell

The application shell manages the top-level widgets of the application. Use this class to add, remove, or activate a widget. The namespace for ApplicationShell class statics.

Hierarchy

  • Widget
    • ApplicationShell

Implements

  • IMessageHandler
  • IObservableDisposable

Index

Namespaces

Enumerations

Classes

Interfaces

Type aliases

Constructors

Properties

Accessors

Methods

Object literals

Type aliases

Static Area

Area: "main" | "top" | "left" | "right" | "bottom"

The areas of the application shell where widgets can reside.

Static OpenToSideMode

OpenToSideMode: "open-to-left" | "open-to-right"

Whether a widget should be opened to the side tab bar relatively to the reference widget.

Constructors

constructor

Properties

Private Readonly activationTimeout

activationTimeout: 2000 = 2000

Readonly activeChanged

activeChanged: Signal<this, IChangedArgs<Widget>> = new Signal<this, FocusTracker.IChangedArgs<Widget>>(this)

A signal emitted whenever the activeWidget property is changed.

deprecated

since 0.11.0, use onDidChangeActiveWidget instead

Protected Readonly applicationStateService

applicationStateService: FrontendApplicationStateService

Readonly bottomPanel

bottomPanel: TheiaDockPanel

The dock panel in the bottom shell area. In contrast to the main panel, the bottom panel can be collapsed and expanded.

Protected Readonly contextKeyService

contextKeyService: ContextKeyService

Readonly currentChanged

currentChanged: Signal<this, IChangedArgs<Widget>> = new Signal<this, FocusTracker.IChangedArgs<Widget>>(this)

A signal emitted whenever the currentWidget property is changed.

deprecated

since 0.11.0, use onDidChangeCurrentWidget instead

Readonly dataset

dataset: DOMStringMap

The dataset for the widget's DOM node.

Readonly disposed

disposed: ISignal<this, void>

A signal emitted when the widget is disposed.

Protected dockPanelRendererFactory

dockPanelRendererFactory: () => DockPanelRenderer

Type declaration

Private Optional dragState

dragState: WidgetDragState

id

id: string

Set the id of the widget's DOM node.

Readonly isAttached

isAttached: boolean

Test whether the widget's node is attached to the DOM.

Readonly isDisposed

isDisposed: boolean

Test whether the widget has been disposed.

Readonly isHidden

isHidden: boolean

Test whether the widget is explicitly hidden.

Readonly isVisible

isVisible: boolean

Test whether the widget is visible.

Notes

A widget is visible when it is attached to the DOM, is not explicitly hidden, and has no explicitly hidden ancestors.

layout

layout: Layout | null

Set the layout for the widget.

Notes

The layout is single-use only. It cannot be changed after the first assignment.

The layout is disposed automatically when the widget is disposed.

Readonly leftPanelHandler

leftPanelHandler: SidePanelHandler

Handler for the left side panel. The primary application views go here, such as the file explorer and the git view.

Readonly mainPanel

mainPanel: TheiaDockPanel

The dock panel in the main shell area. This is where editors usually go to.

Readonly node

node: HTMLElement

Get the DOM node owned by the widget.

Readonly onDidAddWidget

onDidAddWidget: Event<Widget> = this.onDidAddWidgetEmitter.event

Protected Readonly onDidAddWidgetEmitter

onDidAddWidgetEmitter: Emitter<Widget> = new Emitter<Widget>()

Readonly onDidChangeActiveWidget

onDidChangeActiveWidget: Event<IChangedArgs<Widget>> = this.onDidChangeActiveWidgetEmitter.event

Protected Readonly onDidChangeActiveWidgetEmitter

onDidChangeActiveWidgetEmitter: Emitter<IChangedArgs<Widget>> = new Emitter<FocusTracker.IChangedArgs<Widget>>()

Readonly onDidChangeCurrentWidget

onDidChangeCurrentWidget: Event<IChangedArgs<Widget>> = this.onDidChangeCurrentWidgetEmitter.event

Protected Readonly onDidChangeCurrentWidgetEmitter

onDidChangeCurrentWidgetEmitter: Emitter<IChangedArgs<Widget>> = new Emitter<FocusTracker.IChangedArgs<Widget>>()

Readonly onDidRemoveWidget

onDidRemoveWidget: Event<Widget> = this.onDidRemoveWidgetEmitter.event

Protected Readonly onDidRemoveWidgetEmitter

onDidRemoveWidgetEmitter: Emitter<Widget> = new Emitter<Widget>()

Protected options

options: Options

General options for the application shell.

parent

parent: Widget | null

Set the parent of the widget.

Notes

Children are typically added to a widget by using a layout, which means user code will not normally set the parent widget directly.

The widget will be automatically removed from its old parent.

This is a no-op if there is no effective parent change.

Readonly rightPanelHandler

rightPanelHandler: SidePanelHandler

Handler for the right side panel. The secondary application views go here, such as the outline view.

Protected splitPositionHandler

splitPositionHandler: SplitPositionHandler

Protected Readonly statusBar

statusBar: StatusBarImpl

Readonly title

title: Title<Widget>

The title object for the widget.

Notes

The title object is used by some container widgets when displaying the widget alongside some title, such as a tab panel or side bar.

Since not all widgets will use the title, it is created on demand.

The owner property of the title is set to this widget.

Private Readonly toDisposeOnActivationCheck

toDisposeOnActivationCheck: DisposableCollection = new DisposableCollection()

Protected Readonly toDisposeOnActiveChanged

toDisposeOnActiveChanged: DisposableCollection = new DisposableCollection()

Readonly topPanel

topPanel: Panel

The fixed-size panel shown on top. This one usually holds the main menu.

Private Readonly tracker

tracker: FocusTracker<Widget> = new FocusTracker<Widget>()

Static DEFAULT_OPTIONS

DEFAULT_OPTIONS: {} = Object.freeze(<Options>{bottomPanel: Object.freeze(<BottomPanelOptions>{emptySize: 140,expandThreshold: 160,expandDuration: 0,initialSizeRatio: 0.382}),leftPanel: Object.freeze(<SidePanel.Options>{emptySize: 140,expandThreshold: 140,expandDuration: 0,initialSizeRatio: 0.191}),rightPanel: Object.freeze(<SidePanel.Options>{emptySize: 140,expandThreshold: 140,expandDuration: 0,initialSizeRatio: 0.191})})

The default values for application shell options.

Type declaration

Accessors

activeWidget

  • get activeWidget(): Widget | undefined
  • The active widget in the application shell. The active widget is the one that has focus (either the widget itself or any of its contents).

    Note: Focus is taken by a widget through the onActivateRequest method. It is up to the widget implementation which DOM element will get the focus. The default implementation does not take any focus; in that case the widget is never returned by this property.

    Returns Widget | undefined

allTabBars

  • get allTabBars(): TabBar<Widget>[]

bottomAreaTabBars

  • get bottomAreaTabBars(): TabBar<Widget>[]

currentTabArea

  • get currentTabArea(): Area | undefined

currentTabBar

  • get currentTabBar(): TabBar<Widget> | undefined

currentWidget

  • get currentWidget(): Widget | undefined

mainAreaTabBars

  • get mainAreaTabBars(): TabBar<Widget>[]

pendingUpdates

  • get pendingUpdates(): Promise<void>

widgets

  • get widgets(): ReadonlyArray<Widget>

Methods

activate

  • activate(): void
  • Post an 'activate-request' message to the widget.

    Notes

    This is a simple convenience method for posting the message.

    Returns void

activateNextTab

  • activateNextTab(): boolean

activateNextTabBar

  • activateNextTabBar(current?: TabBar<Widget> | undefined): boolean

activateNextTabInTabBar

  • activateNextTabInTabBar(current?: TabBar<Widget> | undefined): boolean

activatePreviousTab

  • activatePreviousTab(): boolean

activatePreviousTabBar

  • activatePreviousTabBar(current?: TabBar<Widget> | undefined): boolean

activatePreviousTabInTabBar

  • activatePreviousTabInTabBar(current?: TabBar<Widget> | undefined): boolean

activateWidget

  • activateWidget(id: string): Promise<Widget | undefined>
  • Activate a widget in the application shell. This makes the widget visible and usually also assigns focus to it.

    Note: Focus is taken by a widget through the onActivateRequest method. It is up to the widget implementation which DOM element will get the focus. The default implementation does not take any focus.

    Parameters

    • id: string

    Returns Promise<Widget | undefined>

    the activated widget if it was found

addClass

  • addClass(name: string): void
  • Add a class name to the widget's DOM node.

    Parameters

    • name: string

      The class name to add to the node.

      Notes

      If the class name is already added to the node, this is a no-op.

      The class name must not contain whitespace.

    Returns void

addWidget

  • Add a widget to the application shell. The given widget must have a unique id property, which will be used as the DOM id.

    Widgets are removed from the shell by calling their close or dispose methods.

    Widgets added to the top area are not tracked regarding the current and active states.

    Parameters

    Returns Promise<void>

Private assertActivated

  • assertActivated(widget: Widget): void

canSave

  • canSave(): boolean

canSaveAll

  • canSaveAll(): boolean

canToggleMaximized

  • canToggleMaximized(): boolean

Private checkActivation

  • checkActivation(widget: Widget): Widget
  • Focus is taken by a widget through the onActivateRequest method. It is up to the widget implementation which DOM element will get the focus. The default implementation of Widget does not take any focus. This method can help finding such problems by logging a warning in case a widget was explicitly activated, but did not trigger a change of the activeWidget property.

    Parameters

    • widget: Widget

    Returns Widget

children

  • children(): IIterator<Widget>
  • Create an iterator over the widget's children.

    Returns IIterator<Widget>

    A new iterator over the children of the widget.

    Notes

    The widget must have a populated layout in order to have children.

    If a layout is not installed, the returned iterator will be empty.

clearFlag

  • clearFlag(flag: Flag): void
  • Clear the given widget flag.

    Notes

    This will not typically be called directly by user code.

    Parameters

    Returns void

close

  • close(): void
  • Send a 'close-request' message to the widget.

    Notes

    This is a simple convenience method for sending the message.

    Returns void

closeTabs

  • closeTabs(tabBarOrArea: TabBar<Widget> | Area, filter?: undefined | ((title: Title<Widget>, index: number) => boolean)): void
  • Close all tabs or a selection of tabs in a specific part of the application shell.

    Parameters

    • tabBarOrArea: TabBar<Widget> | Area
       Either the name of a shell area or a `TabBar` that is contained in such an area.
    • Optional filter: undefined | ((title: Title<Widget>, index: number) => boolean)
       If undefined, all tabs are closed; otherwise only those tabs that match the filter are closed.

    Returns void

closeWidget

  • closeWidget(id: string, options?: CloseOptions): Promise<Widget | undefined>

Protected collapseBottomPanel

  • collapseBottomPanel(): Promise<void>

collapsePanel

  • collapsePanel(area: Area): Promise<void>

contains

  • contains(widget: Widget): boolean
  • Test whether a widget is a descendant of this widget.

    Parameters

    • widget: Widget

      The descendant widget of interest.

    Returns boolean

    true if the widget is a descendant, false otherwise.

Protected createBottomPanel

Protected createBoxLayout

  • createBoxLayout(widgets: Widget[], stretch?: number[], options?: BoxPanel.IOptions): BoxLayout

Protected createLayout

  • createLayout(): Layout

Protected createMainPanel

Protected createSplitLayout

  • createSplitLayout(widgets: Widget[], stretch?: number[], options?: Partial<IOptions>): SplitLayout

Protected createTopPanel

  • createTopPanel(): Panel

Private dispatchMouseMove

  • dispatchMouseMove(): void

dispose

  • dispose(): void
  • Dispose of the widget and its descendant widgets.

    Notes

    It is unsafe to use the widget after it has been disposed.

    All calls made to this method after the first are a no-op.

    Returns void

Protected doActivateWidget

  • doActivateWidget(id: string): Widget | undefined

Protected doRevealWidget

  • doRevealWidget(id: string): Widget | undefined

Protected expandBottomPanel

  • expandBottomPanel(): void

expandPanel

  • expandPanel(area: Area): void
  • Expand the named side panel area. This makes sure that the panel is visible, even if there are no widgets in it. If the panel is already visible, nothing happens. If the panel is currently collapsed (see collapsePanel) and it contains widgets, the widgets are revealed that were visible before it was collapsed.

    Parameters

    Returns void

findTabBar

  • findTabBar(event?: Event): TabBar<Widget> | undefined

findTargetedWidget

  • findTargetedWidget(event?: Event): Widget | undefined

findTitle

  • findTitle(tabBar: TabBar<Widget>, event?: Event): Title<Widget> | undefined
  • Finds the title widget from the tab-bar.

    Parameters

    • tabBar: TabBar<Widget>

      used for providing an array of titles.

    • Optional event: Event

    Returns Title<Widget> | undefined

    the selected title widget, else returns the currentTitle or undefined.

findWidgetForElement

  • findWidgetForElement(element: HTMLElement): Widget | undefined
  • Find the widget that contains the given HTML element. The returned widget may be one that is managed by the application shell, or one that is embedded in another widget and not directly managed by the shell, or a tab bar.

    Parameters

    • element: HTMLElement

    Returns Widget | undefined

Private findWidgetForNode

  • findWidgetForNode(widgetNode: HTMLElement, widget: Widget): Widget | undefined

Protected fireDidAddWidget

  • fireDidAddWidget(widget: Widget): void

Protected fireDidRemoveWidget

  • fireDidRemoveWidget(widget: Widget): void

fit

  • fit(): void
  • Post a 'fit-request' message to the widget.

    Notes

    This is a simple convenience method for posting the message.

    Returns void

getAreaFor

  • getAreaFor(input: TabBar<Widget> | Widget): Area | undefined

Protected getAreaPanelFor

  • getAreaPanelFor(input: Widget): DockPanel | undefined

Protected getBottomPanelSize

  • getBottomPanelSize(): number | undefined

getCurrentWidget

  • getCurrentWidget(area: Area): Widget | undefined

Protected getDefaultBottomPanelSize

  • getDefaultBottomPanelSize(): number | undefined

getLayoutData

getTabBarFor

  • getTabBarFor(widgetOrArea: Widget | Area): TabBar<Widget> | undefined

getWidgetById

  • getWidgetById(id: string): Widget | undefined

getWidgets

  • getWidgets(area: Area): Widget[]

handleEvent

  • handleEvent(event: Event): void

hasClass

  • hasClass(name: string): boolean
  • Test whether the widget's DOM node has the given class name.

    Parameters

    • name: string

      The class name of interest.

    Returns boolean

    true if the node has the class, false otherwise.

hide

  • hide(): void
  • Hide the widget and make it hidden to its parent widget.

    Notes

    This causes the isHidden property to be true.

    If the widget is explicitly hidden, this is a no-op.

    Returns void

Protected init

  • init(): void

Protected initFocusKeyContexts

  • initFocusKeyContexts(): void

Protected initSidebarVisibleKeyContext

  • initSidebarVisibleKeyContext(): void

isExpanded

  • isExpanded(area: Area): boolean

nextTabBar

  • nextTabBar(current?: TabBar<Widget> | undefined): TabBar<Widget> | undefined
  • Return the tab bar next to the given tab bar; return the given tab bar if there is no adjacent one.

    Parameters

    • Default value current: TabBar<Widget> | undefined = this.currentTabBar

    Returns TabBar<Widget> | undefined

nextTabIndexInTabBar

  • nextTabIndexInTabBar(current?: TabBar<Widget> | undefined): number

Protected notifyLayout

  • notifyLayout(msg: Message): void
  • Invoke the message processing routine of the widget's layout.

    Parameters

    • msg: Message

      The message to dispatch to the layout.

      Notes

      This is a no-op if the widget does not have a layout.

      This will not typically be called directly by user code.

    Returns void

Protected onActivateRequest

  • onActivateRequest(msg: Message): void
  • A message handler invoked on an 'activate-request' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Private onActiveChanged

  • onActiveChanged(sender: FocusTracker<Widget>, args: IChangedArgs<Widget>): void

Protected onAfterAttach

  • onAfterAttach(msg: Message): void
  • A message handler invoked on an 'after-attach' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onAfterDetach

  • onAfterDetach(msg: Message): void

Protected onAfterHide

  • onAfterHide(msg: Message): void
  • A message handler invoked on an 'after-hide' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onAfterShow

  • onAfterShow(msg: Message): void
  • A message handler invoked on an 'after-show' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onBeforeAttach

  • onBeforeAttach(msg: Message): void

Protected onBeforeDetach

  • onBeforeDetach(msg: Message): void
  • A message handler invoked on a 'before-detach' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onBeforeHide

  • onBeforeHide(msg: Message): void
  • A message handler invoked on a 'before-hide' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onBeforeShow

  • onBeforeShow(msg: Message): void
  • A message handler invoked on a 'before-show' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onChildAdded

  • A message handler invoked on a 'child-added' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    Returns void

Protected onChildRemoved

  • A message handler invoked on a 'child-removed' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    Returns void

Protected onCloseRequest

  • onCloseRequest(msg: Message): void
  • A message handler invoked on a 'close-request' message.

    Notes

    The default implementation unparents or detaches the widget.

    Parameters

    • msg: Message

    Returns void

Private onCurrentChanged

  • onCurrentChanged(sender: FocusTracker<Widget>, args: IChangedArgs<Widget>): void

Protected onDragEnter

  • onDragEnter(__namedParameters: { mimeData: MimeData }): void

Protected onDragLeave

  • onDragLeave(event: IDragEvent): void

Protected onDragOver

  • onDragOver(event: IDragEvent): void

Protected onDrop

  • onDrop(event: IDragEvent): void

Protected onFitRequest

  • onFitRequest(msg: Message): void
  • A message handler invoked on a 'fit-request' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

Protected onResize

  • A message handler invoked on a 'resize' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    Returns void

Protected onUpdateRequest

  • onUpdateRequest(msg: Message): void
  • A message handler invoked on an 'update-request' message.

    Notes

    The default implementation of this handler is a no-op.

    Parameters

    • msg: Message

    Returns void

previousTabBar

  • previousTabBar(current?: TabBar<Widget> | undefined): TabBar<Widget> | undefined
  • Return the tab bar previous to the given tab bar; return the given tab bar if there is no adjacent one.

    Parameters

    • Default value current: TabBar<Widget> | undefined = this.currentTabBar

    Returns TabBar<Widget> | undefined

previousTabIndexInTabBar

  • previousTabIndexInTabBar(current?: TabBar<Widget> | undefined): number

processMessage

  • processMessage(msg: Message): void
  • Process a message sent to the widget.

    Parameters

    • msg: Message

      The message sent to the widget.

      Notes

      Subclasses may reimplement this method as needed.

    Returns void

Protected refreshBottomPanelToggleButton

  • refreshBottomPanelToggleButton(): void

Protected registerWithFocusTracker

  • registerWithFocusTracker(data: ITabAreaConfig | ISplitAreaConfig | LayoutData | null): void

removeClass

  • removeClass(name: string): void
  • Remove a class name from the widget's DOM node.

    Parameters

    • name: string

      The class name to remove from the node.

      Notes

      If the class name is not yet added to the node, this is a no-op.

      The class name must not contain whitespace.

    Returns void

resize

  • resize(size: number, area: Area): void

revealWidget

  • revealWidget(id: string): Promise<Widget | undefined>

save

saveAll

saveTabs

  • saveTabs(tabBarOrArea: TabBar<Widget> | Area, filter?: undefined | ((title: Title<Widget>, index: number) => boolean)): void

Protected setBottomPanelSize

  • setBottomPanelSize(size: number): Promise<void>

setFlag

  • setFlag(flag: Flag): void
  • Set the given widget flag.

    Notes

    This will not typically be called directly by user code.

    Parameters

    Returns void

setHidden

  • setHidden(hidden: boolean): void
  • Show or hide the widget according to a boolean value.

    Parameters

    • hidden: boolean

      true to hide the widget, or false to show it.

      Notes

      This is a convenience method for hide() and show().

    Returns void

setLayoutData

  • setLayoutData(layoutData: LayoutData): Promise<void>

Private setZIndex

  • setZIndex(element: HTMLElement, z: string | null): void

show

  • show(): void
  • Show the widget and make it visible to its parent widget.

    Notes

    This causes the isHidden property to be false.

    If the widget is not explicitly hidden, this is a no-op.

    Returns void

testFlag

  • testFlag(flag: Flag): boolean
  • Test whether the given widget flag is set.

    Notes

    This will not typically be called directly by user code.

    Parameters

    Returns boolean

Protected toTrackedStack

  • toTrackedStack(id: string): Widget[]

toggleClass

  • toggleClass(name: string, force?: undefined | false | true): boolean
  • Toggle a class name on the widget's DOM node.

    Parameters

    • name: string

      The class name to toggle on the node.

    • Optional force: undefined | false | true

      Whether to force add the class (true) or force remove the class (false). If not provided, the presence of the class will be toggled from its current state.

    Returns boolean

    true if the class is now present, false otherwise.

    Notes

    The class name must not contain whitespace.

toggleMaximized

  • toggleMaximized(): void

Protected track

  • track(widget: Widget): void

update

  • update(): void
  • Post an 'update-request' message to the widget.

    Notes

    This is a simple convenience method for posting the message.

    Returns void

waitForActivation

  • waitForActivation(id: string): Promise<void>

Static attach

  • attach(widget: Widget, host: HTMLElement, ref?: HTMLElement | null): void
  • Attach a widget to a host DOM node.

    Parameters

    • widget: Widget

      The widget of interest.

    • host: HTMLElement

      The DOM node to use as the widget's host.

    • Optional ref: HTMLElement | null

      The child of host to use as the reference element. If this is provided, the widget will be inserted before this node in the host. The default is null, which will cause the widget to be added as the last child of the host.

      Notes

      This will throw an error if the widget is not a root widget, if the widget is already attached, or if the host is not attached to the DOM.

    Returns void

Static detach

  • detach(widget: Widget): void
  • Detach the widget from its host DOM node.

    Parameters

    • widget: Widget

      The widget of interest.

      Notes

      This will throw an error if the widget is not a root widget, or if the widget is not attached to the DOM.

    Returns void

Static isOpenToSideMode

  • isOpenToSideMode(mode: OpenToSideMode | any): mode is OpenToSideMode

Static isSideArea

  • isSideArea(area?: undefined | string): area is "left" | "right" | "bottom"

Static isValidArea

  • isValidArea(area?: any): area is ApplicationShell.Area

Object literals

Protected Readonly bottomPanelState

bottomPanelState: object

The current state of the bottom panel.

empty

empty: true = true

expansion

expansion: collapsed = SidePanel.ExpansionState.collapsed

pendingUpdate

pendingUpdate: Promise<void> = Promise.resolve()