2016-12-19 2 views
0

リストから項目をドラッグしてモデルビューアにドロップしたいと考えています。 私はすでにそうすることができますが、ノードは常にビューアの左上に作成され、ドロップされた場所にノードを作成する方法はわかりません。ここEclipse-Papyrusは、ドロップアウト時にノードを作成します

は...ノードを作成する関数(x及びyは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; 
} 

答えて

0

さて、ハードそれを修正することはなかったで

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); 


    System.out.println("Dropped at x: "+ (int)this.x + " y: "+ (int)this.y); 

    //for(int i=0;i<nodeView.getDiagram().getChildren().size();i++)System.out.println(nodeView.getDiagram().getChildren().get(i).toString()); 

    nodeView.setLayoutConstraint(NotationFactory.eINSTANCE 
      .createLocation()); 
    Location location = (Location) nodeView.getLayoutConstraint(); 
    location.setX((int)this.x); 
    location.setY((int)this.y); 
    return nodeView; 
} 
関連する問題