if ( executionTrace.getScenarioSimulatedDate() == null ) {
textBox.setText( "<" + format + ">" );
} else {
textBox.setText( DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT).format(executionTrace.getScenarioSimulatedDate()));
}
final SmallLabel dateHint = new SmallLabel();
textBox.addKeyUpHandler( new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
try {
String exampleDate = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT).format(new Date());
String suggestedDate = textBox.getText() + exampleDate.substring(textBox.getText().length());
Date d = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT).parse(suggestedDate);
dateHint.setText( DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT).format(d) );
} catch ( Exception e ) {
dateHint.setText( "..." );
}
}
} );
textBox.addChangeHandler( new ChangeHandler() {
public void onChange(ChangeEvent event) {
if ( textBox.getText().trim().equals( "" ) ) {
textBox.setText( TestScenarioConstants.INSTANCE.currentDateAndTime() );
} else {
try {
//Date d1 = new Date();
Date d = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT).parse(textBox.getText());
executionTrace.setScenarioSimulatedDate( d );
textBox.setText( DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT).format(d) );
dateHint.setText( "" );
} catch ( Exception e ) {
ErrorPopup.showMessage(TestScenarioConstants.INSTANCE.BadDateFormatPleaseTryAgainTryTheFormatOf0(format));
}
}
}