Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Creating an edge between two nodes
Creating an edge between two nodes [message #188288] Wed, 21 May 2008 15:57
Eclipse UserFriend
Originally posted by: megiddo.meg-tech.com

Can anyone take a look at this code I'm using to try to generate an edge
between two nodes? It appears to be erroring out on
CreateRelationshipRequest, but I don't know why. Please excuse the
horrible method for getting targetEditPart, but I was concentrating on the
edge generation; both source and target are valid EditParts just below the
root level.

Thanks for any and all help, I've been trying to figure out how to
programmatically generate an edge for two days now.

final EditPart sourceEditPart = this.getParent();
final EditPart targetEditPart =
(EditPart)getParent().getParent().getChildren().get( 1 );
final PreferencesHint prefsHint = PreferencesHint.USE_DEFAULTS;
final ElementTypeRegistry typeRegistry = ElementTypeRegistry.getInstance();
final IElementType edgeType = typeRegistry.getElementType(
ShapesPackage.Literals.CONNECTION );

CreateRelationshipRequest crr = new CreateRelationshipRequest(
(EObject)sourceEditPart,
(EObject)targetEditPart, edgeType );
CreateElementRequestAdapter cera = new CreateElementRequestAdapter( crr );

ViewService.getInstance().createEdge(cera, getNotationView(),
ConnectionEditPart.VISUAL_ID + "", -1,
true, prefsHint);


-Brett
Previous Topic:Change Absolute Positions (Can't be so difficult???)
Next Topic:[Announce] GMF 2.1.0RC1 is available
Goto Forum:
  


Current Time: Fri Apr 19 23:38:53 GMT 2024

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

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

Back to the top