@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
77 lines • 2.68 kB
JavaScript
import { __extends } from "tslib";
import { DCommandBase } from "@wcardinal/wcardinal-ui";
var ECommandShapeDataValueRemove = /** @class */ (function (_super) {
__extends(ECommandShapeDataValueRemove, _super);
function ECommandShapeDataValueRemove(target, selection) {
var _this = _super.call(this) || this;
_this._selection = selection;
_this._target = target;
var indices = [];
var shapes = _this._selection.get();
for (var i = 0, imax = shapes.length; i < imax; ++i) {
var shape = shapes[i];
var index = shape.data.indexOf(target);
indices.push(index);
if (0 <= index) {
shape.data.remove(index);
}
}
_this._indices = indices;
_this._selection.update("PROPERTY");
return _this;
}
Object.defineProperty(ECommandShapeDataValueRemove.prototype, "selection", {
get: function () {
return this._selection;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandShapeDataValueRemove.prototype, "target", {
get: function () {
return this._target;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandShapeDataValueRemove.prototype, "indices", {
get: function () {
return this._indices;
},
enumerable: false,
configurable: true
});
ECommandShapeDataValueRemove.prototype.execute = function () {
return true;
};
ECommandShapeDataValueRemove.prototype.redo = function () {
var indices = this._indices;
var shapes = this._selection.get();
for (var i = 0, imax = shapes.length; i < imax; ++i) {
var shape = shapes[i];
var index = indices[i];
if (0 <= index) {
shape.data.remove(index);
}
}
this._selection.update("PROPERTY");
return true;
};
ECommandShapeDataValueRemove.prototype.undo = function () {
var target = this._target;
var indices = this._indices;
var shapes = this._selection.get();
for (var i = 0, imax = shapes.length; i < imax; ++i) {
var shape = shapes[i];
var index = indices[i];
if (0 <= index) {
shape.data.add(target, index);
}
}
this._selection.update("PROPERTY");
return true;
};
return ECommandShapeDataValueRemove;
}(DCommandBase));
export { ECommandShapeDataValueRemove };
//# sourceMappingURL=e-command-shape-data-value-remove.js.map