Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » Simple custom constraint on a property editor
Simple custom constraint on a property editor [message #948778] Thu, 18 October 2012 07:13 Go to next message
Hazem ELRAFFIEE is currently offline Hazem ELRAFFIEE
Messages: 59
Registered: September 2012
Member
Hello again Smile

Let's say I have a composite with 2 property editors:

<property-editor>dimension</property-editor>
<property-editor>values</property-editor>


Property "dimension" is expected to be entered in the style "2x3" with 2 integers separated by "x"
Property "values" is expected to be something like "12,2,4,2,0,-5" with 6 integers separated by "," while if the dimension is changed to be "1x3" values should be 3 integers.

more generally, I'd like to write Java code that describes the validation of each property editor and the dependency between each other. How can I achieve that?

Thanks for concern Smile
Re: Simple custom constraint on a property editor [message #949118 is a reply to message #948778] Thu, 18 October 2012 14:03 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 935
Registered: July 2009
Senior Member
To implement a custom constraint, you need to implement ValidationService and attach it to the property using @Service annotation. Take a look at DuplicateContactValidationService in the contacts sample.

- Konstantin
Re: Simple custom constraint on a property editor [message #952079 is a reply to message #949118] Sun, 21 October 2012 02:13 Go to previous messageGo to next message
Hazem ELRAFFIEE is currently offline Hazem ELRAFFIEE
Messages: 59
Registered: September 2012
Member
Just what I needed Smile Thnx a lot Smile
Re: Simple custom constraint on a property editor [message #952138 is a reply to message #952079] Sun, 21 October 2012 03:20 Go to previous messageGo to next message
Hazem ELRAFFIEE is currently offline Hazem ELRAFFIEE
Messages: 59
Registered: September 2012
Member
I just don't really understand what you did in the "init" and "dispose" functions .. could you give a simple illustration?
Re: Simple custom constraint on a property editor [message #953870 is a reply to message #952138] Mon, 22 October 2012 11:52 Go to previous message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 935
Registered: July 2009
Senior Member
A ValidationService implementation is responsible for informing the system when the state of its validation is likely to have changed. That's done via the broadcast() method that you see being called in the listener. The listener is attached to properties that are involved in the validation computation during init(). In dispose(), the listener is removed.

- Konstantin
Previous Topic:Element ordering not according to XSD
Next Topic:Different editors for same file-extensions
Goto Forum:
  


Current Time: Wed Jul 23 01:52:34 EDT 2014

Powered by FUDForum. Page generated in 0.18102 seconds