/******************************************************************************** * Copyright (C) 2018 TypeFox and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0. * * This Source Code may also be made available under the following Secondary * Licenses when the conditions for such availability set forth in the Eclipse * Public License v. 2.0 are satisfied: GNU General Public License, version 2 * with the GNU Classpath Exception which is available at * https://www.gnu.org/software/classpath/license.html. * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ import { URI } from '@gedit/utils'; import { Emitter, Event, MaybePromise } from '@gedit/utils'; import { BaseWidget } from './widgets'; import { ApplicationShell, WidgetManager } from './shell'; import { OpenerOptions, OpenHandler } from '@gedit/application-common/lib/browser'; export type WidgetOpenMode = 'open' | 'reveal' | 'activate'; export interface WidgetOpenerOptions extends OpenerOptions { /** * 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; } export declare abstract class WidgetOpenHandler implements OpenHandler { /** * 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; protected readonly shell: ApplicationShell; protected readonly widgetManager: WidgetManager; protected readonly onCreatedEmitter: Emitter; /** * Emit when a new widget is created. */ readonly onCreated: Event; /** * All opened widgets. */ get all(): W[]; abstract canHandle(uri: URI, options?: WidgetOpenerOptions): MaybePromise; /** * Open a widget for the given uri and options. * Reject if the given options is not an widget options or a widget cannot be opened. */ open(uri: URI, options?: WidgetOpenerOptions): Promise; /** * Return an existing widget for the given uri. */ getByUri(uri: URI): Promise; /** * Return an existing widget for the given uri or creates a new one. * * It does not open a widget, use `open` instead. */ getOrCreateByUri(uri: URI): Promise; closeAll(options?: ApplicationShell.CloseOptions): Promise; protected init(): void; protected doOpen(widget: W, options?: WidgetOpenerOptions): Promise; protected getWidget(uri: URI, options?: WidgetOpenerOptions): Promise; protected getOrCreateWidget(uri: URI, options?: WidgetOpenerOptions): Promise; protected abstract createWidgetOptions(uri: URI, options?: WidgetOpenerOptions): Object; } //# sourceMappingURL=widget-open-handler.d.ts.map