Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Data field validation is one character behind.
Data field validation is one character behind. [message #453012] Tue, 29 March 2005 21:54 Go to next message
Mauro Zallocco is currently offline Mauro ZalloccoFriend
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
Re: Data field validation is one character behind. [message #453087 is a reply to message #453012] Wed, 30 March 2005 13:16 Go to previous message
Mauro Zallocco is currently offline Mauro ZalloccoFriend
Messages: 2
Registered: July 2009
Junior Member
I should have mentioned that I'm running on Windows XP platform.
Previous Topic:Handle of Workspace and Project - Problem.
Next Topic:How to freeze first col,umn of Tree
Goto Forum:
  


Current Time: Thu Apr 25 23:38:44 GMT 2024

Powered by FUDForum. Page generated in 0.03354 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top