@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
878 lines • 30.1 kB
JavaScript
import { __extends } from "tslib";
import { DDialogLayered, DInputInteger, DInputIntegerAndLabel, DInputLabel, DInputRealAndLabel, DInputTextAndLabel, DLayoutHorizontal, DLayoutSpace, DSelect, EShapeDataValueExtensions, EShapeDataValueImpl, EShapeDataValueOrder, EShapeDataValueRangeType, EShapeDataValueScope, EShapeDataValueType } from "@wcardinal/wcardinal-ui";
var EDialogDataValue = /** @class */ (function (_super) {
__extends(EDialogDataValue, _super);
function EDialogDataValue() {
return _super !== null && _super.apply(this, arguments) || this;
}
EDialogDataValue.prototype.newContentChildren = function (theme, options) {
var result = _super.prototype.newContentChildren.call(this, theme, options);
result.push(this.layoutType, this.layoutScope, this.inputId, this.inputAs, this.inputInitial, this.layoutInterval, this.inputFormat, this.layoutRangeType, this.inputRangeFrom, this.inputRangeTo, this.inputCapacity, this.layoutOrder);
return result;
};
Object.defineProperty(EDialogDataValue.prototype, "inputId", {
get: function () {
var result = this._inputId;
if (result == null) {
result = this.newInputId();
this._inputId = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newInputId = function () {
var _this = this;
return new DInputTextAndLabel({
width: "padding",
height: "auto",
input: {
weight: 1,
on: {
enter: function () {
_this.ok();
}
}
},
label: {
width: 60,
text: {
value: this.theme.getInputIdLabel()
}
},
space: {
width: 60
}
});
};
Object.defineProperty(EDialogDataValue.prototype, "inputAs", {
get: function () {
var result = this._inputAs;
if (result == null) {
result = this.newInputAs();
this._inputAs = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newInputAs = function () {
var _this = this;
return new DInputTextAndLabel({
width: "padding",
height: "auto",
input: {
weight: 1,
on: {
enter: function () {
_this.ok();
}
}
},
label: {
width: 60,
text: {
value: this.theme.getInputAsLabel()
}
},
space: {
width: 60
}
});
};
Object.defineProperty(EDialogDataValue.prototype, "layoutType", {
get: function () {
var result = this._layoutType;
if (result == null) {
result = this.newLayoutType();
this._layoutType = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newLayoutType = function () {
return new DLayoutHorizontal({
width: "padding",
height: "auto",
children: [
new DInputLabel({
width: 60,
text: {
value: this.theme.getSelectTypeLabel()
}
}),
this.selectType,
new DLayoutSpace({
width: 60
})
]
});
};
Object.defineProperty(EDialogDataValue.prototype, "selectType", {
get: function () {
var _this = this;
var result = this._selectType;
if (result == null) {
result = this.newSelectType();
result.on("change", function () {
_this.onChange();
});
this._selectType = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newSelectType = function () {
return new DSelect({
weight: 1,
value: EShapeDataValueType.NUMBER,
menu: {
items: this.newSelectTypeItems()
}
});
};
EDialogDataValue.prototype.newSelectTypeItems = function () {
var theme = this.theme;
var result = [
{
value: EShapeDataValueType.BOOLEAN,
text: {
value: theme.getSelectTypeValueLabel(EShapeDataValueType.BOOLEAN)
}
},
{
value: EShapeDataValueType.BOOLEAN_ARRAY,
text: {
value: theme.getSelectTypeValueLabel(EShapeDataValueType.BOOLEAN_ARRAY)
}
},
{
value: EShapeDataValueType.NUMBER,
text: {
value: theme.getSelectTypeValueLabel(EShapeDataValueType.NUMBER)
}
},
{
value: EShapeDataValueType.NUMBER_ARRAY,
text: {
value: theme.getSelectTypeValueLabel(EShapeDataValueType.NUMBER_ARRAY)
}
},
{
value: EShapeDataValueType.STRING,
text: {
value: theme.getSelectTypeValueLabel(EShapeDataValueType.STRING)
}
},
{
value: EShapeDataValueType.STRING_ARRAY,
text: {
value: theme.getSelectTypeValueLabel(EShapeDataValueType.STRING_ARRAY)
}
},
{
value: EShapeDataValueType.OBJECT,
text: {
value: theme.getSelectTypeValueLabel(EShapeDataValueType.OBJECT)
}
},
{
value: EShapeDataValueType.OBJECT_ARRAY,
text: {
value: theme.getSelectTypeValueLabel(EShapeDataValueType.OBJECT_ARRAY)
}
},
{
value: EShapeDataValueType.TICKER,
text: {
value: theme.getSelectTypeValueLabel(EShapeDataValueType.TICKER)
}
}
];
EShapeDataValueExtensions.each(function (extension) {
result.push({
value: extension.type,
text: {
value: extension.label
}
});
});
return result;
};
Object.defineProperty(EDialogDataValue.prototype, "layoutScope", {
get: function () {
var result = this._layoutScope;
if (result == null) {
result = this.newLayoutScope();
this._layoutScope = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newLayoutScope = function () {
return new DLayoutHorizontal({
width: "padding",
height: "auto",
children: [
new DInputLabel({
width: 60,
text: {
value: this.theme.getSelectScopeLabel()
}
}),
this.selectScope,
new DLayoutSpace({
width: 60
})
]
});
};
Object.defineProperty(EDialogDataValue.prototype, "selectScope", {
get: function () {
var result = this._selectScope;
if (result == null) {
result = this.newSelectScope();
this._selectScope = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newSelectScope = function () {
var theme = this.theme;
return new DSelect({
weight: 1,
value: EShapeDataValueScope.PUBLIC,
menu: {
items: [
{
value: EShapeDataValueScope.PUBLIC,
text: {
value: theme.getSelectScopeValueLabel(EShapeDataValueScope.PUBLIC)
}
},
{
value: EShapeDataValueScope.PROTECTED,
text: {
value: theme.getSelectScopeValueLabel(EShapeDataValueScope.PROTECTED)
}
},
{
value: EShapeDataValueScope.PRIVATE,
text: {
value: theme.getSelectScopeValueLabel(EShapeDataValueScope.PRIVATE)
}
}
]
}
});
};
Object.defineProperty(EDialogDataValue.prototype, "inputInitial", {
get: function () {
var result = this._inputInitial;
if (result == null) {
result = this.newInputInitial();
this._inputInitial = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newInputInitial = function () {
var _this = this;
return new DInputTextAndLabel({
width: "padding",
height: "auto",
input: {
weight: 1,
text: {
value: ""
},
on: {
enter: function () {
_this.ok();
}
}
},
label: {
width: 60,
text: {
value: this.theme.getInputInitialLabel()
}
},
space: {
width: 60
}
});
};
Object.defineProperty(EDialogDataValue.prototype, "layoutInterval", {
get: function () {
var result = this._layoutInterval;
if (result == null) {
result = this.newLayoutInterval();
this._layoutInterval = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newLayoutInterval = function () {
var theme = this.theme;
return new DLayoutHorizontal({
width: "padding",
height: "auto",
children: [
new DInputLabel({
width: 60,
text: {
value: theme.getInputIntervalLabel()
}
}),
this.inputInterval,
new DInputLabel({
width: 60,
text: {
value: theme.getInputIntervalUnitLabel(),
align: {
horizontal: "LEFT"
}
}
})
]
});
};
Object.defineProperty(EDialogDataValue.prototype, "inputInterval", {
get: function () {
var result = this._inputInterval;
if (result == null) {
result = this.newInputInterval();
this._inputInterval = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newInputInterval = function () {
var _this = this;
return new DInputInteger({
weight: 1,
text: {
value: 1000
},
step: 1,
min: 0,
on: {
enter: function () {
_this.ok();
}
}
});
};
Object.defineProperty(EDialogDataValue.prototype, "inputFormat", {
get: function () {
var result = this._inputFormat;
if (result == null) {
result = this.newInputFormat();
this._inputFormat = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newInputFormat = function () {
var _this = this;
return new DInputTextAndLabel({
width: "padding",
height: "auto",
input: {
weight: 1,
text: {
value: ""
},
on: {
enter: function () {
_this.ok();
}
}
},
label: {
width: 60,
text: {
value: this.theme.getInputFormatLabel()
}
},
space: {
width: 60
}
});
};
Object.defineProperty(EDialogDataValue.prototype, "layoutRangeType", {
get: function () {
var result = this._layoutRangeType;
if (result == null) {
result = this.newLayoutRangeType();
this._layoutRangeType = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newLayoutRangeType = function () {
return new DLayoutHorizontal({
width: "padding",
height: "auto",
children: [
new DInputLabel({
width: 60,
text: {
value: this.theme.getSelectRangeTypeLabel()
}
}),
this.selectRangeType,
new DLayoutSpace({
width: 60
})
]
});
};
Object.defineProperty(EDialogDataValue.prototype, "selectRangeType", {
get: function () {
var _this = this;
var result = this._selectRangeType;
if (result == null) {
result = this.newSelectRangeType();
result.on("change", function () {
_this.onChange();
});
this._selectRangeType = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newSelectRangeType = function () {
var theme = this.theme;
return new DSelect({
weight: 1,
value: EShapeDataValueRangeType.NONE,
menu: {
items: [
{
value: EShapeDataValueRangeType.NONE,
text: {
value: theme.getSelectRangeTypeValueLabel(EShapeDataValueRangeType.NONE)
}
},
{
value: EShapeDataValueRangeType.FROM,
text: {
value: theme.getSelectRangeTypeValueLabel(EShapeDataValueRangeType.FROM)
}
},
{
value: EShapeDataValueRangeType.TO,
text: {
value: theme.getSelectRangeTypeValueLabel(EShapeDataValueRangeType.TO)
}
},
{
value: EShapeDataValueRangeType.FROM_TO,
text: {
value: theme.getSelectRangeTypeValueLabel(EShapeDataValueRangeType.FROM_TO)
}
}
]
}
});
};
Object.defineProperty(EDialogDataValue.prototype, "inputRangeFrom", {
get: function () {
var result = this._inputRangeFrom;
if (result == null) {
result = this.newInputRangeFrom();
this._inputRangeFrom = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newInputRangeFrom = function () {
var _this = this;
return new DInputRealAndLabel({
width: "padding",
height: "auto",
visible: false,
input: {
weight: 1,
text: {
value: 0
},
on: {
enter: function () {
_this.ok();
}
}
},
label: {
width: 90,
text: {
value: this.theme.getInputRangeFromLabel()
}
},
space: {
width: 90
}
});
};
Object.defineProperty(EDialogDataValue.prototype, "inputRangeTo", {
get: function () {
var result = this._inputRangeTo;
if (result == null) {
result = this.newInputRangeTo();
this._inputRangeTo = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newInputRangeTo = function () {
var _this = this;
return new DInputRealAndLabel({
width: "padding",
height: "auto",
visible: false,
input: {
weight: 1,
text: {
value: 1
},
on: {
enter: function () {
_this.ok();
}
}
},
label: {
width: 90,
text: {
value: this.theme.getInputRangeToLabel()
}
},
space: {
width: 90
}
});
};
Object.defineProperty(EDialogDataValue.prototype, "inputCapacity", {
get: function () {
var result = this._inputCapacity;
if (result == null) {
result = this.newInputCapacity();
this._inputCapacity = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newInputCapacity = function () {
var _this = this;
return new DInputIntegerAndLabel({
width: "padding",
height: "auto",
input: {
weight: 1,
text: {
value: 0
},
on: {
enter: function () {
_this.ok();
}
}
},
label: {
width: 60,
text: {
value: this.theme.getInputCapacityLabel()
}
},
space: {
width: 60
}
});
};
Object.defineProperty(EDialogDataValue.prototype, "layoutOrder", {
get: function () {
var result = this._layoutOrder;
if (result == null) {
result = this.newLayoutOrder();
this._layoutOrder = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newLayoutOrder = function () {
return new DLayoutHorizontal({
width: "padding",
height: "auto",
children: [
new DInputLabel({
width: 60,
text: {
value: this.theme.getSelectOrderLabel()
}
}),
this.selectOrder,
new DLayoutSpace({
width: 60
})
]
});
};
Object.defineProperty(EDialogDataValue.prototype, "selectOrder", {
get: function () {
var result = this._selectOrder;
if (result == null) {
result = this.newSelectOrder();
this._selectOrder = result;
}
return result;
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.newSelectOrder = function () {
var _this = this;
var theme = this.theme;
return new DSelect({
weight: 1,
value: EShapeDataValueOrder.ASCENDING,
menu: {
items: [
{
value: EShapeDataValueOrder.ASCENDING,
text: {
value: theme.getSelectOrderValueLabel(EShapeDataValueOrder.ASCENDING)
}
},
{
value: EShapeDataValueOrder.DESCENDING,
text: {
value: theme.getSelectOrderValueLabel(EShapeDataValueOrder.DESCENDING)
}
}
]
},
on: {
init: function (self) {
_this._selectOrder = self;
}
}
});
};
EDialogDataValue.prototype.onChange = function () {
var type = this.selectType.value;
switch (type) {
case EShapeDataValueType.BOOLEAN:
case EShapeDataValueType.BOOLEAN_ARRAY:
case EShapeDataValueType.NUMBER:
case EShapeDataValueType.NUMBER_ARRAY:
case EShapeDataValueType.STRING:
case EShapeDataValueType.STRING_ARRAY:
case EShapeDataValueType.OBJECT:
case EShapeDataValueType.OBJECT_ARRAY:
this.layoutScope.show();
this.inputId.show();
this.inputAs.show();
this.inputInitial.show();
this.layoutInterval.hide();
this.inputFormat.show();
if (type === EShapeDataValueType.NUMBER) {
this.layoutRangeType.show();
var rangeType = this.selectRangeType.value;
if (rangeType != null && (rangeType & EShapeDataValueRangeType.FROM) !== 0) {
this.inputRangeFrom.show();
}
else {
this.inputRangeFrom.hide();
}
if (rangeType != null && (rangeType & EShapeDataValueRangeType.TO) !== 0) {
this.inputRangeTo.show();
}
else {
this.inputRangeTo.hide();
}
}
else {
this.layoutRangeType.hide();
this.inputRangeFrom.hide();
this.inputRangeTo.hide();
}
break;
case EShapeDataValueType.TICKER:
this.layoutScope.hide();
this.inputId.hide();
this.inputAs.show();
this.inputInitial.hide();
this.layoutInterval.show();
this.inputFormat.hide();
this.layoutRangeType.hide();
this.inputRangeFrom.hide();
this.inputRangeTo.hide();
break;
default:
this.layoutScope.hide();
this.inputId.hide();
this.inputAs.show();
this.inputInitial.hide();
this.layoutInterval.hide();
this.inputFormat.hide();
this.layoutRangeType.hide();
this.inputRangeFrom.hide();
this.inputRangeTo.hide();
break;
}
};
EDialogDataValue.prototype.reset = function () {
this.selectType.value = EShapeDataValueType.NUMBER;
this.selectScope.value = EShapeDataValueScope.PUBLIC;
this.inputId.input.value = "";
this.inputAs.input.value = "";
this.inputInitial.input.value = "";
this.inputInterval.value = 1000;
this.inputFormat.input.value = "";
this.selectRangeType.value = EShapeDataValueRangeType.NONE;
this.inputRangeFrom.input.value = 0;
this.inputRangeTo.input.value = 1;
this.inputCapacity.input.value = 0;
this.selectOrder.value = EShapeDataValueOrder.ASCENDING;
this.onChange();
return this;
};
Object.defineProperty(EDialogDataValue.prototype, "value", {
get: function () {
var _a, _b, _c, _d;
var result = new EShapeDataValueImpl();
var type = (_a = this.selectType.value) !== null && _a !== void 0 ? _a : EShapeDataValueType.NUMBER;
var scope = (_b = this.selectScope.value) !== null && _b !== void 0 ? _b : EShapeDataValueScope.PUBLIC;
var order = (_c = this.selectOrder.value) !== null && _c !== void 0 ? _c : EShapeDataValueOrder.ASCENDING;
result.type = type;
switch (type) {
case EShapeDataValueType.BOOLEAN:
case EShapeDataValueType.BOOLEAN_ARRAY:
case EShapeDataValueType.NUMBER:
case EShapeDataValueType.NUMBER_ARRAY:
case EShapeDataValueType.STRING:
case EShapeDataValueType.STRING_ARRAY:
case EShapeDataValueType.OBJECT:
case EShapeDataValueType.OBJECT_ARRAY:
result.scope = scope;
result.id = this.inputId.input.value.trim();
result.as = this.inputAs.input.value.trim();
result.initial = this.inputInitial.input.value.trim();
result.format = this.inputFormat.input.value.trim();
if (type === EShapeDataValueType.NUMBER) {
result.range.type = (_d = this.selectRangeType.value) !== null && _d !== void 0 ? _d : EShapeDataValueRangeType.NONE;
result.range.from = this.inputRangeFrom.input.value;
result.range.to = this.inputRangeTo.input.value;
}
else {
result.range.type = EShapeDataValueRangeType.NONE;
result.range.from = 0;
result.range.to = 1;
}
result.order = order;
break;
case EShapeDataValueType.TICKER:
result.scope = EShapeDataValueScope.PUBLIC;
result.id = "";
result.as = this.inputAs.input.value.trim();
result.initial = "".concat(this.inputInterval.value);
result.format = "";
result.range.type = EShapeDataValueRangeType.NONE;
result.range.from = 0;
result.range.to = 1;
result.order = order;
break;
default:
result.scope = EShapeDataValueScope.PUBLIC;
result.id = "";
result.as = this.inputAs.input.value.trim();
result.initial = "";
result.format = "";
result.range.type = EShapeDataValueRangeType.NONE;
result.range.from = 0;
result.range.to = 1;
result.order = order;
break;
}
return result;
},
set: function (value) {
if (value != null) {
this.selectType.value = value.type;
this.selectScope.value = value.scope;
this.inputId.input.value = value.id;
this.inputAs.input.value = value.as;
if (value.type === EShapeDataValueType.TICKER) {
this.inputInitial.input.value = "";
this.inputInterval.value = this.toInterval(value.initial);
}
else {
this.inputInitial.input.value = value.initial;
this.inputInterval.value = 1000;
}
this.inputFormat.input.value = value.format;
this.selectRangeType.value = value.range.type;
this.inputRangeFrom.input.value = value.range.from;
this.inputRangeTo.input.value = value.range.to;
this.inputCapacity.input.value = value.capacity;
this.selectOrder.value = value.order;
this.onChange();
}
},
enumerable: false,
configurable: true
});
EDialogDataValue.prototype.toInterval = function (target) {
try {
var result = parseInt(target, 10);
if (result === result) {
return Math.max(0, result);
}
}
catch (_a) {
// DO NOTHING
}
return 1000;
};
EDialogDataValue.prototype.getResolvedValue = function () {
return this.value;
};
EDialogDataValue.prototype.getType = function () {
return "EDialogDataValue";
};
return EDialogDataValue;
}(DDialogLayered));
export { EDialogDataValue };
//# sourceMappingURL=e-dialog-data-value.js.map