Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Disable validation rule if editor state is dirty
Disable validation rule if editor state is dirty [message #1849723] Mon, 31 January 2022 09:15 Go to next message
Yannick DAVELUY is currently offline Yannick DAVELUYFriend
Messages: 36
Registered: July 2020
Member
Hello,

In my Dsl editor I have an editor callback that generate an UUID on items of type ItemWithUUID if their UUID is empty.
On the other side I have a valiation rule that check that ItemWithUUID have a valid UUID.

I would like to disable this rule if the validation is runned from the XtextEditor and XtextEditor.isDirty() is true.

Is it possible ?

Regards,

Yannick
Re: Disable validation rule if editor state is dirty [message #1849773 is a reply to message #1849723] Wed, 02 February 2022 09:36 Go to previous message
Yannick DAVELUY is currently offline Yannick DAVELUYFriend
Messages: 36
Registered: July 2020
Member
Hello,

I found the following solution:

- Add in the UI plugin a custom DirtyStateEditorSupport
public class CustomDirtyStateEditorSupport extends DirtyStateEditorSupport
{
  @Override
  public void announceDirtyState(XtextResource resource)
  {
    super.announceDirtyState(resource);
    // update the modified state of the resource
    resource.setModified(isDirty());
  }

}

- Check in the validator if the resource is modified
  @Check
  public void myCheck(MyType p)
  {
      if (!p.eResource().isModified() && ...)
            error(...);
  }


This seems to works properly.

Regards

Yannick
Previous Topic:Xtend and Xtext
Next Topic:Adapting the generated java code from xtend
Goto Forum:
  


Current Time: Mon Oct 03 02:30:10 GMT 2022

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

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

Back to the top