@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
63 lines • 2.43 kB
JavaScript
import { __extends } from "tslib";
import { DCommandBase } from "@wcardinal/wcardinal-ui";
import { EShapeButtonLayer } from "./e-shape-button-layer";
var ECommandShapeButtonLayerValueRemove = /** @class */ (function (_super) {
__extends(ECommandShapeButtonLayerValueRemove, _super);
function ECommandShapeButtonLayerValueRemove(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];
if (shape instanceof EShapeButtonLayer) {
var index = shape.button.indexOf(target);
indices.push(index);
if (0 <= index) {
shape.button.remove(index);
}
}
}
_this._indices = indices;
_this._selection.update("PROPERTY");
return _this;
}
ECommandShapeButtonLayerValueRemove.prototype.execute = function () {
return true;
};
ECommandShapeButtonLayerValueRemove.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];
if (shape instanceof EShapeButtonLayer) {
var index = indices[i];
if (0 <= index) {
shape.button.remove(index);
}
}
}
this._selection.update("PROPERTY");
return true;
};
ECommandShapeButtonLayerValueRemove.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];
if (shape instanceof EShapeButtonLayer) {
var index = indices[i];
if (0 <= index) {
shape.button.add(target, index);
}
}
}
this._selection.update("PROPERTY");
return true;
};
return ECommandShapeButtonLayerValueRemove;
}(DCommandBase));
export { ECommandShapeButtonLayerValueRemove };
//# sourceMappingURL=e-command-shape-button-layer-value-remove.js.map