SGraphPropertyCommand.js 1.0 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.SGraphPropertyCommand = void 0;
  4. const SGraphCommand_1 = require("./SGraphCommand");
  5. class SGraphPropertyCommand extends SGraphCommand_1.SGraphCommand {
  6. constructor(scene, item, propName, oldProp, newProp) {
  7. super(scene);
  8. this.item = item;
  9. this.propName = propName;
  10. this.oldProp = oldProp;
  11. this.newProp = newProp;
  12. this.command = "SGraphPropertyCommand";
  13. this.command = `更新属性=${item.id}`;
  14. }
  15. redo() {
  16. this.item[this.propName] = this.newProp;
  17. this.item.update();
  18. }
  19. undo() {
  20. this.item[this.propName] = this.oldProp;
  21. this.item.update();
  22. }
  23. toString() {
  24. const propName = `propName=${this.propName}`;
  25. const oldProp = `oldProp=${JSON.stringify(this.oldProp)}`;
  26. const newProp = `newProp=${JSON.stringify(this.newProp)}`;
  27. return `${propName};\n${oldProp};\n${newProp}`;
  28. }
  29. }
  30. exports.SGraphPropertyCommand = SGraphPropertyCommand;