import URI from '../common/uri'; import { MaybePromise, Emitter, Event } from '../common'; import { BaseWidget } from './widgets'; import { ApplicationShell } from './shell'; import { OpenHandler, OpenerOptions } from './opener-service'; import { WidgetManager } from './widget-manager'; export declare type WidgetOpenMode = 'open' | 'reveal' | 'activate'; /** * `WidgetOpenerOptions` define serializable generic options used by the {@link WidgetOpenHandler}. */ export interface WidgetOpenerOptions extends OpenerOptions { /** * Determines whether the widget should be only opened, revealed or activated. * By default is `activate`. */ mode?: WidgetOpenMode; /** * Specify how an opened widget should be added to the shell. * By default to the main area. */ widgetOptions?: ApplicationShell.WidgetOptions; } /** * Generic base class for {@link OpenHandler}s that are opening a widget for a given {@link URI}. */ export declare abstract class WidgetOpenHandler implements OpenHandler { protected readonly shell: ApplicationShell; protected readonly widgetManager: WidgetManager; protected readonly onCreatedEmitter: Emitter; /** * Emit when a new widget is created. */ readonly onCreated: Event; protected init(): void; /** * The widget open handler id. * * #### Implementation * - A widget factory for this id should be registered. * - Subclasses should not implement `WidgetFactory` * to avoid exposing capabilities to create a widget outside of `WidgetManager`. */ abstract readonly id: string; abstract canHandle(uri: URI, options?: WidgetOpenerOptions): MaybePromise; /** * Open a widget for the given uri and options. * Reject if the given options are not widget options or a widget cannot be opened. * @param uri the uri of the resource that should be opened. * @param options the widget opener options. * * @returns promise of the widget that resolves when the widget has been opened. */ open(uri: URI, options?: WidgetOpenerOptions): Promise; protected doOpen(widget: W, options?: WidgetOpenerOptions): Promise; /** * Tries to get an existing widget for the given uri. * @param uri the uri of the widget. * * @returns a promise that resolves to the existing widget or `undefined` if no widget for the given uri exists. */ getByUri(uri: URI): Promise; /** * Return an existing widget for the given uri or creates a new one. * * It does not open a widget, use {@link WidgetOpenHandler#open} instead. * @param uri uri of the widget. * * @returns a promise of the existing or newly created widget. */ getOrCreateByUri(uri: URI): Promise; /** * Retrieves all open widgets that have been opened by this handler. * * @returns all open widgets for this open handler. */ get all(): W[]; protected tryGetPendingWidget(uri: URI, options?: WidgetOpenerOptions): MaybePromise | undefined; protected getWidget(uri: URI, options?: WidgetOpenerOptions): Promise; protected getOrCreateWidget(uri: URI, options?: WidgetOpenerOptions): Promise; protected abstract createWidgetOptions(uri: URI, options?: WidgetOpenerOptions): Object; /** * Closes all widgets that have been opened by this open handler. * @param options the close options that should be applied to all widgets. * * @returns a promise of all closed widgets that resolves after they have been closed. */ closeAll(options?: ApplicationShell.CloseOptions): Promise; } //# sourceMappingURL=widget-open-handler.d.ts.map