The file directory editor value is not save if user doesn't press enter at the text box after selected folder using the browse for directory button.

This commit is contained in:
Heng Sin Low 2011-02-07 11:11:37 +08:00
parent a9f8888564
commit e2fa0f1fc4
1 changed files with 18 additions and 9 deletions

View File

@ -31,6 +31,7 @@ public class WFileDirectoryEditor extends WEditor
{
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK, Events.ON_CHANGE, Events.ON_OK};
@SuppressWarnings("unused")
private static final CLogger log = CLogger.getCLogger(WFileDirectoryEditor.class);
private String oldValue;
@ -87,9 +88,21 @@ public class WFileDirectoryEditor extends WEditor
public void onEvent(Event event)
{
String newValue = null;
if (Events.ON_CHANGE.equals(event.getName()) || Events.ON_OK.equals(event.getName()))
{
String newValue = getComponent().getText();
newValue = getComponent().getText();
}
else if (Events.ON_CLICK.equals(event.getName()))
{
cmd_file();
newValue = getComponent().getText();
}
else
{
return;
}
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
return;
}
@ -99,11 +112,6 @@ public class WFileDirectoryEditor extends WEditor
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
fireValueChange(changeEvent);
}
else if (Events.ON_CLICK.equals(event.getName()))
{
cmd_file();
}
}
/**
* Load file
@ -113,6 +121,7 @@ public class WFileDirectoryEditor extends WEditor
FolderBrowser directoryDialog = new FolderBrowser(true);
String directory = directoryDialog.getPath();
getComponent().setText(directory);
getComponent().getTextbox().focus();
} // cmd_file
public String[] getEvents()