Package ghidra.framework.model
Interface UndoableDomainObject
- All Superinterfaces:
DomainObject,Undoable
- All Known Subinterfaces:
DataTypeArchive,DataTypeManagerDomainObject,Program
- All Known Implementing Classes:
DataTypeArchiveDB,DomainObjectAdapterDB,ProgramDB,URLLinkObject
UndoableDomainObject extends a domain object to provide transaction
support and the ability to undo and redo changes made within a stack of
recent transactions. Each transactions may contain many sub-transactions which
reflect concurrent changes to the domain object. If any sub-transaction fails to commit,
all concurrent sub-transaction changes will be rolled-back.
NOTE: A transaction must be started in order to make any change to this domain object - failure to do so will result in a IOException.
-
Field Summary
Fields inherited from interface ghidra.framework.model.DomainObject
DO_DOMAIN_FILE_CHANGED, DO_OBJECT_CLOSED, DO_OBJECT_ERROR, DO_OBJECT_RENAMED, DO_OBJECT_RESTORED, DO_OBJECT_SAVED, DO_PROPERTY_CHANGED, undoLock -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSynchronizedDomainObject(DomainObject domainObj) Synchronize the specified domain object with this domain object using a shared transaction manager.voidendTransaction(int transactionID, boolean commit) Terminate the specified transaction for this domain object.Returns the current transaction infoReturn array of all domain objects synchronized with a shared transaction manager.booleanReturns true if the last transaction was terminated externally from the action that started it.openTransaction(String description) Open new transaction.voidRemove this domain object from a shared transaction manager.intstartTransaction(String description) Start a new transaction in order to make changes to this domain object.intstartTransaction(String description, AbortedTransactionListener listener) Start a new transaction in order to make changes to this domain object.Methods inherited from interface ghidra.framework.model.DomainObject
addCloseListener, addConsumer, addListener, canLock, canSave, createPrivateEventQueue, flushEvents, flushPrivateEventQueue, forceLock, getConsumerList, getDescription, getDomainFile, getMetadata, getModificationNumber, getName, getOptions, getOptionsNames, hasExclusiveAccess, isChangeable, isChanged, isClosed, isLocked, isSendingEvents, isTemporary, isUsedBy, lock, release, removeCloseListener, removeListener, removePrivateEventQueue, save, saveToPackedFile, setEventsEnabled, setName, setTemporary, unlockMethods inherited from interface ghidra.framework.model.Undoable
addTransactionListener, canRedo, canUndo, clearUndo, getRedoName, getUndoName, redo, removeTransactionListener, undo
-
Method Details
-
openTransaction
Open new transaction. This should generally be done with a try-with-resources block:try (Transaction tx = dobj.openTransaction(description)) { // ... Do something }- Parameters:
description- a short description of the changes to be made.- Returns:
- transaction object
- Throws:
IllegalStateException- if thisDomainObjecthas already been closed.
-
startTransaction
Start a new transaction in order to make changes to this domain object. All changes must be made in the context of a transaction. If a transaction is already in progress, a sub-transaction of the current transaction will be returned.- Parameters:
description- brief description of transaction- Returns:
- transaction ID
- Throws:
DomainObjectLockedException- the domain object is currently lockedTerminatedTransactionException- an existing transaction which has not yet ended was terminated early. Sub-transactions are not permitted until the terminated transaction ends.
-
startTransaction
Start a new transaction in order to make changes to this domain object. All changes must be made in the context of a transaction. If a transaction is already in progress, a sub-transaction of the current transaction will be returned.- Parameters:
description- brief description of transactionlistener- listener to be notified if the transaction is aborted.- Returns:
- transaction ID
- Throws:
DomainObjectLockedException- the domain object is currently lockedTerminatedTransactionException- an existing transaction which has not yet ended was terminated early. Sub-transactions are not permitted until the terminated transaction ends.
-
endTransaction
void endTransaction(int transactionID, boolean commit) Terminate the specified transaction for this domain object.- Parameters:
transactionID- transaction ID obtained from startTransaction methodcommit- if true the changes made in this transaction will be marked for commit, if false this and any concurrent transaction will be rolled-back.
-
getCurrentTransactionInfo
TransactionInfo getCurrentTransactionInfo()Returns the current transaction info- Returns:
- the current transaction info
-
hasTerminatedTransaction
boolean hasTerminatedTransaction()Returns true if the last transaction was terminated externally from the action that started it. -
getSynchronizedDomainObjects
DomainObject[] getSynchronizedDomainObjects()Return array of all domain objects synchronized with a shared transaction manager.- Returns:
- returns array of synchronized domain objects or null if this domain object is not synchronized with others.
-
addSynchronizedDomainObject
Synchronize the specified domain object with this domain object using a shared transaction manager. If either or both is already shared, a transition to a single shared transaction manager will be performed.- Parameters:
domainObj-- Throws:
LockException- if lock or open transaction is active on either this or the specified domain object
-
releaseSynchronizedDomainObject
Remove this domain object from a shared transaction manager. If this object has not been synchronized with others via a shared transaction manager, this method will have no affect.- Throws:
LockException- if lock or open transaction is active
-