Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Keeping contents of two nodes synchronized
Keeping contents of two nodes synchronized [message #536295] Thu, 27 May 2010 14:52 Go to next message
Pettax  is currently offline Pettax Friend
Messages: 7
Registered: April 2010
Junior Member
Hi,

I have two different node types (Node A and Node B) that contain a description (based on a DescriptionCompartmentEditPart). I want the description to be synchronized if I connect the two node types with a connection.

Basically, I would like the description to be stored in one place but be editable from two different nodes. Editing the description of Node A should be reflected in Node B and vice versa.

I'm thinking something like that Node A is the owner of the description and that Node B (when connected) gets a child added somehow that references the description child of Node A. How can I achieve this?

If I in the view factory for one of the node write something like

public class TextExtensionViewFactory extends TextShapeViewFactory {   
   @Override
   protected void decorateView(View containerView, View view, IAdaptable element, String semanticHint, int index, boolean persisted) {
      super.decorateView(containerView, view, element, semanticHint, index, persisted);
      view.setType(SemanticHints.TEXT_EXTENSION);
      getViewService().createNode(element, view, SemanticHints.DESCRIPTION, ViewUtil.APPEND, persisted, getPreferencesHint());
   }
}


I end up with something close to what I want to achieve. I get two description children on the node that are in sync, i.e. I can edit either one and the other gets updated. The reason for this, I guess, is that the statement

getViewService().createNode(element, view, SemanticHints.DESCRIPTION, ViewUtil.APPEND, persisted, getPreferencesHint());


get executed twice (once in the superclass). So how can I set up the Notation model to achieve something similar across nodes?

Btw, I using GMF Runtime. Nothing is generated.

Thanks,
Pettax
Re: Keeping contents of two nodes synchronized [message #536317 is a reply to message #536295] Thu, 27 May 2010 15:52 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

you can use EOpposite in your EMF model


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: Keeping contents of two nodes synchronized [message #536371 is a reply to message #536317] Thu, 27 May 2010 20:20 Go to previous message
Pettax  is currently offline Pettax Friend
Messages: 7
Registered: April 2010
Junior Member
Oh, does this apply if the nodes are only in the notational model, i.e. not in the semantic model? Do you mind providing a short code snippet on how to apply this in GMF Runtime?

Thanks,
Pettax
Previous Topic:Multiple figure types for one Ecore class
Next Topic:How to detect (& notify) that the size of a node has changed
Goto Forum:
  


Current Time: Sat May 25 14:52:35 GMT 2024

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

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

Back to the top