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 type WidgetOpenMode = 'open' | 'reveal' | 'activate';
/**
 * `WidgetOpenerOptions` define generic options used by the {@link WidgetOpenHandler}.
 *
 * _Note:_ This object may contain references to widgets (e.g. `widgetOptions.ref`);
 * these need to be transformed before it can be serialized.
 */
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<W extends BaseWidget> implements OpenHandler {
    protected readonly shell: ApplicationShell;
    protected readonly widgetManager: WidgetManager;
    protected readonly onCreatedEmitter: Emitter<W>;
    /**
     * Emit when a new widget is created.
     */
    readonly onCreated: Event<W>;
    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<number>;
    /**
     * 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<W>;
    protected doOpen(widget: W, uri: URI, options?: WidgetOpenerOptions): Promise<void>;
    /**
     * 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<W | undefined>;
    /**
     * 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<W>;
    /**
     * 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<W> | undefined;
    protected getWidget(uri: URI, options?: WidgetOpenerOptions): Promise<W | undefined>;
    protected getOrCreateWidget(uri: URI, options?: WidgetOpenerOptions): Promise<W>;
    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<W[]>;
}
//# sourceMappingURL=widget-open-handler.d.ts.map