예제 #1
0
  public void build(String headerText, Fact fact) {

    if (fact instanceof FactData) {
      FactData factData = (FactData) fact;
      widget.setWidget(0, ++col, new SmallLabel("[" + factData.getName() + "]"));
    } else {
      col++;
    }

    widget.setWidget(0, 0, new ClickableLabel(headerText, createAddFieldButton(fact)));

    // Sets row name and delete button.
    for (final Field field : fact.getFieldData()) {
      // Avoid duplicate field rows, only one for each name.
      if (rowIndexByFieldName.doesNotContain(field.getName())) {
        newRow(fact, field.getName());
      }

      // Sets row data
      int fieldRowIndex = rowIndexByFieldName.getRowIndex(field.getName());
      widget.setWidget(fieldRowIndex, col, editableCell(field, fact, fact.getType()));
    }

    if (fact instanceof FactData) {
      DeleteFactColumnButton deleteFactColumnButton = new DeleteFactColumnButton((FactData) fact);

      widget.setWidget(rowIndexByFieldName.amountOrRows() + 1, col, deleteFactColumnButton);
    }
  }
 private boolean isThereABoundVariableToSet() {
   boolean retour = false;
   List<String> vars = this.scenario.getFactNamesInScope(executionTrace, true);
   if (vars.size() > 0) {
     for (int i = 0; i < vars.size(); i++) {
       String var = (String) vars.get(i);
       FactData f = (FactData) scenario.getFactTypes().get(var);
       String fieldType = sce.getFieldType(this.factType, field.getFieldName());
       if (f.getType().equals(fieldType)) {
         retour = true;
         break;
       }
     }
   }
   return retour;
 }
  private Widget variableEditor() {
    List<String> vars = this.scenario.getFactNamesInScope(this.executionTrace, true);

    final ListBox box = new ListBox();

    if (this.field.getExpected() == null) {
      box.addItem(constants.Choose());
    }
    int j = 0;
    for (int i = 0; i < vars.size(); i++) {
      String var = vars.get(i);
      FactData f = (FactData) scenario.getFactTypes().get(var);
      String fieldType = sce.getFieldType(this.factType, field.getFieldName());
      if (f.getType().equals(fieldType)) {
        if (box.getItemCount() == 0) {
          box.addItem("...");
          j++;
        }
        box.addItem("=" + var);
        if (this.field.getExpected() != null && this.field.getExpected().equals("=" + var)) {
          box.setSelectedIndex(j);
        }
        j++;
      }
    }

    box.addChangeHandler(
        new ChangeHandler() {

          public void onChange(ChangeEvent event) {
            field.setExpected(box.getItemText(box.getSelectedIndex()));
          }
        });

    return box;
  }
예제 #4
0
    public DeleteFactColumnButton(final FactData fact) {
      super(
          DroolsGuvnorImages.INSTANCE.deleteItemSmall(),
          Constants.INSTANCE.RemoveTheColumnForScenario(fact.getName()));

      addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              if (scenario.isFactDataReferenced(fact)) {
                Window.alert(
                    Constants.INSTANCE.CanTRemoveThisColumnAsTheName0IsBeingUsed(fact.getName()));
              } else if (Window.confirm(
                  Constants.INSTANCE.AreYouSureYouWantToRemoveColumn0(fact.getName()))) {
                scenario.removeFixture(fact);
                definitionList.remove(fact);

                parent.renderEditor();
              }
            }
          });
    }