зеркало из https://github.com/mozilla/gecko-dev.git
Initial checkin of XPIDL'ized TransactionManager interfaces.
NOT PART OF THE BUILD YET!
This commit is contained in:
Родитель
c66c6bce12
Коммит
a907c4ffe0
|
@ -0,0 +1,80 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/*
|
||||
* The nsITransaction interface.
|
||||
* <P>
|
||||
* This interface is implemented by an object that needs to
|
||||
* execute some behavior that must be tracked by the transaction manager.
|
||||
*/
|
||||
[scriptable, uuid(58e330c1-7b48-11d2-98b9-00805f297d89)]
|
||||
interface nsITransaction : nsISupports
|
||||
{
|
||||
/**
|
||||
* Executes the transaction.
|
||||
*/
|
||||
void doTransaction();
|
||||
|
||||
/**
|
||||
* Restores the state to what it was before the transaction was executed.
|
||||
*/
|
||||
void undoTransaction();
|
||||
|
||||
/**
|
||||
* Executes the transaction again. Can only be called on a transaction that
|
||||
* was previously undone.
|
||||
* <P>
|
||||
* In most cases, the redoTransaction() method will actually call the
|
||||
* doTransaction() method to execute the transaction again.
|
||||
*/
|
||||
void redoTransaction();
|
||||
|
||||
/**
|
||||
* The transaction's transient state. This attribute is checked by
|
||||
* the transaction manager after the transaction's Execute() method is called.
|
||||
* If the transient state is false, a reference to the transaction is
|
||||
* held by the transaction manager so that the transactions' undoTransaction()
|
||||
* and redoTransaction() methods can be called. If the transient state is
|
||||
* true, the transaction manager returns immediately after the transaction's
|
||||
* doTransaction() method is called, no references to the transaction are
|
||||
* maintained. Transient transactions cannot be undone or redone by the
|
||||
* transaction manager.
|
||||
*/
|
||||
readonly attribute boolean isTransient;
|
||||
|
||||
/**
|
||||
* Attempts to merge a transaction into "this" transaction. Both transactions
|
||||
* must be in their undo state, doTransaction() methods already called. The
|
||||
* transaction manager calls this method to coalesce a new transaction with
|
||||
* the transaction on the top of the undo stack.
|
||||
* This method returns a boolean value that indicates the merge result.
|
||||
* A true value indicates that the transactions were merged successfully,
|
||||
* a false value if the merge was not possible or failed. If true,
|
||||
* the transaction manager will Release() the new transacton instead of
|
||||
* pushing it on the undo stack.
|
||||
* @param aTransaction the previously executed transaction to merge.
|
||||
*/
|
||||
boolean merge(in nsITransaction aTransaction);
|
||||
};
|
||||
|
|
@ -0,0 +1,79 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
interface nsITransaction;
|
||||
|
||||
/*
|
||||
* The nsITransactionList interface.
|
||||
* <P>
|
||||
* The implementation for this interface is provided by the Transaction Manager.
|
||||
* This interface provides a mechanism for accessing the transactions on the
|
||||
* Undo or Redo stacks as well as any auto-aggragated children that a
|
||||
* transaction may have.
|
||||
*/
|
||||
[scriptable, uuid(97f863f3-f886-11d4-9d39-0060b0f8baff)]
|
||||
|
||||
interface nsITransactionList : nsISupports
|
||||
{
|
||||
/**
|
||||
* The number of transactions contained in this list.
|
||||
*/
|
||||
readonly attribute long numItems;
|
||||
|
||||
/**
|
||||
* itemIsBatch() returns true if the item at aIndex is a batch. Note that
|
||||
* currently there is no requirement for a TransactionManager implementation
|
||||
* to associate a toplevel nsITransaction with a batch so it is possible for
|
||||
* itemIsBatch() to return true and getItem() to return null. However, you
|
||||
* can still access the transactions contained in the batch with a call to
|
||||
* getChildListForItem().
|
||||
* @param aIndex The index of the item in the list.
|
||||
*/
|
||||
boolean itemIsBatch(in long aIndex);
|
||||
|
||||
/**
|
||||
* getItem() returns the transaction at the given index in the list. Note that
|
||||
* a null can be returned here if the item is a batch. The transaction
|
||||
* returned is AddRef'd so it is up to the caller to Release the transaction
|
||||
* when it is done.
|
||||
* @param aIndex The index of the item in the list.
|
||||
*/
|
||||
nsITransaction getItem(in long aIndex);
|
||||
|
||||
/**
|
||||
* getNumChildrenForItem() returns the number of child (auto-aggreated)
|
||||
* transactions the item at aIndex has.
|
||||
* @param aIndex The index of the item in the list.
|
||||
*/
|
||||
long getNumChildrenForItem(in long aIndex);
|
||||
|
||||
/**
|
||||
* getChildListForItem() returns the list of children associated with the
|
||||
* item at aIndex. Implementations may return null if there are no children,
|
||||
* or an empty list. The list returned is AddRef'd so it is up to the caller
|
||||
* to Release the transaction when it is done.
|
||||
* @param aIndex The index of the item in the list.
|
||||
*/
|
||||
nsITransactionList getChildListForItem(in long aIndex);
|
||||
};
|
||||
|
|
@ -0,0 +1,187 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsITransaction;
|
||||
interface nsITransactionManager;
|
||||
|
||||
/**
|
||||
* The nsITransactionListener interface.
|
||||
* <P>
|
||||
* This interface is implemented by an object that tracks transactions.
|
||||
*/
|
||||
[scriptable, uuid(58e330c4-7b48-11d2-98b9-00805f297d89)]
|
||||
interface nsITransactionListener : nsISupports
|
||||
{
|
||||
/**
|
||||
* Called before a transaction manager calls a transaction's
|
||||
* doTransaction() method.
|
||||
* @param aManager the transaction manager doing the transaction.
|
||||
* @param aTransaction the transaction being executed.
|
||||
* @result boolean value returned by listener which indicates
|
||||
* it's desire to interrupt normal control flow. Listeners should
|
||||
* return true if they want to interrupt normal control flow, without
|
||||
* throwing an error.
|
||||
*/
|
||||
boolean willDo(in nsITransactionManager aManager,
|
||||
in nsITransaction aTransaction);
|
||||
|
||||
/**
|
||||
* Called after a transaction manager calls the doTransaction() method of
|
||||
* a transaction.
|
||||
* @param aManager the transaction manager that did the transaction.
|
||||
* @param aTransaction the transaction that was executed.
|
||||
* @param aDoResult the nsresult returned after executing
|
||||
* the transaction.
|
||||
*/
|
||||
void didDo(in nsITransactionManager aManager,
|
||||
in nsITransaction aTransaction,
|
||||
in nsresult aDoResult);
|
||||
|
||||
/**
|
||||
* Called before a transaction manager calls the Undo() method of
|
||||
* a transaction.
|
||||
* @param aManager the transaction manager undoing the transaction.
|
||||
* @param aTransaction the transaction being undone.
|
||||
* @result boolean value returned by listener which indicates
|
||||
* it's desire to interrupt normal control flow. Listeners should
|
||||
* return true if they want to interrupt normal control flow, without
|
||||
* throwing an error. Note that listeners can also interrupt normal
|
||||
* control flow by throwing an nsresult that indicates an error.
|
||||
*/
|
||||
boolean willUndo(in nsITransactionManager aManager,
|
||||
in nsITransaction aTransaction);
|
||||
|
||||
/**
|
||||
* Called after a transaction manager calls the Undo() method of
|
||||
* a transaction.
|
||||
* @param aManager the transaction manager undoing the transaction.
|
||||
* @param aTransaction the transaction being undone.
|
||||
* @param aUndoResult the nsresult returned after undoing the transaction.
|
||||
*/
|
||||
void didUndo(in nsITransactionManager aManager,
|
||||
in nsITransaction aTransaction,
|
||||
in nsresult aUndoResult);
|
||||
|
||||
/**
|
||||
* Called before a transaction manager calls the Redo() method of
|
||||
* a transaction.
|
||||
* @param aManager the transaction manager redoing the transaction.
|
||||
* @param aTransaction the transaction being redone.
|
||||
* @result boolean value returned by listener which indicates
|
||||
* it's desire to interrupt normal control flow. Listeners should
|
||||
* return true if they want to interrupt normal control flow, without
|
||||
* throwing an error. Note that listeners can also interrupt normal
|
||||
* control flow by throwing an nsresult that indicates an error.
|
||||
*/
|
||||
boolean willRedo(in nsITransactionManager aManager,
|
||||
in nsITransaction aTransaction);
|
||||
|
||||
/**
|
||||
* Called after a transaction manager calls the Redo() method of
|
||||
* a transaction.
|
||||
* @param aManager the transaction manager redoing the transaction.
|
||||
* @param aTransaction the transaction being redone.
|
||||
* @param aRedoResult the nsresult returned after redoing the transaction.
|
||||
*/
|
||||
void didRedo(in nsITransactionManager aManager,
|
||||
in nsITransaction aTransaction,
|
||||
in nsresult aRedoResult);
|
||||
|
||||
/**
|
||||
* Called before a transaction manager begins a batch.
|
||||
* @param aManager the transaction manager beginning a batch.
|
||||
* @result boolean value returned by listener which indicates
|
||||
* it's desire to interrupt normal control flow. Listeners should
|
||||
* return true if they want to interrupt normal control flow, without
|
||||
* throwing an error. Note that listeners can also interrupt normal
|
||||
* control flow by throwing an nsresult that indicates an error.
|
||||
*/
|
||||
boolean willBeginBatch(in nsITransactionManager aManager);
|
||||
|
||||
/**
|
||||
* Called after a transaction manager begins a batch.
|
||||
* @param aManager the transaction manager that began a batch.
|
||||
* @param aResult the nsresult returned after beginning a batch.
|
||||
*/
|
||||
void didBeginBatch(in nsITransactionManager aManager,
|
||||
in nsresult aResult);
|
||||
|
||||
/**
|
||||
* Called before a transaction manager ends a batch.
|
||||
* @param aManager the transaction manager ending a batch.
|
||||
* @result boolean value returned by listener which indicates
|
||||
* it's desire to interrupt normal control flow. Listeners should
|
||||
* return true if they want to interrupt normal control flow, without
|
||||
* throwing an error. Note that listeners can also interrupt normal
|
||||
* control flow by throwing an nsresult that indicates an error.
|
||||
*/
|
||||
boolean willEndBatch(in nsITransactionManager aManager);
|
||||
|
||||
/**
|
||||
* Called after a transaction manager ends a batch.
|
||||
* @param aManager the transaction manager ending a batch.
|
||||
* @param aResult the nsresult returned after ending a batch.
|
||||
*/
|
||||
void didEndBatch(in nsITransactionManager aManager,
|
||||
in nsresult aResult);
|
||||
|
||||
/**
|
||||
* Called before a transaction manager tries to merge
|
||||
* a transaction, that was just executed, with the
|
||||
* transaction at the top of the undo stack.
|
||||
* @param aManager the transaction manager ending a batch.
|
||||
* @param aTopTransaction the transaction at the top of the undo stack.
|
||||
* @param aTransactionToMerge the transaction to merge.
|
||||
* @result boolean value returned by listener which indicates
|
||||
* it's desire to interrupt normal control flow. Listeners should
|
||||
* return true if they want to interrupt normal control flow, without
|
||||
* throwing an error. Note that listeners can also interrupt normal
|
||||
* control flow by throwing an nsresult that indicates an error.
|
||||
*/
|
||||
boolean willMerge(in nsITransactionManager aManager,
|
||||
in nsITransaction aTopTransaction,
|
||||
in nsITransaction aTransactionToMerge);
|
||||
|
||||
/**
|
||||
* Called after a transaction manager tries to merge
|
||||
* a transaction, that was just executed, with the
|
||||
* transaction at the top of the undo stack.
|
||||
* @param aManager the transaction manager ending a batch.
|
||||
* @param aTopTransaction the transaction at the top of the undo stack.
|
||||
* @param aTransactionToMerge the transaction to merge.
|
||||
* @param aDidMerge true if transaction was merged, else false.
|
||||
* @param aMergeResult the nsresult returned after the merge attempt.
|
||||
* @param aInterrupt listeners should set this to PR_TRUE if they
|
||||
* want to interrupt normal control flow, without throwing an error.
|
||||
*/
|
||||
void didMerge(in nsITransactionManager aManager,
|
||||
in nsITransaction aTopTransaction,
|
||||
in nsITransaction aTransactionToMerge,
|
||||
in boolean aDidMerge,
|
||||
in nsresult aMergeResult);
|
||||
|
||||
|
||||
/* XXX: We should probably add pruning notification methods. */
|
||||
};
|
||||
|
|
@ -0,0 +1,168 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsITransaction.idl"
|
||||
#include "nsITransactionList.idl"
|
||||
#include "nsITransactionListener.idl"
|
||||
#include "nsIOutputStream.idl"
|
||||
|
||||
%{ C++
|
||||
|
||||
#define NS_TRANSACTIONMANAGER_CONTRACTID "@mozilla.org/transactionmanager;1"
|
||||
|
||||
%} C++
|
||||
|
||||
/**
|
||||
* The nsITransactionManager interface.
|
||||
* <P>
|
||||
* This interface is implemented by an object that wants to
|
||||
* manage/track transactions.
|
||||
*/
|
||||
[scriptable, uuid(58e330c2-7b48-11d2-98b9-00805f297d89)]
|
||||
interface nsITransactionManager : nsISupports
|
||||
{
|
||||
/**
|
||||
* Calls a transaction's doTransaction() method, then pushes it on the
|
||||
* undo stack.
|
||||
* <P>
|
||||
* This method calls the transaction's AddRef() method.
|
||||
* The transaction's Release() method will be called when the undo or redo
|
||||
* stack is pruned or when the transaction manager is destroyed.
|
||||
* @param aTransaction the transaction to do.
|
||||
*/
|
||||
void doTransaction(in nsITransaction aTransaction);
|
||||
|
||||
/**
|
||||
* Pops the topmost transaction on the undo stack, calls it's
|
||||
* undoTransaction() method, then pushes it on the redo stack.
|
||||
*/
|
||||
void undoTransaction();
|
||||
|
||||
/**
|
||||
* Pops the topmost transaction on the redo stack, calls it's
|
||||
* redoTransaction() method, then pushes it on the undo stack.
|
||||
*/
|
||||
void redoTransaction();
|
||||
|
||||
/**
|
||||
* Clears the undo and redo stacks.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
/**
|
||||
* Turns on the transaction manager's batch mode, forcing all transactions
|
||||
* executed by the transaction manager's doTransaction() method to be
|
||||
* aggregated together until EndBatch() is called. This mode allows an
|
||||
* application to execute and group together several independent transactions
|
||||
* so they can be undone with a single call to undoTransaction().
|
||||
*/
|
||||
void beginBatch();
|
||||
|
||||
/**
|
||||
* Turns off the transaction manager's batch mode.
|
||||
*/
|
||||
void endBatch();
|
||||
|
||||
/**
|
||||
* The number of items on the undo stack.
|
||||
*/
|
||||
readonly attribute long numberOfUndoItems;
|
||||
|
||||
/**
|
||||
* The number of items on the redo stack.
|
||||
*/
|
||||
readonly attribute long numberOfRedoItems;
|
||||
|
||||
/**
|
||||
* Sets the maximum number of transaction items the transaction manager will
|
||||
* maintain at any time. This is commonly referred to as the number of levels
|
||||
* of undo.
|
||||
* @param aMaxCount A value of -1 means no limit. A value of zero means the
|
||||
* transaction manager will execute each transaction, then immediately release
|
||||
* all references it has to the transaction without pushing it on the undo
|
||||
* stack. A value greater than zero indicates the max number of transactions
|
||||
* that can exist at any time on both the undo and redo stacks. This method
|
||||
* will prune the neccessary number of transactions on the undo and redo
|
||||
* stacks if the value specified is less than the number of items that exist
|
||||
* on both the undo and redo stacks.
|
||||
*/
|
||||
attribute long maxTransactionCount;
|
||||
|
||||
/**
|
||||
* Returns an AddRef'd pointer to the transaction at the top of the
|
||||
* undo stack. Callers should be aware that this method could return
|
||||
* return a null in some implementations if there is a batch at the top
|
||||
* of the undo stack.
|
||||
*/
|
||||
nsITransaction peekUndoStack();
|
||||
|
||||
/**
|
||||
* Returns an AddRef'd pointer to the transaction at the top of the
|
||||
* redo stack. Callers should be aware that this method could return
|
||||
* return a null in some implementations if there is a batch at the top
|
||||
* of the redo stack.
|
||||
*/
|
||||
nsITransaction peekRedoStack();
|
||||
|
||||
/**
|
||||
* Returns the list of transactions on the undo stack. Note that the
|
||||
* transaction at the top of the undo stack will actually be at the
|
||||
* index 'n-1' in the list, where 'n' is the number of items in the list.
|
||||
*/
|
||||
nsITransactionList getUndoList();
|
||||
|
||||
/**
|
||||
* Returns the list of transactions on the redo stack. Note that the
|
||||
* transaction at the top of the redo stack will actually be at the
|
||||
* index 'n-1' in the list, where 'n' is the number of items in the list.
|
||||
*/
|
||||
nsITransactionList getRedoList();
|
||||
|
||||
/**
|
||||
* Writes a stream representation of the transaction manager and it's
|
||||
* execution stacks. Calls the Write() method of each transaction on the
|
||||
* execution stacks.
|
||||
* @param aOutputStream the stream to write to.
|
||||
*/
|
||||
void Write(in nsIOutputStream aOutputStream);
|
||||
|
||||
/**
|
||||
* Adds a listener to the transaction manager's notification list. Listeners
|
||||
* are notified whenever a transaction is done, undone, or redone.
|
||||
* <P>
|
||||
* The listener's AddRef() method is called.
|
||||
* @param aListener the lister to add.
|
||||
*/
|
||||
void AddListener(in nsITransactionListener aListener);
|
||||
|
||||
/**
|
||||
* Removes a listener from the transaction manager's notification list.
|
||||
* <P>
|
||||
* The listener's Release() method is called.
|
||||
* @param aListener the lister to remove.
|
||||
*/
|
||||
void RemoveListener(in nsITransactionListener aListener);
|
||||
};
|
||||
|
||||
#endif // nsITransactionManager_h__
|
||||
|
Загрузка…
Ссылка в новой задаче