Package org.drools.guvnor.client.modeldriven.testing

Examples of org.drools.guvnor.client.modeldriven.testing.FieldData


        //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.fieldsForType.get(type);
        final FormStylePopup pop = new FormStylePopup("images/rule_asset.gif", constants.ChooseAFieldToAdd()); //NON-NLS
        final ListBox b = new ListBox();
        for (int i = 0; i < fields.length; i++) {
          String fld = fields[i];
          if (!existingFields.contains(fld)) b.addItem(fld);
        }
        pop.addRow(b);
        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));
                        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));

                  }
                }
              });
                    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));
          }
        }
      });
            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.type));
                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.type));
            }
        }
View Full Code Here



  Object populateFields(FactData fact, Map<String, Object> factData, Object factObject) {
    for (int i = 0; i < fact.fieldData.size(); i++) {
      FieldData field = (FieldData) fact.fieldData.get(i);
      Object val;
      if (field.value != null && !field.value.equals("")) {
        if (field.value.startsWith("=")) {
          // eval the val into existence
          val = eval(field.value.substring(1), factData);
View Full Code Here

TOP

Related Classes of org.drools.guvnor.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.