UNPKG

@eclipse-emfcloud/model-manager

Version:

Command-based model editing with undo/redo.

62 lines 2.32 kB
"use strict"; // ***************************************************************************** // Copyright (C) 2023-2024 STMicroelectronics. // // 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: MIT License which is // available at https://opensource.org/licenses/MIT. // // SPDX-License-Identifier: EPL-2.0 OR MIT // ***************************************************************************** Object.defineProperty(exports, "__esModule", { value: true }); exports.ModelManagerImpl = exports.createModelManager = void 0; const impl_1 = require("../impl"); const command_stack_1 = require("./command-stack"); /** * 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 */ const createModelManager = (delegate) => { return new ModelManagerImpl(delegate || new impl_1.CoreModelManagerImpl()); }; exports.createModelManager = createModelManager; class ModelManagerImpl { constructor(delegate) { this.delegate = delegate; } getModel(modelId) { return this.delegate.getModel(modelId); } getModelId(model) { return this.delegate.getModelId(model); } getModelIds() { return this.delegate.getModelIds(); } setModel(modelId, model) { this.delegate.setModel(modelId, model); } removeModel(modelId) { return this.delegate.removeModel(modelId); } subscribe(modelId) { return this.delegate.subscribe(modelId); } getCommandStack(id, options) { const actualOptions = { ...(options ?? {}), id }; return new command_stack_1.CommandStackImpl(this.delegate.getCommandStack(), actualOptions); } getCommandStackIds() { return this.delegate.getCommandStack().getEditingContexts(); } } exports.ModelManagerImpl = ModelManagerImpl; //# sourceMappingURL=model-manager.js.map