UNPKG

@eclipse-glsp/theia-integration

Version:

Glue code to integrate GLSP clients into Eclipse Theia

117 lines 5.94 kB
/******************************************************************************** * Copyright (c) 2017-2026 TypeFox and others. * Modifications: (c) 2019-2024 EclipseSource 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 { AnyObject, Args, Bounds, EditorContextService, GLSPActionDispatcher, GLSPModelSource, ICopyPasteHandler, ViewerOptions, Viewport } from '@eclipse-glsp/client'; import { URI } from '@theia/core'; import { ApplicationShell, BaseWidget, Message, Navigatable, NavigatableWidgetOptions, SaveableSource, StatefulWidget, StorageService, Widget } from '@theia/core/lib/browser'; import { SelectionService } from '@theia/core/lib/common/selection-service'; import { Container } from '@theia/core/shared/inversify'; import { GLSPSaveable } from './glsp-saveable'; export interface GLSPDiagramWidgetOptions extends NavigatableWidgetOptions { uri: string; diagramType: string; label: string; iconClass: string; editMode: string; } export declare namespace GLSPDiagramWidgetOptions { function is(object: unknown): object is GLSPDiagramWidgetOptions; } export interface GLSPDiagramWidgetContainer { diagramWidget: GLSPDiagramWidget; } export declare function isDiagramWidgetContainer(widget?: Widget): widget is Widget & GLSPDiagramWidgetContainer; export declare class GLSPDiagramWidget extends BaseWidget implements SaveableSource, StatefulWidget, Navigatable { readonly storage: StorageService; readonly theiaSelectionService: SelectionService; protected diagramContainer?: HTMLDivElement; protected copyPasteHandler?: ICopyPasteHandler; protected requestModelOptions: Args; protected storeViewportStateOnClose: boolean; protected _options: GLSPDiagramWidgetOptions; protected _diContainer: Container; saveable: GLSPSaveable; configure(options: GLSPDiagramWidgetOptions, diContainer: Container): void; protected createWidgetId(): string; protected onAfterAttach(msg: Message): void; protected createContainer(): void; protected initializeDiagram(): Promise<void>; protected getRequestModelOptions(): Args; protected getBoundsInPage(element: Element): Bounds; protected onResize(msg: Widget.ResizeMessage): void; protected onActivateRequest(msg: Message): void; protected makeFocusable(element: Element | null): void; protected focusDiagram(): void; protected updateGlobalSelection(): Promise<void>; /** * We cannot activate the widget before the SVG element is there, as it takes the focus. * This should happen within two animation frames, as the action dispatcher issues * a SetModelCommand in the constructor. OTOH, shell.activateWidget() is synchronous. So * after creating the widget and before activating it, we use this method to wait for the * SVG to be appended to the DOM. */ getSvgElement(): Promise<HTMLElement | undefined>; protected onBeforeDetach(msg: Message): void; protected onCloseRequest(msg: Message): void; reloadModel(): Promise<void>; handleMouseEnter(e: MouseEvent): void; handleMouseLeave(e: MouseEvent): void; handleCopy(e: ClipboardEvent): void; handleCut(e: ClipboardEvent): void; handlePaste(e: ClipboardEvent): void; listenToFocusState(shell: ApplicationShell): void; protected isThisWidget(widget?: Widget | null): boolean; get hasFocus(): boolean | undefined; protected getSelectedElementIds(): Promise<string[]>; protected clearGlobalSelection(): Promise<void>; storeState(): AnyObject; restoreState(oldState: AnyObject): void; getResourceUri(): URI | undefined; createMoveToUri(resourceUri: URI): URI | undefined; protected storeViewportDataInStorageService(): void; restoreViewportDataFromStorageService(): Promise<void>; protected removeViewportDataFromStorageService(): Promise<void>; protected getViewportData(): ViewportDataContainer | undefined; protected setViewportData(viewportData: ViewportDataContainer): Promise<void>; protected get viewportStorageId(): string; get actionDispatcher(): GLSPActionDispatcher; get editorContext(): EditorContextService; get viewerOptions(): ViewerOptions; get modelSource(): GLSPModelSource; get clientId(): string; get uri(): URI; get diagramType(): string; get options(): GLSPDiagramWidgetOptions; get diContainer(): Container; } interface ViewportDataContainer { readonly elementId: string; readonly viewportData: Viewport; } /** * Retrieve the active (or current) diagram widget from the given shell. * @param shell The application shell to retrieve the active widget from. * @returns The active diagram widget or `undefined` if no diagram widget is active/current. */ export declare function getDiagramWidget(shell?: ApplicationShell): GLSPDiagramWidget | undefined; /** * Retrieve the corresponding diagram widget from the given widget. * @param widget The widget to retrieve the diagram widget from. * @returns The diagram widget or `undefined` if the given widget is not a diagram widget or a diagram widget container. */ export declare function getDiagramWidget(widget?: Widget): GLSPDiagramWidget | undefined; export {}; //# sourceMappingURL=glsp-diagram-widget.d.ts.map