Options
All
  • Public
  • Public/Protected
  • All
Menu

Transaction 类

层次结构

  • Transaction

事务保存在事务期间收集的 ChangedEvents 列表,作为只读 changes 属性的值

通过调用 UndoManager.startTransaction (或调用方法 Model.startTransactionDiagram.startTransaction) 来启动事务。 确保通过匹配调用 UndoManager.commitTransaction (或 Model.commitTransactionDiagram.commitTransaction), 或调用 UndoManager.rollbackTransaction (或 ModelDiagram 上相同的命名方法) 来完成事务

如果要对model或diagram执行多次更改或重复更改,请在所有代码周围都包含start和commit事务的调用,不要重复调用start-commit-start-commit。 通常,由用户引起的每项更改(例如按钮单击或焦点更改或鼠标拖动)都应执行一个事务,在该事务中进行所有更改。 所有预定义的命令和工具都执行事务。

撤销或重做事务时通过调用 UndoManager.undoUndoManager.redo. 来完成的。这些方法调用这里的 undoredo 方法

UndoManager 在其 UndoManager.history 中保存一个事务列表

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

Read-only changes : List<ChangedEvent>

  • 此只读属性返回 ChangedEvents的列表。更改按发生顺序储存

    你不应该修改此列表

isComplete : boolean

name : string

Methods

canRedo

  • canRedo(): boolean
  • 如果可以调用 redo,即 isComplete 为true,这个谓词返回true

    Returns boolean

    如果准备好调用 redo 则为true

canUndo

  • canUndo(): boolean
  • 如果可以调用 undo, 即 isComplete 为true,这个谓词返回true

    Returns boolean

    如果准备好调用 undo 则为true

clear

  • clear(): void
  • 清楚所有已保存的更改

    Returns void

redo

  • redo(): void
  • undo 后重新执行这些更改。 通常仅由 UndoManager 调用。 canRedo 必须为true才能使用此方法

    Returns void

undo

  • undo(): void
  • 以相反的顺序撤销所有更改。 通常仅由 UndoManager 调用。 canUndo 必须为true才能使此方法生效

    Returns void