change attributes during runtime in transactional context [message #1052067] |
Mon, 29 April 2013 15:13 |
Phil H Messages: 267 Registered: November 2012 |
Senior Member |
|
|
Hi there,
When I add an element to my diagram, I want to give this element an initial name.
First I tried the following code:
if (this.resolveSemanticElement() instanceof Feature) {
Feature featureNode = (Feature) this.resolveSemanticElement();
if (featureNode.getName() == null) {
featureNode.setName("Feature");
}
}
By executing this code, the desired attribute changed, but I get always this execption:
java.lang.IllegalStateException: Cannot modify resource set without a write transaction
......
So I tried the following code (which works in another context), since it seems to be a problem with trancactions:
if (this.resolveSemanticElement() instanceof Feature) {
Feature featureNode = (Feature) this.resolveSemanticElement();
if (featureNode.getName() == null) {
TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) this).getEditingDomain();
SetRequest setRequestX = new SetRequest(editingDomain, featureNode,PldPackage.eINSTANCE.getFeature_Name(), "Feature");
SetValueCommand setX = new SetValueCommand(setRequestX);
try {
setX.execute(null, null);
} catch (ExecutionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
But then I get the following error:
java.lang.IllegalStateException: Cannot activate read/write transaction in read-only transaction context
What is going wrong?
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03299 seconds