Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Create Diagram Node from code
Create Diagram Node from code [message #725631] Thu, 15 September 2011 11:43
janpojer is currently offline janpojerFriend
Messages: 40
Registered: July 2011

I have been battling with the issue of diagram node creation for a while now.
I am trying to create commands that will create ports (child nodes) to a certain function already in the model.
My function that creates requests is following:
for (Object v : getDiagram().getChildren()) {
	NodeImpl masterNode = (NodeImpl) v;
	final EObject masterObj = masterNode.basicGetElement();
	if (((XAbstractFunction) masterObj).getName().equals(object.getName())) {
        	//iterate through set and output its content just for validation
		for (List<String> listRP : setRP) {					
			IElementType type = FnElementTypes.RequiredPort_3007;
			ViewAndElementDescriptor viewDescriptor = new ViewAndElementDescriptor(
				new CreateElementRequestAdapter(
					new CreateElementRequest(
	        	CreateCommand crCmd = new CreateCommand(
				(View) masterNode
		getDiagramPart().getDiagramGraphicalViewer().getEditDomain().getCommandStack().execute(new ICommandProxy(crCmd));	

When debugging, the commands are proceeded, but no nodes are created. I am not sure whats wrong. No exception is thrown. May it be that I am using wrong EObject to get my EditingDomain? What EObject should I use? the semanticRoot or the EObject that represent the parent object for ports?
Function getDiagram returns Diagram and getRoot returns diagramEditPart.resolveSemanticElement()

Does anyone have any ideas where might be the problem?
Previous Topic:Iterating GMF diagram
Next Topic:Same type of diagram in the compartments
Goto Forum:

Current Time: Fri Mar 05 08:37:32 GMT 2021

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

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

Back to the top