Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 package org.drools.workbench.screens.testscenario.client;
 
 
 public class VerifyRulesFiredWidget extends Composite {
 
     private Grid          outer;
     private boolean       showResults;

    

Parameters:
rfl List<VeryfyRuleFired>
scenario = the scenario to add/remove from
 
     public VerifyRulesFiredWidget(final FixtureList rfl,
                                   final Scenario scenario,
                                   boolean showResults) {
          = new Grid( 2,
                 1 );
         this. = showResults;
         .getCellFormatter().setStyleName( 0,
                 0,
                 "modeller-fact-TypeHeader" ); //NON-NLS
         .getCellFormatter().setAlignment( 0,
                 0,
                 .,
                 . );
         .setStyleName"modeller-fact-pattern-Widget" ); //NON-NLS
 
         .setWidget( 0,
                 0,
                 new SmallLabel..ExpectRules() ) );
         initWidget );
 
         FlexTable data = renderrfl,
                 scenario );
         .setWidget( 1,
                 0,
                 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 = (VerifyRuleFiredrfl.geti );
 
             if (  && v.getSuccessResult() != null ) {
                 if ( !v.getSuccessResult().booleanValue() ) {
                     data.setWidgeti,
                             0,
                             new Image..warning() ) );
                     data.setWidgeti,
                             4,
                             new HTML..ActualResult(v.getActualResult().toString()) ) );
 
                     data.getCellFormatter().addStyleNamei,
                             4,
                            "testErrorValue" ); //NON-NLS
                } else {
                    data.setWidgeti,
                            0,
                            new Image..testPassed() ) );
                }
            }
            data.setWidgeti,
                    1,
                    new SmallLabelv.getRuleName() + ":" ) );
            data.getFlexCellFormatter().setAlignmenti,
                    1,
                    .,
                    . );
            final ListBox b = new ListBox();
                    "y" );
            b.addItem..didNotFire(),
                    "n" );
                    "e" );
            final TextBox num = new TextBox();
            num.setVisibleLength( 5 );
            if ( v.getExpectedFire() != null ) {
                b.setSelectedIndex( (v.getExpectedFire().booleanValue()) ? 0 : 1 );
                num.setVisiblefalse );
            } else {
                b.setSelectedIndex( 2 );
                String xc = (v.getExpectedCount() != null) ? "" + v.getExpectedCount().intValue() : "0";
                num.setTextxc );
            }
            b.addChangeHandlernew ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    String s = b.getValueb.getSelectedIndex() );
                    if ( s.equals"y" ) || s.equals"n" ) ) {
                        num.setVisiblefalse );
                        v.setExpectedFire( (s.equals"y" )) ? . : . );
                        v.setExpectedCountnull );
                    } else {
                        num.setVisibletrue );
                        v.setExpectedFirenull );
                        num.setText"1" );
                        v.setExpectedCountnew Integer( 1 ) );
                    }
                }
            } );
            b.addItem..ChooseDotDotDot() );
            num.addChangeHandlernew ChangeHandler() {
                public void onChange(ChangeEvent event) {
                    v.setExpectedCountnew Integernum.getText() ) );
                }
            } );
            HorizontalPanel h = new HorizontalPanel();
            h.addb );
            h.addnum );
            data.setWidgeti,
                    2,
                    h );
            Image del = ..DeleteItemSmall();
            del.addClickHandler(new ClickHandler() {
                public void onClick(ClickEvent w) {
                    if ( Window.confirm..AreYouSureYouWantToRemoveThisRuleExpectation() ) ) {
                        rfl.removev );
                        sc.removeFixturev );
                        .setWidget( 1,
                                0,
                                renderrfl,
                                        sc ) );
                    }
                }
            });
            data.setWidgeti,
                    3,
                    del );
            //we only want numbers here...
            num.addKeyPressHandlernew KeyPressHandler() {
                public void onKeyPress(KeyPressEvent event) {
                    if ( Character.isLetterevent.getCharCode() ) ) {
                        ((TextBoxevent.getSource()).cancelKey();
                    }
                }
            } );
        }
        return data;
    }
New to GrepCode? Check out our FAQ X