|
Re: Adding a Block under Package with Eclipse EMF programatically [message #1850095 is a reply to message #1850086] |
Tue, 15 February 2022 16:24 |
|
This should do the trick:
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.util.TransactionalEditingDomain;
import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Stereotype;
...
TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(yourPackage);
domain.getCommandStack().execute(new RecordingCommand(domain, "Create a block", "Some description...") {
@Override
protected void doExecute() {
Class yourBlock = yourPackage.createOwnedClass("yourBlockName", false);
Stereotype blockStereotype = block.getApplicableStereotype("SysML::Blocks::Block");
yourBlock.applyStereotype(blockStereotype);
}
});
/Thomas
Thomas Wiman
MetaModelAgent Product Manager
|
|
|
|
Powered by
FUDForum. Page generated in 0.03419 seconds