Restrict the number of instances of an extension element

I have created an extension element to be added to logical functions as child.
I create the element from the project explorer by adding the element to the logical function.
I am able to create as many as want of the extension elements.
My question is, how can I force capella to allow the user to create
one and only one child element.

I don’t know if it’s possible declaratively. But you can prevent appearance of the element creation action with the capella MDEMenuItemContribution extension point. For example here’s what capella does to prevent addition of LogicalFunction elements in illegal places:
So you just would implement that interface, and in your selectionContribution method just check if the extension element already exists and return false in that case. Then hook up the extension like this:
Note that this only prevents creation of the element from the UI. From a semantic point, it would still be perfectly legal to have more than one extension element in the model, e.g. I’m not sure how you would handle “Copy/Paste” of your extension element into the same parent, etc.

Copyright © Eclipse Capella, the Eclipse Capella logo, Eclipse and the Eclipse logo are Trademarks of The Eclipse Foundation.