@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
298 lines • 14.3 kB
TypeScript
import { interfaces } from 'inversify';
import { IIterator } from '@phosphor/algorithm';
import { Widget, Message, SplitPanel, BaseWidget, SplitLayout, LayoutItem, PanelLayout, DockPanel } from './widgets';
import { Event as CommonEvent, Emitter } from '../common/event';
import { Disposable, DisposableCollection } from '../common/disposable';
import { CommandRegistry } from '../common/command';
import { MenuModelRegistry, MenuPath } from '../common/menu';
import { ApplicationShell, StatefulWidget, SplitPositionHandler } from './shell';
import { FrontendApplicationStateService } from './frontend-application-state';
import { ContextMenuRenderer, Anchor } from './context-menu-renderer';
import { TabBarToolbarRegistry, TabBarToolbarFactory, TabBarToolbar, TabBarDelegator, TabBarToolbarItem } from './shell/tab-bar-toolbar';
import { WidgetManager } from './widget-manager';
import { ProgressBarFactory } from './progress-bar-factory';
import { IDragEvent } from '@phosphor/dragdrop';
import { TabBarDecoratorService } from './shell/tab-bar-decorator';
export interface ViewContainerTitleOptions {
label: string;
caption?: string;
iconClass?: string;
closeable?: boolean;
}
export declare class ViewContainerIdentifier {
id: string;
progressLocationId?: string;
}
export interface DescriptionWidget {
description: string;
onDidChangeDescription: CommonEvent<void>;
}
export interface BadgeWidget {
badge?: number;
onDidChangeBadge: CommonEvent<void>;
}
export declare namespace DescriptionWidget {
function is(arg: unknown): arg is DescriptionWidget;
}
export declare namespace BadgeWidget {
function is(arg: unknown): arg is BadgeWidget;
}
/**
* A view container holds an arbitrary number of widgets inside a split panel.
* Each widget is wrapped in a _part_ that displays the widget title and toolbar
* and allows to collapse / expand the widget content.
*/
export declare class ViewContainer extends BaseWidget implements StatefulWidget, ApplicationShell.TrackableWidgetProvider, TabBarDelegator {
protected panel: SplitPanel;
protected currentPart: ViewContainerPart | undefined;
/**
* Disable dragging parts from/to this view container.
*/
disableDNDBetweenContainers: boolean;
protected readonly applicationStateService: FrontendApplicationStateService;
protected readonly contextMenuRenderer: ContextMenuRenderer;
protected readonly commandRegistry: CommandRegistry;
protected readonly menuRegistry: MenuModelRegistry;
protected readonly widgetManager: WidgetManager;
protected readonly splitPositionHandler: SplitPositionHandler;
readonly options: ViewContainerIdentifier;
protected readonly toolbarRegistry: TabBarToolbarRegistry;
protected readonly toolbarFactory: TabBarToolbarFactory;
protected readonly onDidChangeTrackableWidgetsEmitter: Emitter<Widget[]>;
readonly onDidChangeTrackableWidgets: CommonEvent<Widget[]>;
protected readonly progressBarFactory: ProgressBarFactory;
protected readonly shell: ApplicationShell;
protected readonly decoratorService: TabBarDecoratorService;
protected init(): void;
protected configureLayout(layout: PanelLayout): void;
protected readonly toDisposeOnCurrentPart: DisposableCollection;
protected updateCurrentPart(part?: ViewContainerPart): void;
protected updateSplitterVisibility(): void;
protected titleOptions: ViewContainerTitleOptions | undefined;
setTitleOptions(titleOptions: ViewContainerTitleOptions | undefined): void;
protected readonly toDisposeOnUpdateTitle: DisposableCollection;
protected _tabBarDelegate: Widget;
updateTabBarDelegate(): void;
getTabBarDelegate(): Widget | undefined;
protected updateTitle(): void;
protected updateToolbarItems(allParts: ViewContainerPart[]): void;
protected getToggleVisibilityGroupLabel(): string;
protected registerToolbarItem(commandId: string, options?: Partial<Omit<TabBarToolbarItem, 'id' | 'command'>>): void;
protected findOriginalPart(): ViewContainerPart | undefined;
protected isCurrentTitle(titleOptions: ViewContainerTitleOptions | undefined): boolean;
protected findPartForAnchor(anchor: Anchor): ViewContainerPart | undefined;
protected readonly toRemoveWidgets: Map<string, DisposableCollection>;
protected createPartId(widget: Widget): string;
addWidget(widget: Widget, options?: ViewContainer.Factory.WidgetOptions, originalContainerId?: string, originalContainerTitle?: ViewContainerTitleOptions): Disposable;
protected attachNewPart(newPart: ViewContainerPart, insertIndex?: number): Disposable;
protected createPart(widget: Widget, partId: string, originalContainerId: string, originalContainerTitle?: ViewContainerTitleOptions, options?: ViewContainer.Factory.WidgetOptions): ViewContainerPart;
removeWidget(widget: Widget): boolean;
getParts(): ViewContainerPart[];
protected getPartIndex(partId: string | undefined): number;
getPartFor(widget: Widget): ViewContainerPart | undefined;
get containerLayout(): ViewContainerLayout;
protected get orientation(): SplitLayout.Orientation;
protected get enableAnimation(): boolean;
protected lastVisibleState: ViewContainer.State | undefined;
storeState(): ViewContainer.State;
protected doStoreState(): ViewContainer.State;
restoreState(state: ViewContainer.State): void;
protected doRestoreState(state: ViewContainer.State): void;
/**
* Register a command to toggle the visibility of the new part.
*/
protected registerPart(toRegister: ViewContainerPart): void;
/**
* Register a menu action to toggle the visibility of the new part.
* The menu action is unregistered first to enable refreshing the order of menu actions.
*/
protected refreshMenu(part: ViewContainerPart): void;
protected unregisterPart(part: ViewContainerPart): void;
protected get contextMenuPath(): MenuPath;
protected toggleVisibilityCommandId(part: ViewContainerPart): string;
protected get globalHideCommandId(): string;
protected moveBefore(toMovedId: string, moveBeforeThisId: string): void;
getTrackableWidgets(): Widget[];
protected fireDidChangeTrackableWidgets(): void;
activateWidget(id: string): Widget | undefined;
revealWidget(id: string): Widget | undefined;
protected revealPart(id: string): ViewContainerPart | undefined;
protected onActivateRequest(msg: Message): void;
protected onAfterAttach(msg: Message): void;
protected onBeforeHide(msg: Message): void;
protected onAfterShow(msg: Message): void;
protected onBeforeAttach(msg: Message): void;
protected onAfterDetach(msg: Message): void;
handleEvent(event: Event): void;
handleDragEnter(event: IDragEvent): void;
toDisposeOnDragEnd: DisposableCollection;
handleDragOver(event: IDragEvent): void;
handleDragLeave(event: IDragEvent): void;
handleDrop(event: IDragEvent): void;
protected registerDND(part: ViewContainerPart): Disposable;
protected getDockPanel(): DockPanel | undefined;
protected isSideDockPanel(widget: Widget): boolean;
}
export declare namespace ViewContainer {
const Factory: unique symbol;
interface Factory {
(options: ViewContainerIdentifier): ViewContainer;
}
namespace Factory {
interface WidgetOptions {
readonly order?: number;
readonly weight?: number;
readonly initiallyCollapsed?: boolean;
readonly canHide?: boolean;
readonly initiallyHidden?: boolean;
/**
* Disable dragging this part from its original container to other containers,
* But allow dropping parts from other containers on it,
* This option only applies to the `ViewContainerPart` and has no effect on the ViewContainer.
*/
readonly disableDraggingToOtherContainers?: boolean;
}
interface WidgetDescriptor {
readonly widget: Widget | interfaces.ServiceIdentifier<Widget>;
readonly options?: WidgetOptions;
}
}
interface State {
title?: ViewContainerTitleOptions;
parts: ViewContainerPart.State[];
}
function getOrientation(node: HTMLElement): 'horizontal' | 'vertical';
}
/**
* Wrapper around a widget held by a view container. Adds a header to display the
* title, toolbar, and collapse / expand handle.
*/
export declare class ViewContainerPart extends BaseWidget {
readonly wrapped: Widget;
readonly partId: string;
protected currentContainerId: string;
readonly originalContainerId: string;
readonly originalContainerTitle: ViewContainerTitleOptions | undefined;
protected readonly toolbarRegistry: TabBarToolbarRegistry;
protected readonly toolbarFactory: TabBarToolbarFactory;
readonly options: ViewContainer.Factory.WidgetOptions;
protected readonly header: HTMLElement;
protected readonly body: HTMLElement;
protected readonly collapsedEmitter: Emitter<boolean>;
protected readonly contextMenuEmitter: Emitter<MouseEvent>;
protected readonly onTitleChangedEmitter: Emitter<void>;
readonly onTitleChanged: CommonEvent<void>;
protected readonly onDidFocusEmitter: Emitter<this>;
readonly onDidFocus: CommonEvent<this>;
protected readonly onPartMovedEmitter: Emitter<ViewContainer>;
readonly onDidMove: CommonEvent<ViewContainer>;
protected readonly onDidChangeDescriptionEmitter: Emitter<void>;
readonly onDidChangeDescription: CommonEvent<void>;
protected readonly onDidChangeBadgeEmitter: Emitter<void>;
readonly onDidChangeBadge: CommonEvent<void>;
protected readonly toolbar: TabBarToolbar;
protected _collapsed: boolean;
uncollapsedSize: number | undefined;
animatedSize: number | undefined;
protected readonly toNoDisposeWrapped: Disposable;
constructor(wrapped: Widget, partId: string, currentContainerId: string, originalContainerId: string, originalContainerTitle: ViewContainerTitleOptions | undefined, toolbarRegistry: TabBarToolbarRegistry, toolbarFactory: TabBarToolbarFactory, options?: ViewContainer.Factory.WidgetOptions);
get viewContainer(): ViewContainer | undefined;
get currentViewContainerId(): string;
get headerElement(): HTMLElement;
get collapsed(): boolean;
set collapsed(collapsed: boolean);
onPartMoved(newContainer: ViewContainer): void;
setHidden(hidden: boolean): void;
get canHide(): boolean;
get onCollapsed(): CommonEvent<boolean>;
get onContextMenu(): CommonEvent<MouseEvent>;
get minSize(): number;
protected readonly toShowHeader: DisposableCollection;
showTitle(): void;
hideTitle(): void;
get titleHidden(): boolean;
protected getScrollContainer(): HTMLElement;
protected registerContextMenu(): Disposable;
protected createContent(): {
header: HTMLElement;
body: HTMLElement;
disposable: Disposable;
};
protected createHeader(): {
header: HTMLElement;
disposable: Disposable;
};
protected onResize(msg: Widget.ResizeMessage): void;
protected onUpdateRequest(msg: Message): void;
protected onAfterAttach(msg: Message): void;
protected onBeforeDetach(msg: Message): void;
protected onBeforeShow(msg: Message): void;
protected onAfterShow(msg: Message): void;
protected onBeforeHide(msg: Message): void;
protected onAfterHide(msg: Message): void;
protected onChildRemoved(msg: Widget.ChildMessage): void;
protected onActivateRequest(msg: Message): void;
}
export declare namespace ViewContainerPart {
/**
* Make sure to adjust the `line-height` of the `.theia-view-container .part > .header` CSS class when modifying this, and vice versa.
*/
const HEADER_HEIGHT = 22;
interface State {
widget?: Widget;
partId: string;
collapsed: boolean;
hidden: boolean;
relativeSize?: number;
description?: string;
/** The original container to which this part belongs */
originalContainerId: string;
originalContainerTitle?: ViewContainerTitleOptions;
}
function closestPart(element: Element | EventTarget | null, selector?: string): Element | undefined;
}
export declare class ViewContainerLayout extends SplitLayout {
protected options: ViewContainerLayout.Options;
protected readonly splitPositionHandler: SplitPositionHandler;
constructor(options: ViewContainerLayout.Options, splitPositionHandler: SplitPositionHandler);
protected get items(): ReadonlyArray<LayoutItem & ViewContainerLayout.Item>;
iter(): IIterator<ViewContainerPart>;
get widgets(): ViewContainerPart[];
attachWidget(index: number, widget: ViewContainerPart): void;
getPartSize(part: ViewContainerPart): number | undefined;
/**
* Set the sizes of the view container parts according to the given weights
* by moving the split handles. This is similar to `setRelativeSizes` defined
* in `SplitLayout`, but here we properly consider the collapsed / expanded state.
*/
setPartSizes(weights: (number | undefined)[]): void;
/**
* Determine the size of the split panel area that is available for widget content,
* i.e. excluding part headers and split handles.
*/
getAvailableSize(): number;
/**
* Update a view container part that has been collapsed or expanded. The transition
* to the new state is animated.
*/
updateCollapsed(part: ViewContainerPart, enableAnimation: boolean): void;
updateSashes(): void;
protected getFirstUncollapsedWidgetIndex(): number | undefined;
protected getLastUncollapsedWidgetIndex(): number | undefined;
protected onFitRequest(msg: Message): void;
/**
* Sinusoidal tween function for smooth animation.
*/
protected tween(t: number): number;
setHandlePosition(index: number, position: number): Promise<void>;
}
export declare namespace ViewContainerLayout {
interface Options extends SplitLayout.IOptions {
headerSize: number;
animationDuration: number;
}
interface Item {
readonly widget: ViewContainerPart;
}
}
//# sourceMappingURL=view-container.d.ts.map