@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
110 lines • 3.78 kB
JavaScript
import { __extends } from "tslib";
import { DCommandBase } from "@wcardinal/wcardinal-ui";
var ECommandLayerCreate = /** @class */ (function (_super) {
__extends(ECommandLayerCreate, _super);
function ECommandLayerCreate(value, layerContainer, selection) {
var _this = _super.call(this) || this;
_this._value = value;
_this._layerContainer = layerContainer;
_this._layerActive = layerContainer.active;
_this._layerCreated = null;
_this._selection = selection;
_this._selectionStored = null;
return _this;
}
ECommandLayerCreate.prototype.newLayer = function (value, layerContainer) {
var result = layerContainer.create(value.name, true);
value.copyTo(result);
return result;
};
Object.defineProperty(ECommandLayerCreate.prototype, "value", {
get: function () {
return this._value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandLayerCreate.prototype, "layerContainer", {
get: function () {
return this._layerContainer;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandLayerCreate.prototype, "layerActive", {
get: function () {
return this._layerActive;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandLayerCreate.prototype, "layerCreated", {
get: function () {
return this._layerCreated;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandLayerCreate.prototype, "selection", {
get: function () {
return this._selection;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ECommandLayerCreate.prototype, "selectionStored", {
get: function () {
return this._selectionStored;
},
enumerable: false,
configurable: true
});
ECommandLayerCreate.prototype.execute = function () {
var selection = this._selection;
if (!selection.isEmpty()) {
this._selectionStored = selection.store();
selection.clear();
}
else {
this._selectionStored = null;
}
this._layerCreated = this.newLayer(this._value, this._layerContainer);
this._layerCreated.reference += 1;
return true;
};
ECommandLayerCreate.prototype.redo = function () {
var selectionStored = this._selectionStored;
if (selectionStored != null) {
this._selection.clear();
}
var layerCreated = this._layerCreated;
if (layerCreated != null) {
this._layerContainer.attach(layerCreated, true);
}
return true;
};
ECommandLayerCreate.prototype.undo = function () {
var layerCreated = this._layerCreated;
if (layerCreated != null) {
this._layerContainer.detach(layerCreated, this._layerActive);
}
var selectionStored = this._selectionStored;
if (selectionStored != null) {
this._selection.restore(selectionStored);
}
return true;
};
ECommandLayerCreate.prototype.destroy = function () {
var layerCreated = this._layerCreated;
if (layerCreated != null) {
layerCreated.reference -= 1;
if (layerCreated.parent == null && layerCreated.reference <= 0) {
layerCreated.destroy();
}
}
this._layerActive = null;
};
return ECommandLayerCreate;
}(DCommandBase));
export { ECommandLayerCreate };
//# sourceMappingURL=e-command-layer-create.js.map