Data field validation is one character behind. [message #453012] |
Tue, 29 March 2005 21:54 |
Mauro Zallocco Messages: 2 Registered: July 2009 |
Junior Member |
|
|
I'm using Eclipse.
Version: 3.1.0
Build id: 200409240800
I have the following code to create an integer field.
public void run() {
PreferenceManager manager = new PreferenceManager();
PreferenceNode node = new PreferenceNode("rpc");
manager.addToRoot(node);
FieldEditorPreferencePage page = new FieldEditorPreferencePage("RPC",
FieldEditorPreferencePage.GRID) {
protected void createFieldEditors() {
final int upperLimitTimeout = 172800;
IntegerFieldEditor communicationTimeout = new IntegerFieldEditor(60,
"Communication timeout (in seconds)", getFieldEditorParent());
communicationTimeout.setValidRange(1, upperLimitTimeout);
communicationTimeout.setEmptyStringAllowed(false);
addField(communicationTimeout);
}
};
node.setPage(page);
page.setPreferenceStore(SwtUiPreferences.getSystemStore());
new PreferenceDialog(ui.getShell(), manager).open();
}
When I run with this I get a nice input field in which I can enter integer
values.
When I enter an invalid character, e.g. 'a', it is not immediately flagged
as an error. On a subsequent character entry (numeric or otherwise), I get
the error message displayed.
"Value must be an Integer"
Stepping through IntegerFieldEditor.checkState() in
package org.eclipse.jface.preference;
I notice that:
String numberString = text.getText();
returns the string entered on the screen but does not include the last
character just entered on the screen (which is not displayed yet either).
As such checkState does not see the bad character and does not report an
error. On a subsequent character entry, text.getText() now "sees" the 'a'
and reports an error but does not the subsequent character.
Has anyone seen this behaviour and is there a fix?
/Mauro
|
|
|
|
Powered by
FUDForum. Page generated in 0.03354 seconds