Skip to main content



      Home
Home » Modeling » EMF » TransactionalEditingDomain Lifecycle
TransactionalEditingDomain Lifecycle [message #517804] Mon, 01 March 2010 22:26 Go to next message
Eclipse UserFriend
Hi,

how can I detect the transactional editing domains disposal? Querying
the domain or the resource set for
org.eclipse.emf.transaction.TransactionalEditingDomain.Lifec ycle doesn't
return any result.

Scenario:
I need to deny a command execution during an final selection change,
while my (gmf) editor is disposing. The editing domain throws an NPE, if
I try to execute the command while the editor is disposing.

Caused by: java.lang.NullPointerException
at
org.eclipse.emf.transaction.impl.TransactionImpl.start(Trans actionImpl.java:257)
at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.startTransaction(TransactionalEditingDomainImpl.java:409 )
at
org.eclipse.emf.transaction.impl.TransactionalEditingDomainI mpl.runExclusive(TransactionalEditingDomainImpl.java:306)
at
org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPa rt.getCommand(GraphicalEditPart.java:477)

Thanks in advance,
Sven
Re: TransactionalEditingDomain Lifecycle [message #517842 is a reply to message #517804] Tue, 02 March 2010 05:13 Go to previous messageGo to next message
Eclipse UserFriend
Hi Sven,

your generated diagram registers a DiagramEditingDomainFactory in its plugin.xml:
    <extension
         point="org.eclipse.emf.transaction.editingDomains">
      <editingDomain
            factory="org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory"
            id="fooDiagramEditingDomain">
      </editingDomain>
   </extension>


You could write an aspect for GMF's plugin.xpt in gmf.codegen/templates/xpt/plugin/plugin.xpt to have your own DiagramEditingDomainFactory registered instead. Then GMF could use your TransactionalEditingDomain extended by your disposal detection code.

Cheers
Rob
Re: TransactionalEditingDomain Lifecycle [message #517846 is a reply to message #517842] Tue, 02 March 2010 05:28 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Robert,

got it. I'm just asking myself, if the Lifecyle is not proposed to be
used outside, since the getLifecyle() is protected and final at the
TransactionalEditingDomainImpl. Its not the issue, since I'm already
using a customized domain factory. But how about not being able to do so
- e.g. using an external (closed source) domain factory?

Sven
Re: TransactionalEditingDomain Lifecycle [message #517908 is a reply to message #517846] Tue, 02 March 2010 08:56 Go to previous messageGo to next message
Eclipse UserFriend
Hi, Sven,

The Lifecycle is an adapter interface that is optionally implemented by
a TransactionalEditingDomain (an API evolution strategy). The stock
domain implementation does provide a Lifecycle adapter.

The way to access it is like

TransactionalEditingDomain domain = ... ;
TransactionalEditingDomainListener listener = ... ;

TransactionalEditingDomain.Lifecycle lifecycle =
TransactionUtil.getAdapter(domain,
TransactionalEditingDomain.Lifecycle.class);

if (lifecycle != null) {
lifecycle.addTransactionalEditingDomainListener(listener);
}

Your listener, then, will be notified of the domain-disposing event.

HTH,

Christian


On 02/03/10 05:28 AM, Sven Krause wrote:
> Thanks Robert,
>
> got it. I'm just asking myself, if the Lifecyle is not proposed to be
> used outside, since the getLifecyle() is protected and final at the
> TransactionalEditingDomainImpl. Its not the issue, since I'm already
> using a customized domain factory. But how about not being able to do so
> - e.g. using an external (closed source) domain factory?
>
> Sven
Re: TransactionalEditingDomain Lifecycle [message #517957 is a reply to message #517908] Tue, 02 March 2010 10:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

thats exact the point. Asking the editing domain for adapting the
Lifecyle type does not return an instance. Who needs to register this
adapter? Is it done internally or is it in the domain factories response?

Sven
Re: TransactionalEditingDomain Lifecycle [message #517981 is a reply to message #517957] Tue, 02 March 2010 11:04 Go to previous message
Eclipse UserFriend
Ah! Sorry, Sven,

You must have a domain implementation that was created prior to the EMF
Transaction 1.3 release and (a) implemented the
TransactionalEditingDomain interface without extending the stock impl
class, and (b) wasn't updated to provide the new-in-1.3 adapter interface.

I'm afraid that the domain implementation, itself, must provide the
adapter. I'm afraid it would be hard for an external object to
intercept these life-cycle events ... unless, of course, the
implementation provides API that makes it feasible.

Cheers,

Christian


On 02/03/10 10:27 AM, Sven Krause wrote:
> Hi Christian,
>
> thats exact the point. Asking the editing domain for adapting the
> Lifecyle type does not return an instance. Who needs to register this
> adapter? Is it done internally or is it in the domain factories response?
>
> Sven
Previous Topic:[TENEO] Problem to generate mapping when using multiple ecore models
Next Topic:Using Jet with recursive data structures
Goto Forum:
  


Current Time: Fri Jul 04 10:33:14 EDT 2025

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

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

Back to the top