12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import { SGraphCommand } from "@saga-web/graph/lib/commands/SGraphCommand";
- import { SGraphItem } from "@saga-web/graph/lib/SGraphItem";
- import { SGraphScene } from "@saga-web/graph/lib/SGraphScene";
- import { SUndoCommand } from "@saga-web/base/lib";
- /**
- * 添加item命令
- *
- * @author hanyaolong
- * */
- export class SGraphDeleteCommand extends SGraphCommand {
- /** 命令item对象 */
- item: SGraphItem;
- /** 命令item的父类 */
- parent: SGraphItem | null;
- /**
- * 构造函数
- *
- * @param scene item所在场景
- * @param item 命令item对象
- * */
- constructor(scene: SGraphScene, item: SGraphItem) {
- super(scene);
- this.item = item;
- this.parent = item.parent;
- } // Constructor
- /**
- * 合并命令
- *
- * @return boolean 是否已执行合并
- * */
- mergeWith(command: SUndoCommand): boolean {
- return false;
- } // Function mergeWith()
- /**
- * 重做
- *
- * */
- undo(): void {
- this.item.parent = this.parent;
- // @ts-ignore
- this.parent.update();
- } // Function redo()
- /**
- * 撤销
- *
- * */
- redo(): void {
- this.item.parent = null;
- // @ts-ignore
- this.parent.update();
- } // Function undo()
- } // Class SGraphAddCommand
|