Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Model edit within a thread = no notification
Model edit within a thread = no notification [message #428394] Thu, 19 March 2009 15:32 Go to next message
Jennifer is currently offline JenniferFriend
Messages: 2
Registered: July 2009
Junior Member
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 #428399 is a reply to message #428394] Thu, 19 March 2009 17:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Jen,

Try setting a breakpoint on the method where you know a change is
happening and trace what happens to the notification it produces...


Jennifer wrote:
> 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
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Model edit within a thread = no notification [message #428421 is a reply to message #428399] Fri, 20 March 2009 16:13 Go to previous messageGo to next message
Jennifer is currently offline JenniferFriend
Messages: 2
Registered: July 2009
Junior Member
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 #428427 is a reply to message #428421] Fri, 20 March 2009 17:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Jen,

I don't really know. Hopefully Christian is still reading the
newsgroups questions...


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 #428443 is a reply to message #428421] Fri, 20 March 2009 22:28 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
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 Go to previous message
Eclipse UserFriend
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
>
>
>
Previous Topic:Unsettable attributes in editor
Next Topic:XMI serialisation persistent object id's
Goto Forum:
  


Current Time: Fri Apr 26 05:21:39 GMT 2024

Powered by FUDForum. Page generated in 0.05716 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top