+ startTransaction: function(metadata) {
+ if(this._currentTransaction) {
+ throw new Error('Nested transactions not supported!');
+ }
+ this._currentTransaction = new Transaction([], metadata);
+ },
+
+ endTransaction: function() {
+ if(!this._currentTransaction) {
+ throw new Error('End of transaction requested, but there is no transaction in progress!');
+ }
+ if(this._currentTransaction.hasTransformations()) {
+ this.undoStack.push(this._currentTransaction);
+ }
+ this._currentTransaction = null;
+ },
+
+ transaction: function(callback, context, metadata) {
+ var toret;
+ this.startTransaction(metadata);
+ toret = callback.call(context);
+ this.endTransaction();
+ return toret;
+ },
+