Community
Participate
Working Groups
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; }
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; }