@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
234 lines • 9.7 kB
JavaScript
import { __extends } from "tslib";
import { DButtonCheckRight, DControllers, DLayoutVertical, DPane, DSelect, DSelectMultiple, DText, DThemes, EShapeAcceptorEdgeSide, EShapeAcceptorEdgeType, EShapeEmbeddedAcceptorEdge } from "@wcardinal/wcardinal-ui";
import { ECommandShapeEmbeddedAcceptorEdgePropertySide } from "./e-command-shape-embedded-acceptor-edge-property-side";
import { ECommandShapeEmbeddedAcceptorEdgePropertySubtype } from "./e-command-shape-embedded-acceptor-edge-property-subtype";
import { ECommandShapeEmbeddedAcceptorEdgePropertyVvisible } from "./e-command-shape-embedded-acceptor-edge-property-vvisible";
var EEditorShapeEmbeddedAcceptorEdge = /** @class */ (function (_super) {
__extends(EEditorShapeEmbeddedAcceptorEdge, _super);
function EEditorShapeEmbeddedAcceptorEdge(options) {
var _this = _super.call(this, options) || this;
_this._icons = options.icons;
var selection = options.selection;
_this._selection = selection;
_this._diagram = options.diagram;
// Layout
_this.initLayout();
return _this;
}
EEditorShapeEmbeddedAcceptorEdge.prototype.initLayout = function () {
var _this = this;
// Content height
this.content.setHeight("padding");
// Layout
new DLayoutVertical({
parent: this.content,
x: "padding",
y: "padding",
width: "padding",
height: "padding",
children: [this.newTextLabel(), this.selectSubtype, this.selectSide, this.checkVvisible]
});
// Selection
var selection = this._selection;
this.state.isDisabled = selection.isEmpty();
selection.on("change", function () {
_this.state.isDisabled = selection.isEmpty();
_this.onSelectionChange(selection);
});
this.onSelectionChange(selection);
};
EEditorShapeEmbeddedAcceptorEdge.prototype.newTextLabel = function () {
return new DText({
width: "100%",
text: {
value: this.subtheme.getLabel()
}
});
};
Object.defineProperty(EEditorShapeEmbeddedAcceptorEdge.prototype, "selectSubtype", {
get: function () {
var _a;
return ((_a = this._selectSubtype) !== null && _a !== void 0 ? _a : (this._selectSubtype = this.newSelectSubtype()));
},
enumerable: false,
configurable: true
});
EEditorShapeEmbeddedAcceptorEdge.prototype.newSelectSubtype = function () {
var _this = this;
var subtheme = this.subtheme;
return new DSelect({
width: "padding",
value: EShapeAcceptorEdgeType.HEAD,
menu: {
items: [
{
value: EShapeAcceptorEdgeType.HEAD,
text: {
value: subtheme.toSelectSubtypeLabel(EShapeAcceptorEdgeType.HEAD)
}
},
{
value: EShapeAcceptorEdgeType.TAIL,
text: {
value: subtheme.toSelectSubtypeLabel(EShapeAcceptorEdgeType.TAIL)
}
},
{
value: EShapeAcceptorEdgeType.ALL,
text: {
value: subtheme.toSelectSubtypeLabel(EShapeAcceptorEdgeType.ALL)
}
}
]
},
on: {
change: function (value) {
_this.onSelectSubtypeChanged(value);
}
}
});
};
EEditorShapeEmbeddedAcceptorEdge.prototype.onSelectSubtypeChanged = function (value) {
DControllers.getCommandController().push(new ECommandShapeEmbeddedAcceptorEdgePropertySubtype(this._selection, value));
};
Object.defineProperty(EEditorShapeEmbeddedAcceptorEdge.prototype, "selectSide", {
get: function () {
var _a;
return ((_a = this._selectSide) !== null && _a !== void 0 ? _a : (this._selectSide = this.newSelectSide()));
},
enumerable: false,
configurable: true
});
EEditorShapeEmbeddedAcceptorEdge.prototype.newSelectSide = function () {
var _this = this;
var subtheme = this.subtheme;
return new DSelectMultiple({
width: "padding",
values: [EShapeAcceptorEdgeSide.LEFT],
menu: {
items: [
{
value: EShapeAcceptorEdgeSide.LEFT,
text: {
value: subtheme.toSelectSideLabel(EShapeAcceptorEdgeSide.LEFT)
},
check: true
},
{
value: EShapeAcceptorEdgeSide.TOP,
text: {
value: subtheme.toSelectSideLabel(EShapeAcceptorEdgeSide.TOP)
},
check: true
},
{
value: EShapeAcceptorEdgeSide.RIGHT,
text: {
value: subtheme.toSelectSideLabel(EShapeAcceptorEdgeSide.RIGHT)
},
check: true
},
{
value: EShapeAcceptorEdgeSide.BOTTOM,
text: {
value: subtheme.toSelectSideLabel(EShapeAcceptorEdgeSide.BOTTOM)
},
check: true
}
]
},
on: {
change: function (values) {
_this.onSelectSideChange(values);
}
}
});
};
EEditorShapeEmbeddedAcceptorEdge.prototype.onSelectSideChange = function (values) {
DControllers.getCommandController().push(new ECommandShapeEmbeddedAcceptorEdgePropertySide(this._selection, this.fromSelectSideValues(values)));
};
EEditorShapeEmbeddedAcceptorEdge.prototype.toSelectSideValues = function (value) {
var result = [];
if (value & EShapeAcceptorEdgeSide.LEFT) {
result.push(EShapeAcceptorEdgeSide.LEFT);
}
if (value & EShapeAcceptorEdgeSide.TOP) {
result.push(EShapeAcceptorEdgeSide.TOP);
}
if (value & EShapeAcceptorEdgeSide.RIGHT) {
result.push(EShapeAcceptorEdgeSide.RIGHT);
}
if (value & EShapeAcceptorEdgeSide.BOTTOM) {
result.push(EShapeAcceptorEdgeSide.BOTTOM);
}
return result;
};
EEditorShapeEmbeddedAcceptorEdge.prototype.fromSelectSideValues = function (values) {
var result = EShapeAcceptorEdgeSide.NONE;
for (var i = 0, imax = values.length; i < imax; ++i) {
result |= values[i];
}
return result;
};
Object.defineProperty(EEditorShapeEmbeddedAcceptorEdge.prototype, "checkVvisible", {
get: function () {
var _a;
return ((_a = this._checkVvisible) !== null && _a !== void 0 ? _a : (this._checkVvisible = this.newCheckIsVvisible()));
},
enumerable: false,
configurable: true
});
EEditorShapeEmbeddedAcceptorEdge.prototype.newCheckIsVvisible = function () {
var _this = this;
return new DButtonCheckRight({
width: "padding",
text: {
value: this.subtheme.getCheckIsVvisibleLabel()
},
on: {
active: function () {
_this.onCheckVvisibleChanged(true);
},
inactive: function () {
_this.onCheckVvisibleChanged(false);
}
}
});
};
EEditorShapeEmbeddedAcceptorEdge.prototype.onCheckVvisibleChanged = function (isVvisible) {
DControllers.getCommandController().push(new ECommandShapeEmbeddedAcceptorEdgePropertyVvisible(this._selection, isVvisible));
};
EEditorShapeEmbeddedAcceptorEdge.prototype.onSelectionChange = function (selection) {
var selectSubtype = this.selectSubtype;
var selectSide = this.selectSide;
var checkVvisible = this.checkVvisible;
var last = selection.last();
if (last instanceof EShapeEmbeddedAcceptorEdge) {
selectSubtype.value = last.subtype;
selectSubtype.state.isEnabled = true;
selectSide.values = this.toSelectSideValues(last.side);
selectSide.state.isEnabled = true;
checkVvisible.state.isActive = last.vvisible;
checkVvisible.state.isEnabled = true;
}
else {
selectSubtype.state.isEnabled = false;
selectSide.state.isEnabled = false;
checkVvisible.state.isEnabled = false;
}
};
Object.defineProperty(EEditorShapeEmbeddedAcceptorEdge.prototype, "subtheme", {
get: function () {
var _a;
return ((_a = this._subtheme) !== null && _a !== void 0 ? _a : (this._subtheme = this.newSubtheme()));
},
enumerable: false,
configurable: true
});
EEditorShapeEmbeddedAcceptorEdge.prototype.newSubtheme = function () {
return DThemes.get("EEditorShapeEmbeddedAcceptorEdge");
};
return EEditorShapeEmbeddedAcceptorEdge;
}(DPane));
export { EEditorShapeEmbeddedAcceptorEdge };
//# sourceMappingURL=e-editor-shape-embedded-acceptor-edge.js.map