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