Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Placing bordered nodes at the same location when copying a model element
Placing bordered nodes at the same location when copying a model element [message #1842739] Wed, 30 June 2021 09:10
Francesco Bedini is currently offline Francesco BediniFriend
Messages: 26
Registered: March 2018
Junior Member
I am implementing some Java services for allowing changing the type of certain elements:
index.php/fa/40710/0/
index.php/fa/40711/0/

In the java service, I create a new model element, copy the old attributes and delete the original model element.

I finally managed to make Sirius place it in the same location and with the same size as the previous element, but I can't place the pins on the Container edge at the same position on the new container.
index.php/fa/40712/0/
How should I do it?

Calling the service in an Operation "changeContext" like:
aql:self.oclAsType(myPackage::Component).transformToComponent(views)


And here is the Service code so far:
public void transformToComponent(Component c, ArrayList<EObject> containingViews) {
		final Component newComponent = myFactory.eINSTANCE.createComponent();
                // ... copy attributes ...

		// Give to the new component the same size/position as the old one.
		if (containingViews != null && containingViews.size() > 0) {
			DNodeContainer existingNode = (DNodeContainer) containingViews.get(0);
			IGraphicalEditPart editPart = getEditPart(existingNode);
			if (editPart instanceof ShapeEditPart) {
				ShapeEditPart part = (ShapeEditPart) editPart;
				SiriusLayoutDataManager.INSTANCE
						.addData(new RootLayoutData(existingNode.eContainer(), part.getLocation(), part.getSize()));
			}
			
			//TODO: Place bordered nodes at the same position:
			existingNode.getOwnedBorderedNodes().stream().forEach(bn -> {
				IGraphicalEditPart editPart2 = getEditPart(bn);
				System.out.println(editPart2.toString());
				if (editPart2 instanceof ShapeEditPart) {
					ShapeEditPart part = (ShapeEditPart) editPart2;
					SiriusLayoutDataManager.INSTANCE
							.addData(new RootLayoutData(bn.eContainer(), part.getLocation(), part.getSize()));
				}
			});
		}

		// Delete the old component
		EcoreUtil.remove(c);
	}


Thanks in advance for any hint :)
  • Attachment: 1.jpg
    (Size: 8.26KB, Downloaded 150 times)
  • Attachment: 2.jpg
    (Size: 101.91KB, Downloaded 162 times)
  • Attachment: 3.jpg
    (Size: 10.71KB, Downloaded 149 times)

[Updated on: Wed, 30 June 2021 09:11]

Report message to a moderator

Previous Topic:Javadoc building problem
Next Topic:Import of enumeration type cannot be resolved in service
Goto Forum:
  


Current Time: Wed Sep 28 17:16:26 GMT 2022

Powered by FUDForum. Page generated in 0.01996 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top