@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
77 lines • 3.57 kB
JavaScript
import { __extends } from "tslib";
import { EShapeActionRuntimeBase } from "@wcardinal/wcardinal-ui";
import { EShapeTableIds } from "./e-shape-table-ids";
import { UtilShapeSearch } from "../../util/util-shape-search";
var EShapeTableActionRuntime = /** @class */ (function (_super) {
__extends(EShapeTableActionRuntime, _super);
function EShapeTableActionRuntime(table) {
var _this = _super.call(this) || this;
_this.body = UtilShapeSearch.findChildByType(table, EShapeTableIds.BODY_ID);
_this.column = table.column;
return _this;
}
EShapeTableActionRuntime.prototype.execute = function (shape, runtime, time) {
var body = this.body;
var column = this.column;
if (body != null && column != null) {
var data = shape.data;
if (data.isChanged) {
var rows = body.children;
var rowsLength = rows.length;
var first = data.get(0);
if (first != null) {
var columnValues = column.values;
var values = first.values;
var valuesLength = values.length;
var imin = Math.min(rowsLength, valuesLength);
for (var i = 0; i < imin; ++i) {
var value = values[i];
var row = rows[i];
var cells = row.children;
var cellsLength = cells.length;
var jmin = Math.min(cellsLength, columnValues.length);
for (var j = 0; j < jmin; ++j) {
var cell = cells[j];
var columnValue = columnValues[j];
var columnRuntime = columnValue.runtime;
if (columnRuntime != null) {
cell.state.isFocusable = true;
cell.text.value = columnRuntime.formatter(columnRuntime.toValue(value, j, values), j);
}
}
for (var j = jmin; j < cellsLength; ++j) {
var cell = cells[j];
cell.state.isFocusable = false;
cell.text.value = "";
}
}
for (var i = imin; i < rowsLength; ++i) {
var row = rows[i];
var cells = row.children;
var cellsLength = cells.length;
for (var j = 0; j < cellsLength; ++j) {
var cell = cells[j];
cell.state.isFocusable = false;
cell.text.value = "";
}
}
}
else {
for (var i = 0; i < rowsLength; ++i) {
var row = rows[i];
var cells = row.children;
var cellsLength = cells.length;
for (var j = 0; j < cellsLength; ++j) {
var cell = cells[j];
cell.state.isFocusable = false;
cell.text.value = "";
}
}
}
}
}
};
return EShapeTableActionRuntime;
}(EShapeActionRuntimeBase));
export { EShapeTableActionRuntime };
//# sourceMappingURL=e-shape-table-action-runtime.js.map