Home » Modeling » EMF » Model edit within a thread = no notification
| | | |
Re: Model edit within a thread = no notification [message #428443 is a reply to message #428421] |
Fri, 20 March 2009 22: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 23:10 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
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
>>
>>
>>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: Model edit within a thread = no notification [message #428447 is a reply to message #428421] |
Sat, 21 March 2009 12: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: Fri Apr 26 05:21:39 GMT 2024
Powered by FUDForum. Page generated in 0.05716 seconds
|