Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Sharing a resource between transactional editing domains
Sharing a resource between transactional editing domains [message #1472148] Thu, 13 November 2014 16:40 Go to next message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Hi all,

I try to handle the following use case : two Graphiti editors display diagrams that are accessing a same and shared underlying business model.

Each editor is using a dedicated transactional editing domain (TED) which contains the resource holding the open diagram.

When the user modifies the name of a shape in a diagram, the modification must also take place for the name attribute of the corresponding element in the underlying business model.

Therefore, the resource containing the business model is added to the editor's TED so that the modifications can take place in both the diagram and the business model resources in a transactional context. This works fine and is implemented as follow :

TransactionalEditingDomain owningTED = TransactionUtil.getEditingDomain((Resource) editedElement.cdoResource());
TransactionalEditingDomain currentTED = getDiagramBehavior().getEditingDomain();
if (!currentTED.equals(owningTED)) {
  currentTED.getResourceSet().getResources().add(editedElement.cdoResource());
  if (owningTED != null) {
    owningTED.getResourceSet().getResources().remove(editedElement.cdoResource());
    TransactionUtil.disconnectFromEditingDomain((Resource) editedElement.cdoResource());
  }
}


At this stage, there's no 'owningTED' yet and 'currentTED' becomes the owning one.

If now, the second editor needs to access the business model resource to also apply a modification, the resource must be disconnected from the first TED and added to the second editor's one which is done by the same code lines as above.

This also works fine and the business model resource is "switching TEDs".

But, when the user goes back to the first editor and tries to undo the modification, it fails.

In this case, following the execution in the debugger shows that 'owningTED' is null when I was expecting it to hold the reference of the second editor's TED.
'TransactionUtil.getEditingDomain' returns null because editedElement.cdoResource() has apparently no containing resource set.

How comes it is not contained by the second editor's TED resource set anymore ?

Regards,

Laurent
Re: Sharing a resource between transactional editing domains [message #1472309 is a reply to message #1472148] Thu, 13 November 2014 19:35 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Laurent,

The TransactionalEditingDomain is most definitely designed not to share
resources with other editing domains. Each is a self-sufficient,
enclosed universe. I would recommend that either (a) each of your
graphiti editors have a distinct copy of the business model in its
editing domain, or else (b) let the graphiti editors share a single
editing domain between them.

Cheers,

Christian

On 2014-11-13 16:40:40 +0000, Laurent Le Moux said:

> Hi all,
>
> I try to handle the following use case : two Graphiti editors display
> diagrams that are accessing a same and shared underlying business model.
>
> Each editor is using a dedicated transactional editing domain (TED)
> which contains the resource holding the open diagram.
>
> When the user modifies the name of a shape in a diagram, the
> modification must also take place for the name attribute of the
> corresponding element in the underlying business model.
>
> Therefore, the resource containing the business model is added to the
> editor's TED so that the modifications can take place in both the
> diagram and the business model resources in a transactional context.
> This works fine and is implemented as follow :
>
>
> TransactionalEditingDomain owningTED =
> TransactionUtil.getEditingDomain((Resource)
> editedElement.cdoResource());
> TransactionalEditingDomain currentTED =
> getDiagramBehavior().getEditingDomain();
> if (!currentTED.equals(owningTED)) {
> currentTED.getResourceSet().getResources().add(editedElement.cdoResource());
> if (owningTED != null) {
>
> owningTED.getResourceSet().getResources().remove(editedElement.cdoResource());
>
> TransactionUtil.disconnectFromEditingDomain((Resource)
> editedElement.cdoResource());
> }
> }
>
>
> At this stage, there's no 'owningTED' yet and 'currentTED' becomes the
> owning one.
>
> If now, the second editor needs to access the business model resource
> to also apply a modification, the resource must be disconnected from
> the first TED and added to the second editor's one which is done by the
> same code lines as above.
>
> This also works fine and the business model resource is "switching TEDs".
>
> But, when the user goes back to the first editor and tries to undo the
> modification, it fails.
>
> In this case, following the execution in the debugger shows that
> 'owningTED' is null when I was expecting it to hold the reference of
> the second editor's TED.
> 'TransactionUtil.getEditingDomain' returns null because
> editedElement.cdoResource() has apparently no containing resource set.
>
> How comes it is not contained by the second editor's TED resource set anymore ?
>
> Regards,
>
> Laurent
Re: Sharing a resource between transactional editing domains [message #1472394 is a reply to message #1472309] Thu, 13 November 2014 21:09 Go to previous message
Laurent Le Moux is currently offline Laurent Le MouxFriend
Messages: 184
Registered: September 2011
Senior Member
Hi Christian,
Thanks for the clarification about the TED usage.
I'll have a look (once again Wink) at scenario (b)...
Cheers,
Laurent
Previous Topic:[CDO] User password change with new security manager
Next Topic:[CDO] ClassCastException in CDODeltaNotification for Enum-based attribute
Goto Forum:
  


Current Time: Thu Apr 25 23:35:39 GMT 2024

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

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

Back to the top