123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- import { SGraphCommand } from "./SGraphCommand";
- import { SGraphItem } from "@persagy-web/graph/";
- import { SGraphScene } from "@persagy-web/graph/";
- export class SGraphPropertyCommand<T> extends SGraphCommand {
-
- readonly command: string;
-
- item: SGraphItem;
-
- propName: string;
-
- oldProp: T;
-
- newProp: T;
-
- constructor(
- scene: SGraphScene,
- item: SGraphItem,
- propName: string,
- oldProp: T,
- newProp: T
- ) {
- super(scene);
- this.item = item;
- this.propName = propName;
- this.oldProp = oldProp;
- this.newProp = newProp;
- this.command = "SGraphPropertyCommand";
- this.command = `更新属性=${item.id}`;
- }
-
- redo(): void {
-
- this.item[this.propName] = this.newProp;
- this.item.update();
- }
-
- undo(): void {
-
- this.item[this.propName] = this.oldProp;
- this.item.update();
- }
-
- toString(): string {
- const propName = `propName=${this.propName}`;
- const oldProp = `oldProp=${JSON.stringify(this.oldProp)}`;
- const newProp = `newProp=${JSON.stringify(this.newProp)}`;
- return `${propName};\n${oldProp};\n${newProp}`;
- }
- }
|