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 07:43
janpojer is currently offline janpojer
Messages: 40
Registered: July 2011
Member
Hi,

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(
			        		TransactionUtil.getEditingDomain(getRoot()),
						masterObj,
						type,
						FnPackage.eINSTANCE.getXAbstractFunction_Ports()
					)
				),	
				Node.class, 
				FnDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT
			);
	        	CreateCommand crCmd = new CreateCommand(
			        TransactionUtil.getEditingDomain(getRoot()),
		        	viewDescriptor,
				(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 Jul 25 14:29:47 EDT 2014

Powered by FUDForum. Page generated in 0.02295 seconds