-
Notifications
You must be signed in to change notification settings - Fork 208
/
UndoRedoTool.ts
52 lines (44 loc) · 1.63 KB
/
UndoRedoTool.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Editing
*/
import { IModelApp, IpcApp, Tool } from "@itwin/core-frontend";
/** Undo all element changes
* @beta
*/
export class UndoAllTool extends Tool {
public static override toolId = "UndoAll";
public override async run(): Promise<boolean> {
const imodel = IModelApp.viewManager.selectedView?.view.iModel;
if (undefined === imodel || imodel.isReadonly || !imodel.isBriefcaseConnection)
return true;
await IpcApp.appFunctionIpc.reverseAllTxn(imodel.key);
// ### TODO Restart of primitive tool should be handled by Txn event listener...needs to happen even if not the active tool...
if (undefined !== IModelApp.toolAdmin.primitiveTool)
await IModelApp.toolAdmin.primitiveTool.onRestartTool();
return true;
}
}
/** Undo active tool steps, or element changes
* @beta
*/
export class UndoTool extends Tool {
public static override toolId = "Undo";
public override async run(): Promise<boolean> {
await IModelApp.toolAdmin.doUndoOperation();
return true;
}
}
/** Redo active tool steps, or element changes
* @beta
*/
export class RedoTool extends Tool {
public static override toolId = "Redo";
public override async run(): Promise<boolean> {
await IModelApp.toolAdmin.doRedoOperation();
return true;
}
}