Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF Transaction/Validation] How to exploit the live validation performed in a transaction?
[EMF Transaction/Validation] How to exploit the live validation performed in a transaction? [message #1647321] Tue, 03 March 2015 11:11 Go to next message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
Hello,

When executing a RecordingCommand on a TransactionalCommandStack, the Transaction framework automatically performs a live validation. When the validation fails with an error status, I get feedback from it by means of a RollbackException. So far, so good.

But is there any ways to "profit" from this live validation when the live validation doesn't return an error status, but a warning or an info?

For now, the only thing I could come up with is quite laborious : I've implemented an IValidationListener that registers every UI control from which originates a transaction. When a ValidationEvent is observed, it retrieves the appropriate UI control by means of the target of the Event, and asks for the appropriate decoration (warning, info, etc.). Laborious, and moreover error prone in regard to the registering and unregistering of the controls.

All this would be very much simplified if the UI control who launches the Recordingcommand also could retrieve its result, regardless of severity.

I've seen some solutions using databinding, but I do not want a validation and/or Transaction on every time a value, for instance in a Textfield, is modified.

Any ideas to do so differently ?

Thomas Elskens
Re: [EMF Transaction/Validation] How to exploit the live validation performed in a transaction? [message #1647601 is a reply to message #1647321] Tue, 03 March 2015 14:14 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Thomas,

The live validation really was intended primarily as a mechanism for
automatic roll-back of damaging changes, so it is geared towards checks
of "error" severity.

On successful (less severe than error) validation of a transaction, its
status is assigned from the result of validation. So, I would expect
that rather than a validation listener, a simpler ResourceSetListener
on the editing domain could implement the post-commit call-back to
retrieve the committed transaction's status via the transaction
attached to the ResourceSetChangedEvent.

Slightly more fancy might be to set a custom
TransactionValidator.Factory in the editing domain to shunt the
validation status off in some other direction. For example, it could
look for a special result-holder option in the transaction's options
map and put the status in there. A client such as your UI control then
could put that option when executing the command and retrieve the
status from it afterwards.

HTH,

Christian


On 2015-03-03 11:11:21 +0000, Thomas Elskens said:

> Hello,
>
> When executing a RecordingCommand on a TransactionalCommandStack, the
> Transaction framework automatically performs a live validation. When
> the validation fails with an error status, I get feedback from it by
> means of a RollbackException. So far, so good.
> But is there any ways to "profit" from this live validation when the
> live validation doesn't return an error status, but a warning or an
> info?
> For now, the only thing I could come up with is quite laborious : I've
> implemented an IValidationListener that registers every UI control from
> which originates a transaction. When a ValidationEvent is observed, it
> retrieves the appropriate UI control by means of the target of the
> Event, and asks for the appropriate decoration (warning, info, etc.).
> Laborious, and moreover error prone in regard to the registering and
> unregistering of the controls.
> All this would be very much simplified if the UI control who launches
> the Recordingcommand also could retrieve its result, regardless of
> severity.
> I've seen some solutions using databinding, but I do not want a
> validation and/or Transaction on every time a value, for instance in a
> Textfield, is modified.
> Any ideas to do so differently ?
>
> Thomas Elskens
Re: [EMF Transaction/Validation] How to exploit the live validation performed in a transaction? [message #1649445 is a reply to message #1647601] Wed, 04 March 2015 10:22 Go to previous message
Thomas Elskens is currently offline Thomas ElskensFriend
Messages: 159
Registered: September 2014
Location: Brussels - Belgium
Senior Member
Thanks a lot for the answer: tweaking the TransactionalEditingDomain yields exactly the results I was looking for, and for once it was even easy to implement Smile

I just had to override getValidatorFactory(), create a new TransactionalEditingDomainFactory, and override the validate method in ReadWriteValidatorImpl.

Thomas
Previous Topic:org.eclipselabs.emfjson on Maven repository?
Next Topic:Java Sun/Oracle xerces parser bug?
Goto Forum:
  


Current Time: Sat Apr 27 03:45:54 GMT 2024

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

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

Back to the top