Bug 439877 - SiriusLayoutManager populated after VSM drop tool's tasks
Summary: SiriusLayoutManager populated after VSM drop tool's tasks
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Core (show other bugs)
Version: 1.0.0   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2014-07-18 05:50 EDT by Benoit Ries CLA
Modified: 2014-08-05 06:01 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benoit Ries CLA 2014-07-18 05:50:23 EDT
steps to reproduce:

In a VSM drop tool's task using a java service with the code below. 

The method call "SiriusLayoutDataManager.INSTANCE.getData()" will always return null.

----
 public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
Object diagram = parameters.get("diagram");
Object elementToLookFor = parameters.get("element");

if (diagram instanceof DNodeContainer) {
DNodeContainer dNodeContainer = (DNodeContainer) diagram;
DDiagramElement diagElt = lookForElementInContainerByEObject(dNodeContainer, elementToLookFor);
if (diagElt instanceof AbstractDNode) {
AbstractDNode abstractDNode = (AbstractDNode) diagElt;
//retrieve mouse drop location
LayoutData layoutData = SiriusLayoutDataManager.INSTANCE.getData(abstractDNode);

//set view location
View view = SiriusGMFHelper.getGmfView(abstractDNode);
Node gmfnode = (Node) view;
Bounds bounds = (Bounds) gmfnode.getLayoutConstraint();
bounds.setX(layoutData.getLocation().x);
bounds.setY(layoutData.getLocation().y);

}
return;
}
Comment 1 Benoit Ries CLA 2014-07-18 08:19:38 EDT
I forgot to add the code for the lookForElementInContainerByEObject(), see below:

-------------------
private DDiagramElement lookForElementInContainerByEObject(DContainer dContainer, Object objectToLookFor) {
 if (dContainer instanceof DSemanticDiagram) {
  DSemanticDiagram dSemanticDiagram = (DSemanticDiagram) dContainer;
  for (DDiagramElement diagElt : dSemanticDiagram.getDiagramElements()) {
   if (diagElt instanceof DNode || diagElt instanceof DNodeList) {
     if (diagElt.getTarget().equals(objectToLookFor)) {
       return diagElt;
     }
   }
  }
 }
 return null;
}