Hi folks,
I'm trying to modify my UML model during it's validation and here is the piece of code I use to apply programatically a stereotype to the validated node.
Code:
public static void applyStereotype(final NamedElement obj, final IStereotypedElementType stereotype ){
if (obj.getAppliedStereotype(stereotype.getStereotypeName()) != null) return;
final TransactionalEditingDomain domain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain("org.eclipse.gmf.runtime.emf.core.compatibility.MSLEditingDomain");
CommandStack stack = domain.getCommandStack();
Command c = new RecordingCommand(domain, "apply stereotype"){
@Override
protected void doExecute() {
obj.applyStereotype(obj.getApplicableStereotype(stereotype.getStereotypeName()));
}
};
stack.execute(c);
return;
}
This code is called during validation of a selected UML object. There is no problem as far as the object is selected in project explorer. But when the object is selecting via diagram editor, the validation freezes ; the RecordingCommand is passed and executed, but never gives back to calling thread.
Does someone have an idea for me ?