|
Re: Create slot programmatically when Classifier is set on InstanceSpecification [message #1414876 is a reply to message #1412586] |
Mon, 01 September 2014 13:47 |
Camille Letavernier Messages: 952 Registered: February 2011 |
Senior Member |
|
|
Hi Sofia,
The exception is due to the Transaction framework, which prevents edition of the model outside a... write transaction, as the exception says.
The simplest way to start a Transaction is to use a Command and the Papyrus CommandStack. For example, if you have an EObject which is already attached to the Papyrus model, use:
TransactionalEditingDomain domain = ServiceUtilsForEObject.getInstance().getTransactionalEditingDomain(eObject);
CommandStack stack = domain.getCommandStack();
stack.execute(myCommand);
Papyrus implements an action when a Classifier is dropped on an InstanceSpecification, to create a set of slots. Have a look at this command to see how it is implemented:
Plugin org.eclipse.papyrus.uml.diagram.dnd:
org.eclipse.papyrus.uml.diagram.dnd.strategy.instancespecification.command.SelectAndCreateSlotsCommand
Regards,
Camille
Camille Letavernier
|
|
|
Powered by
FUDForum. Page generated in 0.03195 seconds