I want to drag and drop some items out of a list into the model viewer. I already can do so but the node is always created at the top left of the viewer and i don't know how to create the node at the dropped location.
Here is the function that creates the node (x and y are the coordinates of the droplocation)
private View addNode(Node node, View deploymentView) {
// use the view service to create the types. This is a bit cleaner than
// using the sequence-diagram view provider directlys
final String nodeType = UMLVisualIDRegistry
.getType(org.eclipse.papyrus.uml.diagram.deployment.edit.parts.NodeEditPart.VISUAL_ID);
org.eclipse.gmf.runtime.notation.Node nodeView = ViewService.createNode(deploymentView.getDiagram(), node,
nodeType, UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
Bounds location = NotationFactory.eINSTANCE.createBounds();
System.out.println("Dropped at x: "+ (int)this.x + " y: "+ (int)this.y);
location.setX((int)this.x);
location.setY((int)this.y);
return nodeView;
}
Okay wasn't that hard to fix it ...