Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » TransactionalEditingDomain - how to write
|
Re: TransactionalEditingDomain - how to write [message #38748 is a reply to message #38714] |
Wed, 28 June 2006 16:38 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Steve,
If you are using a plain TransactionalEditingDomain created by the default
factory, then you should perform your write by executing a Command on its
CommandStack. For your convenience, the API provides a RecordingCommand
which you can extend to implement its doExecute() method, in which you just
call whatever EMF or metamodel APIs you need to effect your change. This
is analogous to the ResourceSetModifyOperation of RSA, inasmuch as it
records your changes for effortless undo/redo.
If you are using a TransactionalEditingDomain that is integrated with the
Workbench's operation history (created by a WorkspaceEditingDomainFactory),
then you can also execute some kind of AbstractEMFOperation on the
operation history. The operation is initialized with the editing domain in
which it will create a read/write transaction.
HTH,
Christian
steve rooks wrote:
> Quick question I hope, how do you request write access to an editing
> domain?
>
> I'm looking for the new way of doing the old "
> ResourceSetModifyOperation". The documentation implies that
> TransactionalEditingDomain::runExclusive is for read access only.
>
> Cheers,
>
> steve rooks
|
|
|
Re: TransactionalEditingDomain - how to write [message #39636 is a reply to message #38748] |
Tue, 11 July 2006 13:59 |
Grzegorz Bialek Messages: 43 Registered: July 2009 |
Member |
|
|
Hello,
I have problem with executing commands in this way. I create standard emf command (AddCommand)
and try executing it on TransactionalEditingDomain. When it starts executing it have own
transaction but in dispaching notifications 'domain.getActiveTransaction()' returns null.
I'm new in EMFT and have no idea what I do wrong.
Grzesiek
PS: This is my stack:
java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:291)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:253)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:235)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:191)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:230)
at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:234)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:452)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:396)
at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.jav a:688)
at org.eclipse.emf.edit.command.AddCommand.doExecute(AddCommand .java:400)
at org.eclipse.emf.edit.command.AbstractOverrideableCommand.exe cute(AbstractOverrideableCommand.java:128)
at org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFC ommandOperation.java:116)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:127)
at org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:509)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:144)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:180)
at [.....].addNewSignal(ServiceOutputsSection.java:180)
....
Christian W. Damus wrote:
> Hi, Steve,
>
> If you are using a plain TransactionalEditingDomain created by the default
> factory, then you should perform your write by executing a Command on its
> CommandStack. For your convenience, the API provides a RecordingCommand
> which you can extend to implement its doExecute() method, in which you just
> call whatever EMF or metamodel APIs you need to effect your change. This
> is analogous to the ResourceSetModifyOperation of RSA, inasmuch as it
> records your changes for effortless undo/redo.
>
> If you are using a TransactionalEditingDomain that is integrated with the
> Workbench's operation history (created by a WorkspaceEditingDomainFactory),
> then you can also execute some kind of AbstractEMFOperation on the
> operation history. The operation is initialized with the editing domain in
> which it will create a read/write transaction.
>
> HTH,
>
> Christian
>
> steve rooks wrote:
>
>> Quick question I hope, how do you request write access to an editing
>> domain?
>>
>> I'm looking for the new way of doing the old "
>> ResourceSetModifyOperation". The documentation implies that
>> TransactionalEditingDomain::runExclusive is for read access only.
>>
>> Cheers,
>>
>> steve rooks
>
|
|
|
Re: TransactionalEditingDomain - how to write [message #39667 is a reply to message #39636] |
Tue, 11 July 2006 16:34 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Grzesiek,
The only reason why this should happen is that your Command is modifying
objects not contained in the ResourceSet that your
TransactionalEditingDomain is managing (as indicated by
EditingDomain.getResourceSet() method), but instead in some other domain.
Check in the debugger that the editing domain associated with the
TransactionChangeRecorder at the top of the stack you provided is the same
instance as the domain associated with the WorkspaceCommandStackImpl at the
bottom of the stack.
HTH,
Christian
Grzegorz Bialek wrote:
> Hello,
>
> I have problem with executing commands in this way. I create standard emf
> command (AddCommand) and try executing it on TransactionalEditingDomain.
> When it starts executing it have own transaction but in dispaching
> notifications 'domain.getActiveTransaction()' returns null.
>
> I'm new in EMFT and have no idea what I do wrong.
> Grzesiek
>
> PS: This is my stack:
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:291)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:253)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:235)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:191)
> at
>
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:230)
> at
>
org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:234)
> at
>
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:452)
> at
>
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:396)
> at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.jav a:688) at
> org.eclipse.emf.edit.command.AddCommand.doExecute(AddCommand .java:400) at
>
org.eclipse.emf.edit.command.AbstractOverrideableCommand.exe cute(AbstractOverrideableCommand.java:128)
>
> at
>
org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFC ommandOperation.java:116)
> at
>
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:127)
> at
>
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:509)
> at
>
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:144)
> at
>
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:180)
> at [.....].addNewSignal(ServiceOutputsSection.java:180) ....
>
<snip>
|
|
| |
Re: TransactionalEditingDomain - how to write [message #581695 is a reply to message #38714] |
Wed, 28 June 2006 16:38 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Steve,
If you are using a plain TransactionalEditingDomain created by the default
factory, then you should perform your write by executing a Command on its
CommandStack. For your convenience, the API provides a RecordingCommand
which you can extend to implement its doExecute() method, in which you just
call whatever EMF or metamodel APIs you need to effect your change. This
is analogous to the ResourceSetModifyOperation of RSA, inasmuch as it
records your changes for effortless undo/redo.
If you are using a TransactionalEditingDomain that is integrated with the
Workbench's operation history (created by a WorkspaceEditingDomainFactory),
then you can also execute some kind of AbstractEMFOperation on the
operation history. The operation is initialized with the editing domain in
which it will create a read/write transaction.
HTH,
Christian
steve rooks wrote:
> Quick question I hope, how do you request write access to an editing
> domain?
>
> I'm looking for the new way of doing the old "
> ResourceSetModifyOperation". The documentation implies that
> TransactionalEditingDomain::runExclusive is for read access only.
>
> Cheers,
>
> steve rooks
|
|
|
Re: TransactionalEditingDomain - how to write [message #582349 is a reply to message #38748] |
Tue, 11 July 2006 13:59 |
Grzegorz Bialek Messages: 43 Registered: July 2009 |
Member |
|
|
Hello,
I have problem with executing commands in this way. I create standard emf command (AddCommand)
and try executing it on TransactionalEditingDomain. When it starts executing it have own
transaction but in dispaching notifications 'domain.getActiveTransaction()' returns null.
I'm new in EMFT and have no idea what I do wrong.
Grzesiek
PS: This is my stack:
java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:291)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:253)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:235)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:191)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:230)
at org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:234)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:452)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:396)
at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.jav a:688)
at org.eclipse.emf.edit.command.AddCommand.doExecute(AddCommand .java:400)
at org.eclipse.emf.edit.command.AbstractOverrideableCommand.exe cute(AbstractOverrideableCommand.java:128)
at org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFC ommandOperation.java:116)
at org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:127)
at org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:509)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:144)
at org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:180)
at [.....].addNewSignal(ServiceOutputsSection.java:180)
....
Christian W. Damus wrote:
> Hi, Steve,
>
> If you are using a plain TransactionalEditingDomain created by the default
> factory, then you should perform your write by executing a Command on its
> CommandStack. For your convenience, the API provides a RecordingCommand
> which you can extend to implement its doExecute() method, in which you just
> call whatever EMF or metamodel APIs you need to effect your change. This
> is analogous to the ResourceSetModifyOperation of RSA, inasmuch as it
> records your changes for effortless undo/redo.
>
> If you are using a TransactionalEditingDomain that is integrated with the
> Workbench's operation history (created by a WorkspaceEditingDomainFactory),
> then you can also execute some kind of AbstractEMFOperation on the
> operation history. The operation is initialized with the editing domain in
> which it will create a read/write transaction.
>
> HTH,
>
> Christian
>
> steve rooks wrote:
>
>> Quick question I hope, how do you request write access to an editing
>> domain?
>>
>> I'm looking for the new way of doing the old "
>> ResourceSetModifyOperation". The documentation implies that
>> TransactionalEditingDomain::runExclusive is for read access only.
>>
>> Cheers,
>>
>> steve rooks
>
|
|
|
Re: TransactionalEditingDomain - how to write [message #582366 is a reply to message #39636] |
Tue, 11 July 2006 16:34 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Grzesiek,
The only reason why this should happen is that your Command is modifying
objects not contained in the ResourceSet that your
TransactionalEditingDomain is managing (as indicated by
EditingDomain.getResourceSet() method), but instead in some other domain.
Check in the debugger that the editing domain associated with the
TransactionChangeRecorder at the top of the stack you provided is the same
instance as the domain associated with the WorkspaceCommandStackImpl at the
bottom of the stack.
HTH,
Christian
Grzegorz Bialek wrote:
> Hello,
>
> I have problem with executing commands in this way. I create standard emf
> command (AddCommand) and try executing it on TransactionalEditingDomain.
> When it starts executing it have own transaction but in dispaching
> notifications 'domain.getActiveTransaction()' returns null.
>
> I'm new in EMFT and have no idea what I do wrong.
> Grzesiek
>
> PS: This is my stack:
> java.lang.IllegalStateException: Cannot modify resource set without a
> write transaction at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ssertWriting(TransactionChangeRecorder.java:291)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.a ppendNotification(TransactionChangeRecorder.java:253)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.p rocessObjectNotification(TransactionChangeRecorder.java:235)
> at
>
org.eclipse.emf.transaction.impl.TransactionChangeRecorder.n otifyChanged(TransactionChangeRecorder.java:191)
> at
>
org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify (BasicNotifierImpl.java:230)
> at
>
org.eclipse.emf.ecore.util.EcoreEList.dispatchNotification(E coreEList.java:234)
> at
>
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:452)
> at
>
org.eclipse.emf.common.notify.impl.NotifyingListImpl.addAllU nique(NotifyingListImpl.java:396)
> at org.eclipse.emf.common.util.BasicEList.addAll(BasicEList.jav a:688) at
> org.eclipse.emf.edit.command.AddCommand.doExecute(AddCommand .java:400) at
>
org.eclipse.emf.edit.command.AbstractOverrideableCommand.exe cute(AbstractOverrideableCommand.java:128)
>
> at
>
org.eclipse.emf.workspace.EMFCommandOperation.doExecute(EMFC ommandOperation.java:116)
> at
>
org.eclipse.emf.workspace.AbstractEMFOperation.execute(Abstr actEMFOperation.java:127)
> at
>
org.eclipse.core.commands.operations.DefaultOperationHistory .execute(DefaultOperationHistory.java:509)
> at
>
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:144)
> at
>
org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl.exe cute(WorkspaceCommandStackImpl.java:180)
> at [.....].addNewSignal(ServiceOutputsSection.java:180) ....
>
<snip>
|
|
| |
Goto Forum:
Current Time: Fri Apr 26 15:03:38 GMT 2024
Powered by FUDForum. Page generated in 0.06034 seconds
|