@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
119 lines • 4.22 kB
JavaScript
import { __extends } from "tslib";
import { DCommandBase } from "@wcardinal/wcardinal-ui";
var ECommandShapeActionValueReplace = /** @class */ (function (_super) {
__extends(ECommandShapeActionValueReplace, _super);
function ECommandShapeActionValueReplace(oldValue, newValue, selection, list) {
var _this = _super.call(this) || this;
_this._selection = selection;
_this._oldValue = oldValue;
_this._newValue = newValue;
_this._list = list;
_this._indices = [];
_this._oldValues = [];
return _this;
}
Object.defineProperty(ECommandShapeActionValueReplace.prototype, "selection", {
get: function () {
return this._selection;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandShapeActionValueReplace.prototype, "oldValue", {
get: function () {
return this._oldValue;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandShapeActionValueReplace.prototype, "newValue", {
get: function () {
return this._newValue;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandShapeActionValueReplace.prototype, "indices", {
get: function () {
return this._indices;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandShapeActionValueReplace.prototype, "oldValues", {
get: function () {
return this._oldValues;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandShapeActionValueReplace.prototype, "list", {
get: function () {
return this._list;
},
enumerable: false,
configurable: true
});
ECommandShapeActionValueReplace.prototype.execute = function () {
var oldValue = this._oldValue;
var newValue = this._newValue;
var indices = this._indices;
var oldValues = this._oldValues;
var shapes = this._selection.get();
for (var i = 0, imax = shapes.length; i < imax; ++i) {
var shape = shapes[i];
var index = shape.action.indexOf(oldValue);
indices.push(index);
if (0 <= index) {
oldValues.push(shape.action.get(index));
shape.action.set(index, newValue);
}
else {
oldValues.push(newValue);
}
}
var list = this._list;
if (list.data.selection.contains(oldValue)) {
list.data.selection.clearAndAdd(newValue);
}
this._selection.update("PROPERTY");
return true;
};
ECommandShapeActionValueReplace.prototype.redo = function () {
var newValue = this._newValue;
var indices = this._indices;
var shapes = this._selection.get();
for (var i = 0, imax = shapes.length; i < imax; ++i) {
var index = indices[i];
if (0 <= index) {
shapes[i].action.set(index, newValue);
}
}
var list = this._list;
if (list.data.selection.contains(this._oldValue)) {
list.data.selection.clearAndAdd(newValue);
}
this._selection.update("PROPERTY");
return true;
};
ECommandShapeActionValueReplace.prototype.undo = function () {
var indices = this._indices;
var oldValues = this._oldValues;
var shapes = this._selection.get();
for (var i = 0, imax = shapes.length; i < imax; ++i) {
var index = indices[i];
if (0 <= index) {
shapes[i].action.set(index, oldValues[i]);
}
}
var list = this._list;
if (list.data.selection.contains(this._newValue)) {
list.data.selection.clearAndAdd(this._oldValue);
}
this._selection.update("PROPERTY");
return true;
};
return ECommandShapeActionValueReplace;
}(DCommandBase));
export { ECommandShapeActionValueReplace };
//# sourceMappingURL=e-command-shape-action-value-replace.js.map