Removing a specific transaction from undoManager history

I have an item that I can drag and drop into the diagram. When the user performs a specific action on that item it is removed from the diagram. I want the transaction of dragging the item into the diagram to be part of the undoManager.history. But if the user performs the action that removes this item from the diagram I also want to remove the transaction of dragging it (and dropping) into the diagram from the undoManager history. (The ‘ExternalCopy’ transaction).
How can I do this?
I was thinking maybe I could add a property to the transaction with the item’s key and when the user performs this special action to remove the item, we will go through the undoManager history and find the transaction by the item’s key and call transaction.clear() to empty the transaction.
Then overriding the undo and canUndo functions we will skip all transactions that are empty.
(See this post Remove last transaction from UndoManager history - #10 by walter)
What do you say? Do you have any better suggestions?

That sounds OK.

You don’t need to add a property to a Transaction in order to mark it – just search the Transaction.changes List for a ChangedEvent whose change is Insert, whose modelChange is “nodeDataArray”, and whose newValue is that node data object.