data );
}
private FlexTable render( final FixtureList rfl,
final Scenario sc ) {
FlexTable data = new DirtyableFlexTable();
for ( int i = 0; i < rfl.size(); i++ ) {
final VerifyRuleFired v = (VerifyRuleFired) rfl.get( i );
if ( showResults && v.getSuccessResult() != null ) {
if ( !v.getSuccessResult().booleanValue() ) {
data.setWidget( i,
0,
new Image( CommonImages.INSTANCE.warning() ) );
data.setWidget( i,
4,
new HTML( TestScenarioConstants.INSTANCE.ActualResult( v.getActualResult().toString() ) ) );
data.getCellFormatter().addStyleName( i,
4,
"testErrorValue" ); //NON-NLS
} else {
data.setWidget( i,
0,
new Image( TestScenarioImages.INSTANCE.testPassed() ) );
}
}
data.setWidget( i,
1,
new SmallLabel( v.getRuleName() + ":" ) );
data.getFlexCellFormatter().setAlignment( i,
1,
HasHorizontalAlignment.ALIGN_RIGHT,
HasVerticalAlignment.ALIGN_MIDDLE );
final ListBox b = new ListBox();
b.addItem( TestScenarioConstants.INSTANCE.firedAtLeastOnce(),
"y" );
b.addItem( TestScenarioConstants.INSTANCE.didNotFire(),
"n" );
b.addItem( TestScenarioConstants.INSTANCE.firedThisManyTimes(),
"e" );
final TextBox num = new TextBox();
num.setVisibleLength( 5 );
if ( v.getExpectedFire() != null ) {
b.setSelectedIndex( ( v.getExpectedFire().booleanValue() ) ? 0 : 1 );
num.setVisible( false );
} else {
b.setSelectedIndex( 2 );
String xc = ( v.getExpectedCount() != null ) ? "" + v.getExpectedCount().intValue() : "0";
num.setText( xc );
}
b.addChangeHandler( new ChangeHandler() {
public void onChange( ChangeEvent event ) {
String s = b.getValue( b.getSelectedIndex() );
if ( s.equals( "y" ) || s.equals( "n" ) ) {
num.setVisible( false );
v.setExpectedFire( ( s.equals( "y" ) ) ? Boolean.TRUE : Boolean.FALSE );
v.setExpectedCount( null );
} else {
num.setVisible( true );
v.setExpectedFire( null );
num.setText( "1" );
v.setExpectedCount( Integer.valueOf( 1 ) );
}
}
} );
b.addItem( TestScenarioConstants.INSTANCE.ChooseDotDotDot() );
num.addChangeHandler( new ChangeHandler() {
public void onChange( ChangeEvent event ) {
v.setExpectedCount( Integer.valueOf( num.getText() ) );
}
} );
HorizontalPanel h = new HorizontalPanel();
h.add( b );
h.add( num );
data.setWidget( i,
2,
h );
Image del = CommonAltedImages.INSTANCE.DeleteItemSmall();
del.setAltText( TestScenarioConstants.INSTANCE.RemoveThisRuleExpectation() );
del.setTitle( TestScenarioConstants.INSTANCE.RemoveThisRuleExpectation() );
del.addClickHandler( new ClickHandler() {
public void onClick( ClickEvent w ) {
if ( Window.confirm( TestScenarioConstants.INSTANCE.AreYouSureYouWantToRemoveThisRuleExpectation() ) ) {
rfl.remove( v );
sc.removeFixture( v );
outer.setWidget( 1,
0,
render( rfl,
sc ) );
}
}
} );
data.setWidget( i,
3,
del );
//we only want numbers here...
num.addKeyPressHandler( new KeyPressHandler() {