@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
57 lines • 2.21 kB
JavaScript
import { __extends } from "tslib";
import { DCommandBase, EShapeCapabilities, EShapeCapability } from "@wcardinal/wcardinal-ui";
var ECommandShapeDataMappingValueAdd = /** @class */ (function (_super) {
__extends(ECommandShapeDataMappingValueAdd, _super);
function ECommandShapeDataMappingValueAdd(value, selection) {
var _this = _super.call(this) || this;
_this._selection = selection;
_this._value = value;
return _this;
}
Object.defineProperty(ECommandShapeDataMappingValueAdd.prototype, "selection", {
get: function () {
return this._selection;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandShapeDataMappingValueAdd.prototype, "value", {
get: function () {
return this._value;
},
enumerable: false,
configurable: true
});
ECommandShapeDataMappingValueAdd.prototype.execute = function () {
return this.redo();
};
ECommandShapeDataMappingValueAdd.prototype.redo = function () {
var value = this._value;
var shapes = this._selection.get();
for (var i = 0, imax = shapes.length; i < imax; ++i) {
var shape = shapes[i];
if (EShapeCapabilities.contains(shape, EShapeCapability.DATA_MAPPING)) {
shape.data.mapping.add(value);
}
}
this._selection.update("PROPERTY");
return true;
};
ECommandShapeDataMappingValueAdd.prototype.undo = function () {
var shapes = this._selection.get();
for (var i = 0, imax = shapes.length; i < imax; ++i) {
var shape = shapes[i];
if (EShapeCapabilities.contains(shape, EShapeCapability.DATA_MAPPING)) {
var mapping = shape.data.getMapping();
if (mapping) {
mapping.remove(mapping.size() - 1);
}
}
}
this._selection.update("PROPERTY");
return true;
};
return ECommandShapeDataMappingValueAdd;
}(DCommandBase));
export { ECommandShapeDataMappingValueAdd };
//# sourceMappingURL=e-command-shape-data-mapping-value-add.js.map