@eclipse-glsp/client
Version:
A sprotty-based client for GLSP
65 lines • 3.41 kB
TypeScript
/********************************************************************************
* Copyright (c) 2025 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 { Disposable, DisposableCollection, Emitter, Event, GModelRoot, ICommand, ICommandStack, LazyInjector, Viewport } from '@eclipse-glsp/sprotty';
/**
* Service that tracks changes to the model root and the viewport.
* Allows to register listeners that are notified when the model root or the viewport changes.
* The current model root can be queried at any time.
*/
export interface IModelChangeService {
/** The current model root */
readonly currentRoot: Readonly<GModelRoot> | undefined;
/**
* Event that is fired when the model root of the diagram changes i.e. after the `CommandStack` has processed a model update.
*/
onModelRootChanged: Event<Readonly<GModelRoot>>;
/**
* Event that is fired when the viewport of the diagram changes i.e. after the `CommandStack` has processed a viewport update.
* By default, this event is only fired if the viewport was changed via a `SetViewportCommand` or `BoundsAwareViewportCommand`
*/
onViewportChanged: Event<ViewportChange>;
}
/**
* Event data for the {@link IModelChangeService.onViewportChanged} event.
*/
export interface ViewportChange {
/** The new viewport */
newViewport: Readonly<Viewport>;
/** The old viewport */
oldViewport?: Readonly<Viewport>;
}
export declare class ModelChangeService implements IModelChangeService, Disposable {
protected lazyInjector: LazyInjector;
protected _currentRoot?: Readonly<GModelRoot>;
protected lastViewport?: Readonly<Viewport>;
protected toDispose: DisposableCollection;
get currentRoot(): Readonly<GModelRoot> | undefined;
protected get commandStack(): ICommandStack;
protected onModelRootChangedEmitter: Emitter<Readonly<GModelRoot>>;
get onModelRootChanged(): Event<Readonly<GModelRoot>>;
protected onViewportChangedEmitter: Emitter<ViewportChange>;
get onViewportChanged(): Event<ViewportChange>;
protected initialize(): void;
dispose(): void;
protected handleCommandExecution(command: ICommand, newRoot: GModelRoot): void;
protected isModelRootChangeCommand(command: ICommand): boolean;
protected isViewportChangeCommand(command: ICommand): boolean;
protected handleModelRootChangeCommand(command: ICommand, newRoot: GModelRoot): void;
protected handleViewportChangeCommand(command: ICommand, newRoot: GModelRoot): void;
protected hasViewportChanged(newViewport: Readonly<Viewport>): boolean;
protected toViewport(root: Readonly<GModelRoot>): Readonly<Viewport> | undefined;
}
//# sourceMappingURL=model-change-service.d.ts.map