Package org.drools.ide.common.client.modeldriven.testing

Examples of org.drools.ide.common.client.modeldriven.testing.FieldData


    static void removeFields(List factData,
                             String field) {
        for ( Iterator iterator = factData.iterator(); iterator.hasNext(); ) {
            FactData fa = (FactData) iterator.next();
            for ( Iterator iterator2 = fa.fieldData.iterator(); iterator2.hasNext(); ) {
                FieldData fi = (FieldData) iterator2.next();
                if ( fi.name.equals( field ) ) {
                    iterator2.remove();
                }
            }
        }
View Full Code Here


        //build up a list of what we have got, don't want to add it twice
        HashSet existingFields = new HashSet();
        if (defList.size() > 0) {
          FactData d = (FactData) defList.get(0);
          for (Iterator iterator = d.fieldData.iterator(); iterator.hasNext();) {
            FieldData f = (FieldData) iterator.next();
            existingFields.add(f.name);
          }

        }
        String[] fields = (String[]) sce.getModelFields(type);
        final FormStylePopup pop = new FormStylePopup(); //NON-NLS
                pop.setTitle(constants.ChooseDotDotDot());
        final ListBox b = new ListBox();
        for (int i = 0; i < fields.length; i++) {
          String fld = fields[i];
          if (!existingFields.contains(fld)) b.addItem(fld);
        }

        Button ok = new Button(constants.OK());
        ok.addClickListener(new ClickListener() {
                  public void onClick(Widget w) {
                    String f = b.getItemText(b.getSelectedIndex());
                    for (Iterator iterator = defList.iterator(); iterator.hasNext();) {
                      FactData fd = (FactData) iterator.next();
                      fd.fieldData.add(new FieldData(f, ""));
                    }
                        outer.setWidget(1, 0, render(defList, parent, sc));
                        pop.hide();
                  }
                });
View Full Code Here

        int totalCols = defList.size();
        for (Iterator iterator = defList.iterator(); iterator.hasNext();) {
            final FactData d = (FactData) iterator.next();

            for (int i = 0; i < d.fieldData.size(); i++) {
                final FieldData fd = d.fieldData.get(i);
                if (!fields.containsKey(fd.name)) {
                    int idx = fields.size() + 1;
                    fields.put(fd.name, new Integer(idx));
                    t.setWidget(idx, 0, new SmallLabel(fd.name + ":"));
                    Image del = new ImageButton("images/delete_item_small.gif", constants.RemoveThisRow(), new ClickListener() {
                public void onClick(Widget w) {
                  if (Window.confirm(constants.AreYouSureYouWantToRemoveThisRow())) {
                    ScenarioHelper.removeFields(defList, fd.name);
                    outer.setWidget(1, 0, render(defList, parent, sc));

                  }
                }
              });
                    t.setWidget(idx, totalCols + 1, del);
                    t.getCellFormatter().setHorizontalAlignment(idx, 0, HasHorizontalAlignment.ALIGN_RIGHT);
                }
            }
        }

        int totalRows = fields.size();

        t.getFlexCellFormatter().setHorizontalAlignment(totalRows + 1, 0, HasHorizontalAlignment.ALIGN_RIGHT);

        //now we go through the facts and the fields, adding them to the grid
        //if a fact is missing a FieldData, we will add it in (so people can enter data later on)
        col = 0;
        for (Iterator iterator = defList.iterator(); iterator.hasNext();) {
            final FactData d = (FactData) iterator.next();
            t.setWidget(0, ++col, new SmallLabel("[" + d.name + "]"));
            Image del = new ImageButton("images/delete_item_small.gif", Format.format(constants.RemoveTheColumnForScenario(), d.name), new ClickListener() {
        public void onClick(Widget w) {
          if (scenario.isFactNameUsed(d)) {
                        Window.alert(Format.format(constants.CanTRemoveThisColumnAsTheName0IsBeingUsed(), d.name));
          } else if (Window.confirm(constants.AreYouSureYouWantToRemoveThisColumn())) {
            scenario.removeFixture(d);
            defList.remove(d);
            outer.setWidget(1, 0, render(defList, parent, sc));
          }
        }
      });
            t.setWidget(totalRows + 1, col, del);
            Map presentFields = new HashMap(fields);
            for (int i = 0; i < d.fieldData.size(); i++) {
                FieldData fd = d.fieldData.get(i);
                int fldRow = ((Integer) fields.get(fd.name)).intValue();
                t.setWidget(fldRow, col, editableCell(fd, d,d.type,this.executionTrace));
                presentFields.remove(fd.name);
            }

            for (Iterator missing = presentFields.entrySet().iterator(); missing.hasNext();) {
                Map.Entry e = (Map.Entry) missing.next();
                int fldRow = ((Integer) e.getValue()).intValue();
                FieldData fd = new FieldData((String) e.getKey(), "");
                d.fieldData.add(fd);
                t.setWidget(fldRow, col, editableCell(fd, d,d.type,this.executionTrace));
            }
        }
View Full Code Here

            addPattern.setTitle(constants.AddElementBelow());


            addPattern.addClickListener(new ClickListener(){
                public void onClick(Widget sender) {
                   FieldData newFieldData = new FieldData();
                   newFieldData.name = field.name;
                   newFieldData.collectionType = field.collectionType;
                   field.collectionFieldList.add(index+1,newFieldData);
                   calculateValueFromList();
                   refreshEditor();
                }
            });
            hpanel.add(addPattern);
            Image moveDown = new ImageButton("images/shuffle_down.gif");
            moveDown.setTitle(constants.MoveDownListMove());
            moveDown.addClickListener(new ClickListener(){
                public void onClick(Widget sender) {
                   if (index <field.collectionFieldList.size()-1){
                          FieldData onMyLine =field.collectionFieldList.get(index);
                          FieldData onDown =field.collectionFieldList.get(index+1);
                          field.collectionFieldList.set(index+1,onMyLine);
                          field.collectionFieldList.set(index,onDown);
                          calculateValueFromList();
                          refreshEditor();
                   }
                }
            });
            hpanel.add(moveDown);

            Image moveUp = new ImageButton("images/shuffle_up.gif");
            moveUp.setTitle(constants.MoveUpList());
            moveUp.addClickListener(new ClickListener(){
                public void onClick(Widget sender) {
                   if (index >0){
                          FieldData oneUp =field.collectionFieldList.get(index-1);
                          FieldData onMyLine =field.collectionFieldList.get(index);
                          field.collectionFieldList.set(index,oneUp);
                          field.collectionFieldList.set(index-1,onMyLine);
                          calculateValueFromList();
                          refreshEditor();
                   }
                }
            });
            hpanel.add(moveUp);
            panel.add(hpanel);
             i++;
        }
   

        if (this.field.collectionFieldList.size()==0){
            Image add = new ImageButton("images/new_item.gif", Format.format(constants.AElementToAddInCollectionList(), "tt"), new ClickListener() {
                public void onClick(Widget w) {
                    FieldData newFieldData = new FieldData();
                    newFieldData.name = field.name;
                    newFieldData.collectionType = field.collectionType;
                    field.collectionFieldList.add(newFieldData);
                    calculateValueFromList();
                    refreshEditor();
View Full Code Here

                    public void onClick(ClickEvent event) {
                        String field = fieldsListBox.getItemText( fieldsListBox.getSelectedIndex() );
                        for ( Fixture fixture : definitionList ) {
                            if ( fixture instanceof FactData ) {
                                FactData factData = (FactData) fixture;
                                factData.fieldData.add( new FieldData( field,
                                                                       "" ) );
                            }
                        }
                        render();
                        pop.hide();
View Full Code Here

                }

                //
                for ( Map.Entry<String, Integer> entry : presentFields.entrySet() ) {
                    int fieldRow = ((Integer) entry.getValue()).intValue();
                    FieldData fieldData = new FieldData( (String) entry.getKey(),
                                                         "" );
                    factData.fieldData.add( fieldData );
                    setWidget( fieldRow,
                               col,
                               editableCell( fieldData,
View Full Code Here

            addPattern.setTitle(constants.AddElementBelow());


            addPattern.addClickListener(new ClickListener(){
                public void onClick(Widget sender) {
                   FieldData newFieldData = new FieldData();
                   newFieldData.name = field.name;
                   newFieldData.collectionType = field.collectionType;
                   field.collectionFieldList.add(index+1,newFieldData);
                   calculateValueFromList();
                   refreshEditor();
                }
            });
            hpanel.add(addPattern);
            Image moveDown = new ImageButton("images/shuffle_down.gif");
            moveDown.setTitle(constants.MoveDownListMove());
            moveDown.addClickListener(new ClickListener(){
                public void onClick(Widget sender) {
                   if (index <field.collectionFieldList.size()-1){
                          FieldData onMyLine =field.collectionFieldList.get(index);
                          FieldData onDown =field.collectionFieldList.get(index+1);
                          field.collectionFieldList.set(index+1,onMyLine);
                          field.collectionFieldList.set(index,onDown);
                          calculateValueFromList();
                          refreshEditor();
                   }
                }
            });
            hpanel.add(moveDown);

            Image moveUp = new ImageButton("images/shuffle_up.gif");
            moveUp.setTitle(constants.MoveUpList());
            moveUp.addClickListener(new ClickListener(){
                public void onClick(Widget sender) {
                   if (index >0){
                          FieldData oneUp =field.collectionFieldList.get(index-1);
                          FieldData onMyLine =field.collectionFieldList.get(index);
                          field.collectionFieldList.set(index,oneUp);
                          field.collectionFieldList.set(index-1,onMyLine);
                          calculateValueFromList();
                          refreshEditor();
                   }
                }
            });
            hpanel.add(moveUp);
            panel.add(hpanel);
             i++;
        }
   

        if (this.field.collectionFieldList.size()==0){
            Image add = new ImageButton("images/new_item.gif", Format.format(constants.AElementToAddInCollectionList(), "tt"), new ClickListener() {
                public void onClick(Widget w) {
                    FieldData newFieldData = new FieldData();
                    newFieldData.name = field.name;
                    newFieldData.collectionType = field.collectionType;
                    field.collectionFieldList.add(newFieldData);
                    calculateValueFromList();
                    refreshEditor();
View Full Code Here

                             String field) {
        for ( Fixture fixture : factDatas ) {
            if ( fixture instanceof FactData ) {
                FactData factData = (FactData) fixture;
                for ( Iterator<FieldData> fieldDataIterator = factData.fieldData.iterator(); fieldDataIterator.hasNext(); ) {
                    FieldData fieldData = fieldDataIterator.next();
                    if ( fieldData.name.equals( field ) ) {
                        fieldDataIterator.remove();
                    }
                }
            }
View Full Code Here

        Scenario sc = new Scenario();
        FactData person = new FactData();
        person.setName( "p" );
        person.setType("Person");
        person.getFieldData().add(new FieldData("age",
                "40"));
        person.getFieldData().add( new FieldData( "name",
                                                  "michael" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
                                                  1,
                                                  null );
        sc.getFixtures().add( vr );

        VerifyFact vf = new VerifyFact();
        vf.setName( "p" );
        vf.getFieldValues().add(new VerifyField("name",
                "michael",
                "=="));
        vf.getFieldValues().add( new VerifyField( "age",
                                                  "42",
                                                  "==" ) );
        sc.getFixtures().add( vf );

        FactData cheese = new FactData();
        cheese.setName( "cheese" );
        cheese.setType("Cheese");
        cheese.getFieldData().add(new FieldData("price",
                "42"));
        sc.getGlobals().add( cheese );

        ScenarioRunResult res = repositoryPackageService.runScenario(pkg.getName(),
                sc).getResult();
View Full Code Here

        Scenario sc = new Scenario();
        FactData person = new FactData();
        person.setName( "c" );
        person.setType( "GenBean" );
        person.getFieldData().add( new FieldData( "age",
                                                  "40" ) );
        person.getFieldData().add( new FieldData( "name",
                                                  "mic" ) );

        sc.getFixtures().add( person );
        sc.getFixtures().add( new ExecutionTrace() );
        VerifyRuleFired vr = new VerifyRuleFired( "rule1",
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.testing.FieldData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.