Aug 25th, 2009, 07:12 PM
I am digging into the deeper parts of RCP trying to learn how to use it and how it is designed. Very nice so far, but I have some issues/questions. One of them is a fairly simple behavior I don't see in any of the examples/samples/integrations or code. I went digging and didn't see it anywhere. I did see where a person could build the support for it and it looks promising to use the RCP design to do this, but I won't know until I try.
Before I jump into it though, I thought I would ask so I am not reinventing the wheel, or worse, trying to do something that will so clash with RCP that it won't be practical (which I doubt).
At a past gig I did a lot of Swing development. We had our own homebrew sub-optimum methodology for binding beans to various Swing components using reflection (not my choice), but I went with it.
The point I am getting to is that I am a strong believer in the UI not letting the user make mistakes in data entry. For example, if the user is entering a zipcode, the user should never be allowed to enter alpha chars. The field shouldn't need to flag them, it just shouldn't allow them at all. Or better yet, the field might know what a valid zip code is and not allow an invalid zip even if the format is correct. Other feedback is great (field color, icons, etc.), but not allowing incorrect chars is very friendly and not rocket science.
In my previous gig I wrote a number of extensions of Document/Filter and TextComponent such that these were bound to a given bean and the resulting text components would examine the bean property they were bound to for a constraint annotation. So, it was fairly easy to annotate a property in a bean with constraints such as NotNullOrEmpty, MaxLength, MinLength, MinValue, MaxValue - that kind of thing. The text components would use the Document/Filter and document listeners to constrain the user input and give the user feedback on what was expected/etc.
So, the user could not enter an invalid value in many fields and they never had to delete invalid data. Like I said, not rocket science, and fairly common behavior in many apps.
I looked and did not see support for this in any RCP components. I saw one that used a document filter, others used JFormattedTextField which I am not too keen on. Every example I tried allowed non-numeric entry for numeric properties.
Anyway, here are my questions:
1) Is there something already that does this? I didn't see it in RCP, JGoodies or JIDE.
2) Assuming the answer to #1 is no, is there perceived value in this?
3) Is this practical to do with RCP?
I can replicate what I did at my previous gig in an OSS friendly way easily enough. Integrating it with RCP and implementing in the RCP way would actually take longer, although I see value in that instead of going off in my own direction without RCP.