|
Re: transaction and listeners [message #427908 is a reply to message #427901] |
Wed, 04 March 2009 21:38 |
Eclipse User |
|
|
|
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 |
Ali Koudri 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 |
Eclipse User |
|
|
|
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<-----
|
|
|
Powered by
FUDForum. Page generated in 0.02059 seconds