Modifying EObjects without transactions? [message #172874] |
Tue, 19 February 2008 02:39  |
Eclipse User |
|
|
|
Is there a way to modify semantic objects in the editor domain without a
transaction?
What I'm trying to is this: I have a GMF diagram editor that builds a
workflow. I'd like to build in a visual debugger where you can trigger
the workflow (from some external event on a separate thread) and step
through the workflow with some visual cue indicating the active workflow
step.
The problem I'm having is that because the workflow runtime portion is
triggered by an outside event (not via a command) of course I get the
"cannot modify xxx without write transaction..." exception. If I wrap
the trigger in a command the workflow executes fine but I don't get
notified of any of the changes until the current transaction commits (so
they all happen at once).
Optimally I'd like to be able to have a mode where the workflow runtime
is allowed to modify the EObjects without a transaction and still have
the notification events sent to my edit parts so they get updated in
real time.
I guess another option would be to have some kind of custom transaction
that auto-commits after each change or something but I'm not sure where
to begin or if what I'm trying to do is within the realm of reasonable
possibility.
Any ideas would be greatly appreciated!
Thanks,
Zac
|
|
|
|
|
|
|
Re: Modifying EObjects without transactions? SOLVED! [message #173027 is a reply to message #173001] |
Tue, 19 February 2008 16:05   |
Eclipse User |
|
|
|
In my diagram project I have an auto-generated class called
XXXDocumentProvider and I modified the createEditingDomain() to use my
own TransactionEditingDomain:
/**
* @generated NOT
*/
private TransactionalEditingDomain createEditingDomain() {
TransactionalEditingDomain editingDomain =
MyNewDiagramEditingDomainFactory.getInstance()
.createEditingDomain();
....
}
That was the only meaningful change I had to make. What I don't know
is, what kind of things are going to get out of sync now that I've
disabled the assertWrite() check in ChangeRecorder. So far so good but,
since I don't completely understand EMF transactions yet, I can't vouch
for this as a good solution.
Hope that helps!
Tomas Zijdemans wrote:
> How did you make your code use this new TransactionalEditingDomain ?
>
> I'd also like to modify my EObjects without a transaction :)
>
>
> Tomas
>
>
> Zac Woof wrote:
>> I've got it working now simply by making my own
>> TransactionalEditingDomain which is just a cut-and-paste from
>> org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFac tory$DiagramEditingDomain
>> except that the ChangeRecorder I return doesn't check for read/write
>> transactions when in debug mode:
>>
>> protected TransactionChangeRecorder
>> createChangeRecorder(ResourceSet rset) {
>> return new TransactionChangeRecorder(this, rset) {
>>
>> @Override
>> protected void assertWriting() {
>> if (!debugFile) super.assertWriting();
>> }
>> };
>>
>> }
>>
>> Everything seems to be working now and I get real-time updates in the
>> designer as the workflow is executing.
>> Zac Woof wrote:
>>> Thanks Jan,
>>>
>>> That's a good thought but the problem is that I use the same model
>>> project for the actual runtime version of the workflow engine,
>>> outside of the editor. I suppose I could overload each of the steps
>>> to accept an EditingDomain and create and execute a command there
>>> but, if possible, I'd like to keep that portion of the application as
>>> decoupled from the design-time code as possible.
>>>
>>> Jan Herriger wrote:
>>>> Hi Zac,
>>>>
>>>> my first thought was: why don't you put each workflow step into a
>>>> single command and execute them one after another? But this thought
>>>> may not be elaborated well ;-)
>>>>
>>>> Zac Woof schrieb:
>>>>> Is there a way to modify semantic objects in the editor domain
>>>>> without a transaction?
>>>>>
>>>>> What I'm trying to is this: I have a GMF diagram editor that builds
>>>>> a workflow. I'd like to build in a visual debugger where you can
>>>>> trigger the workflow (from some external event on a separate
>>>>> thread) and step through the workflow with some visual cue
>>>>> indicating the active workflow step.
>>>>>
>>>>> The problem I'm having is that because the workflow runtime portion
>>>>> is triggered by an outside event (not via a command) of course I
>>>>> get the "cannot modify xxx without write transaction..."
>>>>> exception. If I wrap the trigger in a command the workflow
>>>>> executes fine but I don't get notified of any of the changes until
>>>>> the current transaction commits (so they all happen at once).
>>>>>
>>>>> Optimally I'd like to be able to have a mode where the workflow
>>>>> runtime is allowed to modify the EObjects without a transaction and
>>>>> still have the notification events sent to my edit parts so they
>>>>> get updated in real time.
>>>>>
>>>>> I guess another option would be to have some kind of custom
>>>>> transaction that auto-commits after each change or something but
>>>>> I'm not sure where to begin or if what I'm trying to do is within
>>>>> the realm of reasonable possibility.
>>>>>
>>>>> Any ideas would be greatly appreciated!
>>>>> Thanks,
>>>>> Zac
|
|
|
Re: Modifying EObjects without transactions? SOLVED! [message #173042 is a reply to message #173001] |
Tue, 19 February 2008 17:29  |
Eclipse User |
|
|
|
In my diagram project I have an auto-generated class called
XXXDocumentProvider and I modified the createEditingDomain() to use my
own TransactionEditingDomain:
/**
* @generated NOT
*/
private TransactionalEditingDomain createEditingDomain() {
TransactionalEditingDomain editingDomain =
MyNewDiagramEditingDomainFactory.getInstance()
.createEditingDomain();
....
}
That was the only meaningful change I had to make. What I don't know
is, what kind of things are going to get out of sync now that I've
disabled the assertWrite() check in ChangeRecorder. So far so good but,
since I don't completely understand EMF transactions yet, I can't vouch
for this as a good solution.
Hope that helps!
Tomas Zijdemans wrote:
> How did you make your code use this new TransactionalEditingDomain ?
>
> I'd also like to modify my EObjects without a transaction :)
>
>
> Tomas
>
>
> Zac Woof wrote:
>> I've got it working now simply by making my own
>> TransactionalEditingDomain which is just a cut-and-paste from
>> org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFac tory$DiagramEditingDomain
>> except that the ChangeRecorder I return doesn't check for read/write
>> transactions when in debug mode:
>>
>> protected TransactionChangeRecorder
>> createChangeRecorder(ResourceSet rset) {
>> return new TransactionChangeRecorder(this, rset) {
>>
>> @Override
>> protected void assertWriting() {
>> if (!debugFile) super.assertWriting();
>> }
>> };
>>
>> }
>>
>> Everything seems to be working now and I get real-time updates in the
>> designer as the workflow is executing.
>> Zac Woof wrote:
>>> Thanks Jan,
>>>
>>> That's a good thought but the problem is that I use the same model
>>> project for the actual runtime version of the workflow engine,
>>> outside of the editor. I suppose I could overload each of the steps
>>> to accept an EditingDomain and create and execute a command there
>>> but, if possible, I'd like to keep that portion of the application as
>>> decoupled from the design-time code as possible.
>>>
>>> Jan Herriger wrote:
>>>> Hi Zac,
>>>>
>>>> my first thought was: why don't you put each workflow step into a
>>>> single command and execute them one after another? But this thought
>>>> may not be elaborated well ;-)
>>>>
>>>> Zac Woof schrieb:
>>>>> Is there a way to modify semantic objects in the editor domain
>>>>> without a transaction?
>>>>>
>>>>> What I'm trying to is this: I have a GMF diagram editor that builds
>>>>> a workflow. I'd like to build in a visual debugger where you can
>>>>> trigger the workflow (from some external event on a separate
>>>>> thread) and step through the workflow with some visual cue
>>>>> indicating the active workflow step.
>>>>>
>>>>> The problem I'm having is that because the workflow runtime portion
>>>>> is triggered by an outside event (not via a command) of course I
>>>>> get the "cannot modify xxx without write transaction..."
>>>>> exception. If I wrap the trigger in a command the workflow
>>>>> executes fine but I don't get notified of any of the changes until
>>>>> the current transaction commits (so they all happen at once).
>>>>>
>>>>> Optimally I'd like to be able to have a mode where the workflow
>>>>> runtime is allowed to modify the EObjects without a transaction and
>>>>> still have the notification events sent to my edit parts so they
>>>>> get updated in real time.
>>>>>
>>>>> I guess another option would be to have some kind of custom
>>>>> transaction that auto-commits after each change or something but
>>>>> I'm not sure where to begin or if what I'm trying to do is within
>>>>> the realm of reasonable possibility.
>>>>>
>>>>> Any ideas would be greatly appreciated!
>>>>> Thanks,
>>>>> Zac
|
|
|
Powered by
FUDForum. Page generated in 0.04193 seconds