Exemplo n.º 1
0
  private Widget valueEditor(final ActionFieldValue val) {
    PackageDataModelOracle completions = this.getModeller().getSuggestionCompletions();
    String type = "";
    if (completions.isGlobalVariable(this.model.getVariable())) {
      type = completions.getGlobalVariable(this.model.getVariable());
    } else {
      type = this.getModeller().getModel().getLHSBindingType(this.model.getVariable());
      /*
       * to take in account if the using a rhs bound variable
       */
      if (type == null && !this.readOnly) {
        type =
            this.getModeller().getModel().getRHSBoundFact(this.model.getVariable()).getFactType();
      }
    }

    DropDownData enums =
        completions.getEnums(
            type, val.getField(), FieldNatureUtil.toMap(this.model.getFieldValues()));
    ActionValueEditor actionValueEditor =
        new ActionValueEditor(
            val, enums, this.getModeller(), this.getEventBus(), val.getType(), this.readOnly);
    actionValueEditor.setOnChangeCommand(
        new Command() {

          public void execute() {
            setModified(true);
          }
        });
    return actionValueEditor;
  }
  /** Pops up the fact selector. */
  protected void showFactTypeSelector(final Widget w) {
    PackageDataModelOracle completions = this.getModeller().getSuggestionCompletions();
    final ListBox box = new ListBox();
    String[] facts = completions.getFactTypes();

    box.addItem(Constants.INSTANCE.Choose());

    for (int i = 0; i < facts.length; i++) {
      box.addItem(facts[i]);
    }
    box.setSelectedIndex(0);

    final FormStylePopup popup = new FormStylePopup();
    popup.setTitle(Constants.INSTANCE.NewFactPattern());
    popup.addAttribute(Constants.INSTANCE.chooseFactType(), box);
    box.addChangeHandler(
        new ChangeHandler() {

          public void onChange(ChangeEvent event) {
            pattern.setFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
          }
        });

    popup.show();
  }
Exemplo n.º 3
0
  public CallMethodWidget(
      String factName,
      ScenarioParentWidget parent,
      Scenario scenario,
      CallMethod mCall,
      ExecutionTrace executionTrace,
      PackageDataModelOracle dmo) {
    super();
    this.factName = factName;
    this.parent = parent;
    this.scenario = scenario;
    this.mCall = mCall;
    this.executionTrace = executionTrace;
    this.dmo = dmo;

    this.layout = new DirtyableFlexTable();

    layout.setStyleName("model-builderInner-Background"); // NON-NLS

    if (dmo.isGlobalVariable(mCall.getVariable())) {

      List<MethodInfo> infos = dmo.getMethodInfosForGlobalVariable(mCall.getVariable());
      this.fieldCompletionTexts = new String[infos.size()];
      this.fieldCompletionValues = new String[infos.size()];
      int i = 0;
      for (MethodInfo info : infos) {
        this.fieldCompletionTexts[i] = info.getName();
        this.fieldCompletionValues[i] = info.getNameWithParameters();
        i++;
      }

      this.variableClass = (String) dmo.getGlobalVariable(mCall.getVariable());
    } else {
      FactData pattern = (FactData) scenario.getFactTypes().get(mCall.getVariable());
      if (pattern != null) {
        List<String> methodList = dmo.getMethodNames(pattern.getType());
        fieldCompletionTexts = new String[methodList.size()];
        fieldCompletionValues = new String[methodList.size()];
        int i = 0;
        for (String methodName : methodList) {
          fieldCompletionTexts[i] = methodName;
          fieldCompletionValues[i] = methodName;
          i++;
        }
        this.variableClass = pattern.getType();
        this.isBoundFact = true;
      }
    }

    doLayout();
    initWidget(this.layout);
  }
Exemplo n.º 4
0
  public ActionSetFieldWidget(
      RuleModeller mod, EventBus eventBus, ActionSetField set, Boolean readOnly) {
    super(mod, eventBus);
    this.model = set;
    this.layout = new DirtyableFlexTable();

    layout.setStyleName("model-builderInner-Background");

    PackageDataModelOracle completions = this.getModeller().getSuggestionCompletions();

    if (completions.isGlobalVariable(set.getVariable())) {
      this.fieldCompletions = completions.getFieldCompletionsForGlobalVariable(set.getVariable());
      this.variableClass = completions.getGlobalVariable(set.getVariable());
    } else {
      String type = mod.getModel().getLHSBindingType(set.getVariable());
      if (type != null) {
        this.fieldCompletions =
            completions.getFieldCompletions(FieldAccessorsAndMutators.MUTATOR, type);
        this.variableClass = type;
        this.isBoundFact = true;
      } else {
        ActionInsertFact patternRhs = mod.getModel().getRHSBoundFact(set.getVariable());
        if (patternRhs != null) {
          this.fieldCompletions =
              completions.getFieldCompletions(
                  FieldAccessorsAndMutators.MUTATOR, patternRhs.getFactType());
          this.variableClass = patternRhs.getFactType();
          this.isBoundFact = true;
        }
      }
    }

    if (this.variableClass == null) {
      readOnly = true;
      ErrorPopup.showMessage(Constants.INSTANCE.CouldNotFindTheTypeForVariable0(set.getVariable()));
    }

    this.isFactTypeKnown = completions.isFactTypeRecognized(this.variableClass);
    if (readOnly == null) {
      this.readOnly = !this.isFactTypeKnown;
    } else {
      this.readOnly = readOnly;
    }

    if (this.readOnly) {
      layout.addStyleName("editor-disabled-widget");
    }

    doLayout();

    initWidget(this.layout);
  }
Exemplo n.º 5
0
  private Widget valueEditor(final CallFieldValue val) {

    String type = "";
    if (dmo.isGlobalVariable(this.mCall.getVariable())) {
      type = dmo.getGlobalVariable(this.mCall.getVariable());
    } else {
      Map<String, String> mFactTypes = scenario.getVariableTypes();
      type = mFactTypes.get(this.mCall.getVariable());
    }

    DropDownData enums = dmo.getEnums(type, val.field, this.mCall.getCallFieldValuesMap());
    return new MethodParameterCallValueEditor(
        val,
        enums,
        executionTrace,
        scenario,
        val.type,
        new Command() {

          public void execute() {
            makeDirty();
          }
        });
  }