michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: /* michael@0: * The nsITransaction interface. michael@0: *
michael@0: * This interface is implemented by an object that needs to michael@0: * execute some behavior that must be tracked by the transaction manager. michael@0: */ michael@0: [scriptable, uuid(58e330c1-7b48-11d2-98b9-00805f297d89)] michael@0: interface nsITransaction : nsISupports michael@0: { michael@0: /** michael@0: * Executes the transaction. michael@0: */ michael@0: void doTransaction(); michael@0: michael@0: /** michael@0: * Restores the state to what it was before the transaction was executed. michael@0: */ michael@0: void undoTransaction(); michael@0: michael@0: /** michael@0: * Executes the transaction again. Can only be called on a transaction that michael@0: * was previously undone. michael@0: *
michael@0: * In most cases, the redoTransaction() method will actually call the michael@0: * doTransaction() method to execute the transaction again. michael@0: */ michael@0: void redoTransaction(); michael@0: michael@0: /** michael@0: * The transaction's transient state. This attribute is checked by michael@0: * the transaction manager after the transaction's Execute() method is called. michael@0: * If the transient state is false, a reference to the transaction is michael@0: * held by the transaction manager so that the transactions' undoTransaction() michael@0: * and redoTransaction() methods can be called. If the transient state is michael@0: * true, the transaction manager returns immediately after the transaction's michael@0: * doTransaction() method is called, no references to the transaction are michael@0: * maintained. Transient transactions cannot be undone or redone by the michael@0: * transaction manager. michael@0: */ michael@0: readonly attribute boolean isTransient; michael@0: michael@0: /** michael@0: * Attempts to merge a transaction into "this" transaction. Both transactions michael@0: * must be in their undo state, doTransaction() methods already called. The michael@0: * transaction manager calls this method to coalesce a new transaction with michael@0: * the transaction on the top of the undo stack. michael@0: * This method returns a boolean value that indicates the merge result. michael@0: * A true value indicates that the transactions were merged successfully, michael@0: * a false value if the merge was not possible or failed. If true, michael@0: * the transaction manager will Release() the new transacton instead of michael@0: * pushing it on the undo stack. michael@0: * @param aTransaction the previously executed transaction to merge. michael@0: */ michael@0: boolean merge(in nsITransaction aTransaction); michael@0: }; michael@0: