UNPKG

@eclipse-emfcloud/model-manager

Version:

Command-based model editing with undo/redo.

51 lines 2.64 kB
import type { ChangeSubscription, CoreModelManager } from '../core'; import { CommandStack, CommandStackOptions } from './command-stack'; /** * A manager of models, providing {@link CommandStack}s with which to * edit them and {@link ChangeSubscription}s with which to monitor them * for changes. * This is a façade on the {@link CoreModelManager} interface for the common * use cases of client applications that manage editing and undo/redo on * their models independently of all other models. * * @template K the type of key with which a model is associated */ export interface ModelManager<K> extends Omit<CoreModelManager<K>, 'getCommandStack' | 'getEditingContexts'> { /** * Get the {@link CommandStack} with the given identifier for editing the models that I manage. * The semantics of the identifier are not defined by the framework. * * @param id an unique identifier for a command stack to retrieve * @param [options] optional configuration of the returned stack. * If omitted, all options assume their default values. * @returns the command stack */ getCommandStack(id: string, options?: CommandStackOptions): CommandStack<K>; /** * Query the IDs of command stacks that currently have associated command histories and/or dirty state. * If a command stack has been {@linkplain CommandStack.flush flushed} but still {@linkplain CommandStack.getDirtyModels is dirty}, then its ID will be returned in the result. * Otherwise, the command stack ID effectively no longer exists and will not be returned in the result. */ getCommandStackIds(): string[]; } /** * Create a new model manager that delegates to a core implementation. * * @param delegate the core model manager to which I delegate my behaviour. * Omit the `delegate` to use the default implementation * @returns the model manager */ export declare const createModelManager: <K>(delegate?: CoreModelManager<K>) => ModelManager<K>; export declare class ModelManagerImpl<K> implements ModelManager<K> { private readonly delegate; constructor(delegate: CoreModelManager<K>); getModel<M extends object = object>(modelId: K): M | undefined; getModelId(model: object): K | undefined; getModelIds(): K[]; setModel(modelId: K, model: object): void; removeModel<M extends object = object>(modelId: K): M | undefined; subscribe<M extends object = object>(modelId?: K): ChangeSubscription<K, M>; getCommandStack(id: string, options?: CommandStackOptions): CommandStack<K>; getCommandStackIds(): string[]; } //# sourceMappingURL=model-manager.d.ts.map