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 |
Thomas Elskens 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 |
|
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
|
|
| |
Goto Forum:
Current Time: Sat Apr 27 03:45:54 GMT 2024
Powered by FUDForum. Page generated in 0.02992 seconds
|