| java.lang.Object org.netbeans.modules.vmd.api.model.TransactionManager
TransactionManager | final public class TransactionManager (Code) | | This class manages a transactional access to a document. If you want execute a code which reads or writes to
a document or its components than you have to use this manager and call readAccess or writeAccess. A parameter is
a Runnable which will be executed with read/write access.
It uses the NetBeans MUTEX class. Therefore it allows multiple reads and just a single write access at the same time.
When a read or a write access is granted, it automatically waits for a read access on descriptor registry.
author: David Kaspar |
Method Summary | |
void | componentDescriptorChangeHappened(DesignComponent component, Collection<? extends Presenter> presentersToRemove, Collection<Presenter> presentersToAdd, boolean useUndo) | public boolean | isAccess() Checks whether the current thread has a read or a write access granted. | public boolean | isWriteAccess() Checks whether the current thread has a write access granted. | void | parentChangeHappened(DesignComponent previousParent, DesignComponent parent, DesignComponent child) | public void | readAccess(Runnable runnable) Executes a Runnable.run method with read access. | public void | rollback() Notifies the manager to rollback the transaction at the end of the of write access.
The rollback is not asure to happen when a model was changed the way that cannot be undone.
Even through the rollback is performed, the created component will be still presented in the document
and the listener manager will fire an event with all changes. | void | rootChangeHappened(DesignComponent root) | void | selectComponentsHappened(Collection<DesignComponent> oldSelection, Collection<DesignComponent> newSelection) | public void | undoableEditHappened(UndoableEdit edit) Adds an undoable edit into a undo-redo queue. | public long | writeAccess(Runnable runnable) Executes a Runnable.run method with write access. | void | writePropertyHappened(DesignComponent component, String propertyName, PropertyValue oldValue, PropertyValue newValue) |
isAccess | public boolean isAccess()(Code) | | Checks whether the current thread has a read or a write access granted.
true if a read or a write access is granted |
isWriteAccess | public boolean isWriteAccess()(Code) | | Checks whether the current thread has a write access granted.
true if a write access is granted |
readAccess | public void readAccess(Runnable runnable)(Code) | | Executes a Runnable.run method with read access.
Parameters: runnable - the runnable |
rollback | public void rollback()(Code) | | Notifies the manager to rollback the transaction at the end of the of write access.
The rollback is not asure to happen when a model was changed the way that cannot be undone.
Even through the rollback is performed, the created component will be still presented in the document
and the listener manager will fire an event with all changes. If it is rollback-able, then the old and new state in the DesignEvent will be the same.
Note: Use this method in corner cases only. It is not asured that the rollback happens or happens correctly.
Note: Supported undoable changes are Component.addComponent, Component.removeComponent, Component.writeProperty and Document.setSelectedComponents only.
Note: Rejecting operations are: DescriptorRegistry changed, Document.setRootComponent, custom UndoableEdit.
|
undoableEditHappened | public void undoableEditHappened(UndoableEdit edit)(Code) | | Adds an undoable edit into a undo-redo queue.
Note: use this to add an additional undoable edit that cannot be produces by the model directly.
Parameters: edit - the edit; for whole edit instance lifecycle, it has to: edit.isSignificant must return false, edit.canUndo and edit.canRedo must return true, edit.undo and edit.redo must not throw any exception. |
writeAccess | public long writeAccess(Runnable runnable)(Code) | | Executes a Runnable.run method with write access.
Parameters: runnable - the runnable the event id at the end of the write transaction |
|
|