Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Programmatically create a semantic element and refresh the view
Programmatically create a semantic element and refresh the view [message #144716] Mon, 30 July 2007 05:38
Eclipse UserFriend
Originally posted by: bmoros.um.es

Hello everybody,

I have defined a metamodel where the concepts of Attribute (characterized by
its name and its type) and AttributeInstance (characterized by its name and
its value) are specified. In the metamodel, there is a Ereference
'instanceOf' between AttributeInstance and Attribute, meaning that an
AttributeInstance is an instance of an Attribute. For instance, the
Attribute
A->[name = cost, type = integer] and one AttributeInstance [name = cost,
value = 10, instanceOf -> A].Consequently, in the editor (generated using
GMF) when the instanceOf reference is set, the name and the type of the
AttributeInstance have to be set accordingly.

To achieve this, I have overridden the handleNotificationEvent method in
AttributeInstanceEditPart class to handle the events related to the
instanceOf relationship. When the 'instanceOf' value is set then I create
the 'value' object according to the type of the selected attribute. But it
does not work since I should create the view of the semantic element at the
same time. I have tryed to create a ViewAndElementRequest but it does not
work either. The piece of code in the handleNotificationEvent method
regarding the creation of the request looks like this:

CreateViewAndElementRequest createRequest = new CreateViewAndElementRequest(

elementType,value,this.getDiagramPreferencesHint());
Command command = this.getCommand(createRequest);
DiagramCommandStack commandStack =
this.getDiagramEditDomain().getDiagramCommandStack();
commandStack.execute(command);

I really do not know where I have to create the pair (semantic element-view)
and how this pair is linked to the model and how it is refreshed in the
diagram. Any hint would be appreciated!!!

Thanks in advance for your time,

Bego
Previous Topic:Automatic creation of nodes
Next Topic:Modify values diagram elements variables
Goto Forum:
  


Current Time: Mon Apr 28 03:03:37 EDT 2025

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

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

Back to the top