Home » Modeling » GMF (Graphical Modeling Framework) » Diagram view doesn't display new edges after adding an edge programmatically
Diagram view doesn't display new edges after adding an edge programmatically [message #639235] |
Mon, 15 November 2010 12:20  |
Eclipse User |
|
|
|
Originally posted by: Grit.Dudeck.gmx.net
Hello,
I have the following problem:
I want to modify models programmatically using the EMF reflective API.
The models are opened in a GMF-based editor and the changes are applied
within AbstractEMFOperations using the related
TransactionalEditingDomain. All works fine and the changes are displayed
automatically in the diagram view. But when adding a new connection to
the model and afterward adding the corresponding edge to the .notation
model, the diagram view is not refreshed. When I close and reopen the
model with the editor, the edges are displayed...
Is there any solution?
Thanks
Grit
|
|
| |
Re: Diagram view doesn't display new edges after adding an edge programmatically [message #639272 is a reply to message #639246] |
Mon, 15 November 2010 14:55   |
Eclipse User |
|
|
|
Originally posted by: Grit.Dudeck.gmx.net
Am 15.11.2010 18:58, schrieb Asiri Rathnayake:
> Eclipse User wrote on Mon, 15 November 2010 12:20
>> Originally posted by: Grit.Dudeck.gmx.net
>>
>> But when adding a new connection to the model and afterward adding the
>> corresponding edge to the .notation model, the diagram view is not
>> refreshed. When I close and reopen the model with the editor, the
>> edges are displayed...
>
>
> I believe you are trying to accomplish the task in two steps, create the
> model element corresponding to the connection and then update the
> notational model. Did you try using
> CreateConnectionViewAndElementRequest instead? this request encapsulates
> both of the tasks AFAIU, corresponding javadoc provides a wealth of
> information on how to use it (and googling will definitely find you
> sample code).
>
> Hope this helps.
>
> - Asiri
>
But I don't want to use any GMF code but the reflective EMF API to
modify the model/notational model. When I want to add an element in the
model/notational model, an AbstractEMFOperation with the following code
is excecuted:
EList<Object> oldList = eObject.eGet(feature);
oldList.add(position,newValue);
But I don't understand why the diagram view isn't refreshed
automatically after an edge has been added. It works only for nodes...
Regards, Grit
|
|
| | | | | | |
Re: Diagram view doesn't display new edges after adding an edge programmatically [message #639597 is a reply to message #639272] |
Wed, 17 November 2010 01:44   |
Eclipse User |
|
|
|
Hi Grit,
Eclipse User wrote on Mon, 15 November 2010 14:55 | Originally posted by: Grit.Dudeck.gmx.net
EList<Object> oldList = eObject.eGet(feature);
oldList.add(position,newValue);
But I don't understand why the diagram view isn't refreshed
automatically after an edge has been added. It works only for nodes...
|
If I understand your code correctly, here you are only updating your business model (adding a connection model object into your business model). How / where do you update the notational model? AFAIU if you only update the business model, your diagram will only be synchronized with it once you close and re-open your diagram file. Is it possible for you to create your edge using the ViewService as below (?):
View sourceView = ... // Source view (notational)
View targetView = ... // Target view (notational)
EObject connectionObj = ... // Business model object corresponding to your connection.
String connectionType = YourPackageElementTypes.<link_type>
preferenceHint = containerEditPart.getDiagramPreferencesHint();
ViewService.createEdge(sourceView, targetView, connectionObj, connectionType, preferencesHint)
Hope this helps.
- Asiri
[Updated on: Wed, 17 November 2010 01:45] by Moderator
|
|
|
Re: Diagram view doesn't display new edges after adding an edge programmatically [message #639629 is a reply to message #639597] |
Wed, 17 November 2010 04:06   |
Eclipse User |
|
|
|
Hi Asiri,
Am 17.11.2010 07:44, schrieb Asiri Rathnayake:
> Hi Grit,
>
> Eclipse User wrote on Mon, 15 November 2010 14:55
>> Originally posted by: Grit.Dudeck.gmx.net
>>
>> EList<Object> oldList = eObject.eGet(feature);
>> oldList.add(position,newValue);
>>
>> But I don't understand why the diagram view isn't refreshed
>> automatically after an edge has been added. It works only for nodes...
>
>
> If I understand your code correctly, here you are only updating your
> business model (adding a connection model object into your business
> model). How / where do you update the notational model?
The scenario is the following:
I record changes made to a model, which is modified in a GMF-based
editor. Than, these change are applied to another model. This means, if
I add an edge to the diagram via drag and drop, a notification is
recorded (an Edge object is added to the feature 'edges' for example).
So, with the code above, the edge object is added. If the edge is
created via the palette, I get also a notification that a connection was
added to the business-model. Because the notifications are processed
step-by-step, the connection is added to the business-model first and
afterward the corresponding edge is added to the notational model (with
the code above).
I do this procedure for each change and the diagram view for the updated
model is always refreshed automatically except for edges...
> AFAIU if you
> only update the business model, your diagram will only be synchronized
> with it once you close and re-open your diagram file. Is it possible for
> you to create your edge using the ViewService as below (?):
>
>
> View sourceView = ... // Source view (notational)
> View targetView = ... // Target view (notational)
> EObject connectionObj = ... // Business model object corresponding to
> your connection.
> String connectionType = YourPackageElementTypes.<link_type>
> preferenceHint = containerEditPart.getDiagramPreferencesHint();
> ViewService.createEdge(sourceView, targetView, connectionObj,
> connectionType, preferencesHint)
>
> Hope this helps.
>
> - Asiri
Grit
|
|
|
Re: Diagram view doesn't display new edges after adding an edge programmatically [message #639633 is a reply to message #639629] |
Wed, 17 November 2010 04:58   |
Eclipse User |
|
|
|
Hi Grit,
Grit Dudeck wrote on Wed, 17 November 2010 04:06 |
The scenario is the following:
I record changes made to a model, which is modified in a GMF-based
editor. Than, these change are applied to another model. This means, if
I add an edge to the diagram via drag and drop, a notification is
recorded (an Edge object is added to the feature 'edges' for example).
So, with the code above, the edge object is added. If the edge is
created via the palette, I get also a notification that a connection was
added to the business-model. Because the notifications are processed
step-by-step, the connection is added to the business-model first and
afterward the corresponding edge is added to the notational model (with
the code above).
I do this procedure for each change and the diagram view for the updated
model is always refreshed automatically except for edges...
|
I'm afraid I'm unable to grasp / understand your use-case Let's hope someone else can help you out 
- Asiri
|
|
| |
Goto Forum:
Current Time: Thu Jul 03 09:13:17 EDT 2025
Powered by FUDForum. Page generated in 0.64109 seconds
|