Home » Modeling » EMF » Model edit within a thread = no notification
Model edit within a thread = no notification [message #428394] |
Thu, 19 March 2009 11:32  |
Eclipse User |
|
|
|
Hi,
Apologies if this is a stupid question or one that has been answered
before.
I am using EMF and building an RCP app. I have a transactional editing
domain and can successfully edit my EMF model (via a frontend) and receive
change notifications on my listener. The listener extends
ResourceSetListenerImpl and extends the transactionAboutToCommit method.
My problem is when I attempt to edit the EMF model from within a thread, I
followed the example here
< http://help.eclipse.org/stable/topic/org.eclipse.emf.transac tion.doc/tutorials/transactionTutorial.html>
(Runnable getLibraryName = new Runnable() etc) and can successfully modify
the model in the thread. The changes are definitely made, HOWEVER the
listener is never notified.
Am I missing something obvious? I can post sample code if that would help.
Thank you lots in anticiapation,
Jen
|
|
| | | |
Re: Model edit within a thread = no notification [message #428443 is a reply to message #428421] |
Fri, 20 March 2009 18:28   |
Eclipse User |
|
|
|
Originally posted by: richkulp.us.NO_SPAM.ibm.com
Hi,
Did you ever execute the command? Just calling setCurrentState doesn't
execute the command. It just sets the command up. The actual execution
and notification won't occur until the command is actually executed.
Jennifer wrote:
>
> Hmmmm so I breakpointed and stepped through as suggested. The
> notification is generated fine and seems to follow the full command
> execution path no problem. I am very confused. A code sample....
>
> public static void setCurrentState(TransactionalEditingDomain
> editingDomain, CompoundCommand compoundCommand, final StateStore
> stateStore,
> final int state)
> {
> compoundCommand.append(new RecordingCommand(editingDomain, "Set
> StateStore state")
> {
> protected void doExecute()
> {
> stateStore.setCurrentState(state);
> }
> });
> }
>
> causes a change to the model but....
>
> Runnable stateRunnable = new Runnable()
> {
> public void run()
> {
> try
> {
> setCurrentState(editingDomain, compoundCommand, stateStore,
> state);
> }
> catch (Exception e)
> {
> // Handle the interrupted exception in an graceful way ...
> e.printStackTrace();
> }
> }
> };
>
> Thread stateThread = new Thread(stateRunnable);
> stateThread.start();
>
> .... has no effect.
>
> Thanks in advance for any thoughts or ideas!
>
> Jen
>
>
>
--
Thanks,
Rich Kulp
|
|
|
Re: Model edit within a thread = no notification [message #428444 is a reply to message #428443] |
Fri, 20 March 2009 19:10   |
Eclipse User |
|
|
|
Rich,
It seems obvious now that you point it out! Thanks!!
Rich Kulp wrote:
> Hi,
>
> Did you ever execute the command? Just calling setCurrentState doesn't
> execute the command. It just sets the command up. The actual execution
> and notification won't occur until the command is actually executed.
>
>
> Jennifer wrote:
>>
>> Hmmmm so I breakpointed and stepped through as suggested. The
>> notification is generated fine and seems to follow the full command
>> execution path no problem. I am very confused. A code sample....
>>
>> public static void setCurrentState(TransactionalEditingDomain
>> editingDomain, CompoundCommand compoundCommand, final StateStore
>> stateStore,
>> final int state)
>> {
>> compoundCommand.append(new RecordingCommand(editingDomain, "Set
>> StateStore state")
>> {
>> protected void doExecute()
>> {
>> stateStore.setCurrentState(state);
>> }
>> });
>> }
>>
>> causes a change to the model but....
>>
>> Runnable stateRunnable = new Runnable()
>> {
>> public void run()
>> {
>> try
>> {
>> setCurrentState(editingDomain, compoundCommand,
>> stateStore, state);
>> }
>> catch (Exception e)
>> {
>> // Handle the interrupted exception in an graceful way ...
>> e.printStackTrace();
>> }
>> }
>> };
>>
>> Thread stateThread = new Thread(stateRunnable);
>> stateThread.start();
>>
>> .... has no effect.
>>
>> Thanks in advance for any thoughts or ideas!
>>
>> Jen
>>
>>
>>
>
|
|
|
Re: Model edit within a thread = no notification [message #428447 is a reply to message #428421] |
Sat, 21 March 2009 08:11  |
Eclipse User |
|
|
|
Originally posted by: give.a.damus.gmail.com
Hi, Jennifer,
If you see a notification on one thread but not another, then perhaps in
the other case something is causing the transaction to roll back? That
would cause a post-commit listener not to be notified (although, you
have a pre-commit listener).
The transaction API can't tell the difference between one thread and
another, so you really shouldn't see different behaviour.
Put a break-point in the commit() method of the TransactionImpl to see
what is happening. You should be able to step into the
TransactionalEditingDomainImpl::precommit(...) method which is where the
notification of pre-commit listeners such as yours occurs. Perhaps a
roll-back is occurring before your listener is notified, or something
else is evidently amiss here.
HTH,
Christian
Jennifer wrote:
>
> Hmmmm so I breakpointed and stepped through as suggested. The
> notification is generated fine and seems to follow the full command
> execution path no problem. I am very confused. A code sample....
>
> public static void setCurrentState(TransactionalEditingDomain
> editingDomain, CompoundCommand compoundCommand, final StateStore
> stateStore,
> final int state)
> {
> compoundCommand.append(new RecordingCommand(editingDomain, "Set
> StateStore state")
> {
> protected void doExecute()
> {
> stateStore.setCurrentState(state);
> }
> });
> }
>
> causes a change to the model but....
>
> Runnable stateRunnable = new Runnable()
> {
> public void run()
> {
> try
> {
> setCurrentState(editingDomain, compoundCommand, stateStore,
> state);
> }
> catch (Exception e)
> {
> // Handle the interrupted exception in an graceful way ...
> e.printStackTrace();
> }
> }
> };
>
> Thread stateThread = new Thread(stateRunnable);
> stateThread.start();
>
> .... has no effect.
>
> Thanks in advance for any thoughts or ideas!
>
> Jen
>
>
>
|
|
|
Goto Forum:
Current Time: Mon Jul 14 21:29:09 EDT 2025
Powered by FUDForum. Page generated in 0.12072 seconds
|