UNPKG

@wcardinal/wcardinal-geditor

Version:

WebGL-based graphic editor, tester and viewer for supervisory systems

87 lines 3.01 kB
import { __extends } from "tslib"; import { DCommandBase } from "@wcardinal/wcardinal-ui"; var ECommandDocumentSnapReplace = /** @class */ (function (_super) { __extends(ECommandDocumentSnapReplace, _super); function ECommandDocumentSnapReplace(snapper, oldValue, newValue, list) { var _this = _super.call(this) || this; _this._snapper = snapper; _this._oldValue = oldValue; _this._newValue = newValue; _this._index = snapper.target.values.indexOf(_this._oldValue); _this._list = list; return _this; } Object.defineProperty(ECommandDocumentSnapReplace.prototype, "snapper", { get: function () { return this._snapper; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapReplace.prototype, "index", { get: function () { return this._index; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapReplace.prototype, "oldValue", { get: function () { return this._oldValue; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapReplace.prototype, "newValue", { get: function () { return this._newValue; }, enumerable: false, configurable: true }); Object.defineProperty(ECommandDocumentSnapReplace.prototype, "list", { get: function () { return this._list; }, enumerable: false, configurable: true }); ECommandDocumentSnapReplace.prototype.execute = function () { return this.redo(); }; ECommandDocumentSnapReplace.prototype.redo = function () { var index = this._index; if (0 <= index) { var list = this._list; var newValue = this._newValue; var snapper = this._snapper; if (list.data.selection.contains(this._oldValue)) { snapper.target.replace(index, newValue); list.data.selection.clearAndAdd(newValue); } else { snapper.target.replace(index, newValue); } } return true; }; ECommandDocumentSnapReplace.prototype.undo = function () { var index = this._index; if (0 <= index) { var list = this._list; var oldValue = this._oldValue; var snapper = this._snapper; if (list.data.selection.contains(this._newValue)) { snapper.target.replace(index, oldValue); list.data.selection.clearAndAdd(oldValue); } else { snapper.target.replace(index, oldValue); } } return true; }; return ECommandDocumentSnapReplace; }(DCommandBase)); export { ECommandDocumentSnapReplace }; //# sourceMappingURL=e-command-document-snap-replace.js.map