Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » transaction and listeners
transaction and listeners [message #427901] Wed, 04 March 2009 16:02 Go to next message
Ali Koudri is currently offline Ali KoudriFriend
Messages: 118
Registered: July 2009
Senior Member
Hi,

I try to implement a Demultiplexing listener in order to monitor changes
in my model. When the TransactionCommandStack of my editing domain
execute a command, it seems that listeners are not notified, I don't
know why. My listener are registered into the plugin through the
plugin.xml file.

Any idea ?
thx
Re: transaction and listeners [message #427908 is a reply to message #427901] Wed, 04 March 2009 21:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi,

Without any diagnostic information, I can only guess that the reason is
that your listener extension is registered against a different
editing-domain ID than the one that your editor is using.

What does your plugin.xml look like? Which registered editing domain is
your editor using? Are there any warnings/errors in the log regarding
unknown editing domain IDs in your listener registration? What kind of
NotificationFilter does your listener define?

HTH,

Christian

exquisitus wrote:
> Hi,
>
> I try to implement a Demultiplexing listener in order to monitor changes
> in my model. When the TransactionCommandStack of my editing domain
> execute a command, it seems that listeners are not notified, I don't
> know why. My listener are registered into the plugin through the
> plugin.xml file.
>
> Any idea ?
> thx
Re: transaction and listeners [message #427909 is a reply to message #427908] Wed, 04 March 2009 22:02 Go to previous messageGo to next message
Ali Koudri is currently offline Ali KoudriFriend
Messages: 118
Registered: July 2009
Senior Member
I checked that everything was fine (I guess). Here is a sample of my
plugin.xml:

<extension
point="org.eclipse.emf.transaction.editingDomains">
<editingDomain
factory="fr.mopcom.modal.tools.ModaltEditingDomainFactory"
id="fr.mopcom.modal.tools.editingDomain">
</editingDomain>
</extension>
<extension
point="org.eclipse.emf.transaction.listeners">
<listener

class="fr.mopcom.modal.tools.listeners.ModalResourceSetListener ">
<editingDomain
id="fr.mopcom.modal.tools.editingDomain">
</editingDomain></listener>
</extension>

Here is a sample of code modifying the CommandStack:

Command cmd = new RecordingCommand(editingDomain, "Add Element"){
@Override
protected void doExecute() {
PackageableElement element = (PackageableElement)
factory.create(metaClass);
element.setName(name);
pack.getOwnedElement().add(element);
try {
pack.eResource().save(editingDomain.getResourceSet().getLoad Options());
} catch (IOException e) {
e.printStackTrace();
}
}
};
try {
cmdStack.execute(cmd, Collections.EMPTY_MAP);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (RollbackException e) {
cmdStack.undo();
}

and finally the handleNotification of my listener:

@Override
protected void handleNotification(TransactionalEditingDomain domain,
Notification notification) {
System.out.println("notification occured");
}

I can't see what's wrong here.
thx.

Christian W. Damus a écrit :
> Hi,
>
> Without any diagnostic information, I can only guess that the reason is
> that your listener extension is registered against a different
> editing-domain ID than the one that your editor is using.
>
> What does your plugin.xml look like? Which registered editing domain is
> your editor using? Are there any warnings/errors in the log regarding
> unknown editing domain IDs in your listener registration? What kind of
> NotificationFilter does your listener define?
>
> HTH,
>
> Christian
>
> exquisitus wrote:
>> Hi,
>>
>> I try to implement a Demultiplexing listener in order to monitor
>> changes in my model. When the TransactionCommandStack of my editing
>> domain execute a command, it seems that listeners are not notified, I
>> don't know why. My listener are registered into the plugin through the
>> plugin.xml file.
>>
>> Any idea ?
>> thx
Re: transaction and listeners [message #427954 is a reply to message #427909] Fri, 06 March 2009 14:27 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

Hi,

The only piece missing from the snippets that you quoted is how you are
getting the editing domain from which you get the command stack to
execute the command. Are you retrieving it from the
TransactionalEditingDomain.Registry.INSTANCE using the same ID as the
extension XML?

As an aside, I see that you are saving a resource using the resource
set's default load options. Many load options don't pertain to the save
operation. Just pass an empty map (Collections.EMPTY_MAP) to get the
resource set's default save options.

Cheers,

Christian


exquisitus wrote:
> I checked that everything was fine (I guess). Here is a sample of my
> plugin.xml:
>
> <extension
> point="org.eclipse.emf.transaction.editingDomains">
> <editingDomain
> factory="fr.mopcom.modal.tools.ModaltEditingDomainFactory"
> id="fr.mopcom.modal.tools.editingDomain">
> </editingDomain>
> </extension>
> <extension
> point="org.eclipse.emf.transaction.listeners">
> <listener
>
> class="fr.mopcom.modal.tools.listeners.ModalResourceSetListener ">
> <editingDomain
> id="fr.mopcom.modal.tools.editingDomain">
> </editingDomain></listener>
> </extension>
>
> Here is a sample of code modifying the CommandStack:
>
> Command cmd = new RecordingCommand(editingDomain, "Add Element"){
> @Override
> protected void doExecute() {
> PackageableElement element = (PackageableElement)
> factory.create(metaClass);
> element.setName(name);
> pack.getOwnedElement().add(element);
> try {
>
> pack.eResource().save(editingDomain.getResourceSet().getLoad Options());
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
> };
> try {
> cmdStack.execute(cmd, Collections.EMPTY_MAP);
> } catch (InterruptedException e) {
> e.printStackTrace();
> } catch (RollbackException e) {
> cmdStack.undo();
> }
>
> and finally the handleNotification of my listener:
>
> @Override
> protected void handleNotification(TransactionalEditingDomain domain,
> Notification notification) {
> System.out.println("notification occured");
> }
>
> I can't see what's wrong here.
> thx.
>

-----8<-----
Previous Topic:Calling a function outside the ItemProvider
Next Topic:URI Encoding problem
Goto Forum:
  


Current Time: Thu Apr 18 02:47:31 GMT 2024

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

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

Back to the top