12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- import { SGraphCommand } from "./SGraphCommand";
- import { SGraphItem, SGraphScene } from "@persagy-web/graph/";
- import { SUndoCommand } from "@persagy-web/base";
- export class SGraphAddCommand extends SGraphCommand {
-
- readonly command: string;
-
- item: SGraphItem;
-
- parent: SGraphItem | null;
-
- constructor(scene: SGraphScene, item: SGraphItem) {
- super(scene);
- this.item = item;
- this.parent = item.parent;
- this.command = "SGraphAddCommand";
- this.desc = `添加对象=${item.id}`;
- }
-
- mergeWith(command: SUndoCommand): boolean {
- return false;
- }
-
- redo(): void {
- this.item.parent = this.parent;
-
- this.parent.update();
- }
-
- undo(): void {
- this.item.parent = null;
-
- this.parent.update();
- }
- }
|