525
edits
Line 63: | Line 63: | ||
The aggregator does/undoes/redoes each of the transactions in the set provided. | The aggregator does/undoes/redoes each of the transactions in the set provided. | ||
= Creating Folders = | = Creating Folders = | ||
Normally, creating folders is no big hassle. You just use <code>PlacesCreateFolderTransaction</code>. For pasting, the <code>PlacesController</code> does something a little special. Since the user may be pasting in a nested folder structure, when it creates the set of CreateTransactions for the insert operation, there is a problem: the insertion is two-pass. The first pass generates a list of transactions for the insertion, and the second pass is the execution of the transactions using <code>doTransaction</code>. The problem is that all the CreateTransactions take the insertion container as a parameter to the constructor, but the folder the items are being inserted into hasn't been created yet for nested contents! | |||
The solution is that on CreateTransactions, the <code>container</code> property is a public field, and that every pasted folder creates its own list of CreateTransactions to create child items. | |||
The <code>PlacesCreateFolderTransaction</code> method has a <code>childTransactions</code> field which is an array of CreateTransactions taht are used to construct child nodes. | |||
During the first phase of the paste, <code>PlacesCreateFolderTransaction</code> objects' <code>childTransactions</code> fields are recursively populated with these CreateTransactions. | |||
During the second phase of the paste, these <code>childTransactions</code> lists are walked after the containing folder is created, and for each child CreateTransaction, the <code>container</code> property is set to the id of the newly created folder, so that the item is created into the right place. | |||
= Removing Folders = | = Removing Folders = |
edits