Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Use of ConnectionHandle to add new node with connection
Use of ConnectionHandle to add new node with connection [message #234666] Thu, 25 June 2009 12:41 Go to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi,

I have a gmf editor for which I have added a custom
ContainerNodeEditPolicy to the DiagramEditPart. In my custom
ContainerNodeEditPolicy I intercept CreateConnectionRequest request
with ContainerNodeEditPolicy.getPromptForConnectionAndEndCommand to
return a custom PromptForConnectionAndEndCommand which provide my custom
PopupMenu. One menu of this PopupMenu permits user to select a file
which will be a EAttribute value of a newly added model's element
connected to source model's element under sourceEditPart of used
ConnectionHandle.

When user has choosen his file, I use CreateViewAndElementRequest
request with location of ConnectionHandle's Popup location and get
corresponding command on my DiagramEditPart and execute it.
Then I use SetRequest to set values to previous created model's
element's EAttributes.
To finish I use CreateRelationshipRequest to add a EReference instance
between source model's element under the sourceEditPart of the
ConnectionHandle and previously created model's element.

The view of previously created model's element is visible but not his
EAttribute's values nor the Connection view, they are visible when I
save diagram, close editor and reopen diagram.

How can I do to see EAttribute and EReference related views.
DiagramEditPart.refresh() operation doesn't works.
Re: Use of ConnectionHandle to add new node with connection [message #234820 is a reply to message #234666] Mon, 29 June 2009 07:49 Go to previous message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080107010000090201080506
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Ok I understand that my previous message isn't so clear, I give code
which do the work, but I don't know how to explain more clearly.
The code represents a method after user have choosen a file, the file is
given in parameter to initialize new created model's element.

Thanks.

--------------080107010000090201080506
Content-Type: text/plain;
name="code.java"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="code.java"

cHJpdmF0ZSB2b2lkIGNyZWF0ZUFuZENvbm5lY3RUb0V4d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RpdFBhcnQo
YnVzaW5lc3NNb2RlbEVkaXRQYXJ0KTsNCgkJCQkJCSBDb21tYW5kIGRtbSA9 IG1kYVByb2pl
Y3RFZGl0UGFydC5nZXRDb21tYW5kKHJlcXVlc3QpOw0KCQkJCQkJIG1kYVBy b2plY3RFZGl0
UGFydC5nZXREaWFncmFtRWRpdERvbWFpbigpLmdldERpYWdyYW1Db21tYW5k U3RhY2soKS5l
eGVjdXRlKGRtbSk7DQoJCQkJCX0gDQoJCQkJfQ0KCQkJfQ0KCQl9DQoJfQ==
--------------080107010000090201080506--
Previous Topic:Arrange all without an editor
Next Topic:need help on GMF graphic definition, how to add a vertical line in a rectangle?
Goto Forum:
  


Current Time: Thu Feb 25 08:45:53 GMT 2021

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

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

Back to the top