Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Setting somethings in semantic model during validation
Setting somethings in semantic model during validation [message #1853991] Wed, 27 July 2022 08:15
Simon Tulia is currently offline Simon TuliaFriend
Messages: 14
Registered: January 2022
Junior Member
Hello all,

I would like to fix some broken names of some components in my model automatically. Actually, I can do it by providing a new operation action. So a user can do a right click and call the fixing function. However, I want to do it by abstracting from the user. So, the user will not be aware of these automatic fixes. I thought that I could perform these kind of automatic fixes during a semantic validation. However, I cannot run a write transaction during a validation and get this error when I call the execute function of a command stack object:

java.lang.IllegalStateException: Cannot activate read/write transaction in read-only transaction context.

I can understand the point, but could not find any solution for this. How can I call a function without requesting an action from the user?

Here is my code that is called during a validation:
public boolean fixComponents(EObject self){
    Component c = (Component) self;
    TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(self);
    CommandStack stack = domain.getCommandStack();
    RecordingCommand r = new RecordingCommand(domain){
        @Override
        protected void doExecute(){
            c.setName("SomeAutoGeneratedString");
        }
    }
    try{
        stack.execute(r);
    } catch(Exception e){
        System.err.println(e);    // Produces: java.lang.IllegalStateException: Cannot activate read/write transaction in read-only transaction context.
    }
}


Thanks in advance.
Previous Topic:Using ELK layouts in a Sirius based product
Next Topic:Sirius Web automatic layout
Goto Forum:
  


Current Time: Mon Jul 22 23:42:21 GMT 2024

Powered by FUDForum. Page generated in 0.03780 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top