diff -r e68342f9b906 xml.xam/src/org/netbeans/modules/xml/xam/Model.java --- a/xml.xam/src/org/netbeans/modules/xml/xam/Model.java Thu Mar 26 14:00:55 2009 +0300 +++ b/xml.xam/src/org/netbeans/modules/xml/xam/Model.java Sat Apr 04 02:20:09 2009 +0400 @@ -147,6 +147,45 @@ public interface Model + * The transactionDataObject parameter allows passing a + * data object through the transaction. For example, such object can be + * used as a semantical source of the transaction or as a transaction's marker. + * + * @param transactionDataObject is a data object + * @return true if transaction is acquired successfully, else false, for example + * if model has transitioned into invalid state. + * @since 1.6 + */ + boolean startTransaction(Object transactionDataObject); + + /** + * Returns the transaction's data object or null. + * Null can be returned in case the data object hasn't been specified in + * the {@link Model#startTransaction(Object)} method or the model + * out of transaciton at all. + *

+ * The transaction's data object can be not null for transactions + * are started implicitly (sinc, undo, redo, ...). So you should rely + * only on a not null value. + *

+ * The data object can be specified only at the beginning of a transaction + * and can't be changed afterward. It remains alive untill transaction is + * ended. For example, it can be inquired when model's events are processed. + * + * @return the data object. + * @since 1.6 + */ + Object getTransactionDataObject(); + + /** * This method stops the transaction and causes all events to be fired. * After all events have been fired, the document representation will be * modified to reflect the current value of the model (flush). diff -r e68342f9b906 xml.xam/test/unit/src/org/netbeans/modules/xml/xam/AbstractModelTest.java --- a/xml.xam/test/unit/src/org/netbeans/modules/xml/xam/AbstractModelTest.java Thu Mar 26 14:00:55 2009 +0300 +++ b/xml.xam/test/unit/src/org/netbeans/modules/xml/xam/AbstractModelTest.java Sat Apr 04 02:20:09 2009 +0400 @@ -212,4 +212,35 @@ public class AbstractModelTest extends T "resources/test1.xml")); plistener.assertEvent(TestModel2.factory().MODEL_LOADED_PROPERTY, null, m); } + + /** + * Tests that only one Model.MODEL_CHANGED_PROPERTY comes + * when a model is changed through the API. + * @throws java.lang.Exception + */ + public void testTransactionDataObjectPassThrough() throws Exception { + + final Object tDO = new Object(); + + model.addPropertyChangeListener(new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + // + // Test the transaction's data object pass through + assertEquals(tDO, model.getTransactionDataObject()); + } + }); + + model.startTransaction(tDO); + try { + TestComponent r = model.getRootComponent(); + List children = r.getChildren(TestComponent.A.class); + TestComponent.A atc = children.get(2); + // + TestComponent.B b1 = new TestComponent.B(model, 1); + model.addChildComponent(atc, b1, -1); + // + } finally { + model.endTransaction(); + } + } } diff -r e68342f9b906 xml.schema.model/nbproject/project.xml --- a/xml.schema.model/nbproject/project.xml Thu Mar 26 14:00:55 2009 +0300 +++ b/xml.schema.model/nbproject/project.xml Sat Apr 04 02:20:09 2009 +0400 @@ -52,7 +52,7 @@ made subject to such option by the copyr 1 - 1.0 + 1.6 diff -r e68342f9b906 xml.xam/apichanges.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xml.xam/apichanges.xml Sat Apr 04 02:20:09 2009 +0400 @@ -0,0 +1,151 @@ + + + + + + + + + + + + + Extansible Abstract Model (XAM) + + + + + + + + +

Support passing a data object through a transaction + + + + + +

+ Two new methods are added: + {@link org.netbeans.modules.xml.xam.Model#startTransaction(Object)} + and + {@link org.netbeans.modules.xml.xam.Model#getTransactionDataObject} + They are intended to pass an object from a transaction's invocation side + to an event processing side. +

+
+ + + + + + + + + + + + Change History for the Extansible Abstract Model (XAM) + + + + + + +

Introduction

+ +

This document lists changes made to the Extansible Abstract Model (XAM).

+
+ +

@FOOTER@

+ +
+ + diff -r e68342f9b906 xml.xam/nbproject/project.properties --- a/xml.xam/nbproject/project.properties Thu Mar 26 14:00:55 2009 +0300 +++ b/xml.xam/nbproject/project.properties Sat Apr 04 02:20:09 2009 +0400 @@ -42,4 +42,5 @@ is.autoload=true is.autoload=true javac.source=1.5 javadoc.arch=${basedir}/arch.xml -spec.version.base=1.5.0 +javadoc.apichanges=${basedir}/apichanges.xml +spec.version.base=1.6.0 diff -r e68342f9b906 xml.xam/src/org/netbeans/modules/xml/xam/AbstractModel.java --- a/xml.xam/src/org/netbeans/modules/xml/xam/AbstractModel.java Thu Mar 26 14:00:55 2009 +0300 +++ b/xml.xam/src/org/netbeans/modules/xml/xam/AbstractModel.java Sat Apr 04 02:20:09 2009 +0400 @@ -254,7 +254,7 @@ public abstract class AbstractModel propertyChangeEvents; private final List componentListenerEvents; @@ -427,8 +448,10 @@ public abstract class AbstractModel(); componentListenerEvents = new ArrayList(); transactionThread = Thread.currentThread(); @@ -436,7 +459,11 @@ public abstract class AbstractModel