Community
Participate
Working Groups
Try subclassing -- there are only about two or three methods that can be overridden since nearly all methods use private fields. E.g., I wanted to experiment with an alternate validation strategy, which should only require a new c'tor, and overriding "Text getTextControl(Composite parent)" and "void setValidateStrategy(int value)". But because those methods (and the c'tor) use *private* fields, one has to copy all those fields and all the methods that use them, and then all the fields *those* methods use, plus all the methods that use that second set of fields; the transitive closure is the entire class except for: "void setEnabled(boolean enabled, Composite parent)" and "int getNumberOfControls()" (And then in the end, something else goes wrong and the result has a 0-width text-field. Ugh.) So, please either make all the fields protected, or at least remove from the javadoc the claim that the class can be subclassed.
I see 10 protected methods + a number of public ... it can be subclassed. This is an enhancement request to try provide different validation strategies over the provided VALIDATE_ON_KEY_STROKE and VALIDATE_ON_FOCUS_LOST. PW
There are currently no plans to work on this however I would be happy to look over a contribution
(In reply to comment #2) > There are currently no plans to work on this however I would be happy to look > over a contribution > I am currently on vacation, but could work on this in July/August. There are indeed a bunch of protected methods etc., but some of them use *private* members... My contribution would deal with that. If that sounds good to you, I will provide more details and re-open in July/Aug? Paul K
Sure.
(In reply to comment #4) > Sure. > How important is it that I keep to the coding style implied by the current state of StringFieldEditor? (E.g., it gives all but one of its methods in alpha order -- but other Eclipse code follows other conventions.)
The order was not a convention - just someone hitting sort. Not to worry.
Tod -- Sooner than I expected, I have this ready -- (1) modified StringFieldEditor, plus (2) two example extensions (InetAddress.. and Regex...) showing how/why to allow subclasses to "extend" the validation-scheme. So -- how to submit? reopen the bug (and perhaps rename in some way), and attach the java files? (They are stuffed in some random package-of-convenience in one of my projects.)
Please feel free to reopen and attach your patch. I'll try and get to it in the milestone you attach it in.
Created attachment 72750 [details] proposed patch for StringFieldEditor NOTE: the class was created in my own package (since I do not have the Eclipse code checked out) -- you'll need to change the package (and perhaps organize imports).
Created attachment 72752 [details] test-case #1 (example subclass) for patch This subclass allows the user to enter a regex, but does not validate until the user presses ENTER or UP or DOWN (since validating on each keystroke would be intrusive/annoying, as most partial regex's are invalid).
Created attachment 72753 [details] test-case #2 (example subclass) for patch This subclass allows the user to enter an InetAddress, either numerical or textual, but does not validate until the user presses ENTER or UP or DOWN -- since valdation is usually lengthy and validating on each keystroke would be annoying; validating on loss-of-focus would also be annoying, since the error-message would not appear until the user re-focussed. (One might think of placing a "wait" message as a temporary error-message, or else asking that pref-pages be like wizards and have a progress-mon available.)
Paul comment #9 isn't a patch - it is a whole class. Could you attach a patch against HEAD please? As this bug is against 3.1.2 I need to see it as compared to the current codebase.
(In reply to comment #12) > Paul comment #9 isn't a patch - it is a whole class. Could you attach a patch > against HEAD please? As this bug is against 3.1.2 I need to see it as compared > to the current codebase. > Oops, didn't think of patch as in the special file. My problem with that is that I do not have the code checked out -- can you give me a pointer to how to do that? (I dunno the values I should enter in the "Define Repository" dialog, nor how to find that data on the Eclipse.org webpage.) I presume I need an id/pwd which I also lack.
There is a CVS HOWTO off of http://www.eclipse.org/ but basically you want dev.eclipse.org anonymous /cvsroot/eclipse pserver If you go to the bottom of HEAD, there is a module called platform-ui that you can check out that will give you most of the Platform UI plugins. From there you can make your changes, self host, and create a patch. PW
As per http://wiki.eclipse.org/Platform_UI/Bug_Triage_Change_2009
The StringFieldEditor code is now in http://git.eclipse.org/c/platform/eclipse.platform.ui.git I tried to just overwrite the StringFieldEditor with the class from comment #9 but it looks like the methods have been re-sorted so I can't consume that. PW