예제 #1
0
  protected void showAddFieldPopup(ClickEvent w) {
    final DataModelOracle completions = this.getModeller().getSuggestionCompletions();
    final FormStylePopup popup =
        new FormStylePopup(
            GuidedRuleEditorImages508.INSTANCE.Wizard(), Constants.INSTANCE.AddAField());

    final ListBox box = new ListBox();
    box.addItem("...");

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

    box.setSelectedIndex(0);

    popup.addAttribute(Constants.INSTANCE.AddField(), box);
    box.addChangeHandler(
        new ChangeHandler() {

          public void onChange(ChangeEvent event) {
            String fieldName = box.getItemText(box.getSelectedIndex());

            String fieldType = completions.getFieldType(variableClass, fieldName);
            model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
          }
        });

    popup.show();
  }
  /** 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();
  }
예제 #3
0
  @Override
  public void onClick(ClickEvent event) {
    final FormStylePopup pop = new FormStylePopup();
    pop.setTitle(TestScenarioConstants.INSTANCE.ChooseDotDotDot());

    pop.addAttribute(TestScenarioConstants.INSTANCE.ChooseAFieldToAdd(), createAddNewField(pop));

    pop.show();
  }
예제 #4
0
  protected void showAddFieldPopup(final Widget w) {
    final FormStylePopup popup =
        new FormStylePopup(
            TestScenarioAltedImages.INSTANCE.Wizard(),
            TestScenarioConstants.INSTANCE.ChooseAMethodToInvoke());
    ListBox box = new ListBox();
    box.addItem("...");

    for (int i = 0; i < fieldCompletionTexts.length; i++) {
      box.addItem(fieldCompletionTexts[i], fieldCompletionValues[i]);
    }

    box.setSelectedIndex(0);

    popup.addAttribute(TestScenarioConstants.INSTANCE.ChooseAMethodToInvoke(), box);
    box.addChangeHandler(
        new ChangeHandler() {

          public void onChange(ChangeEvent event) {
            mCall.setState(ActionCallMethod.TYPE_DEFINED);
            ListBox sourceW = (ListBox) event.getSource();
            final String methodName = sourceW.getItemText(sourceW.getSelectedIndex());
            final String methodNameWithParams = sourceW.getValue(sourceW.getSelectedIndex());

            mCall.setMethodName(methodName);

            oracle.getMethodParams(
                variableClass,
                methodNameWithParams,
                new Callback<List<String>>() {
                  @Override
                  public void callback(final List<String> fieldList) {
                    // String fieldType = oracle.getFieldType( variableClass, fieldName );
                    int i = 0;
                    for (String fieldParameter : fieldList) {
                      mCall.addFieldValue(
                          new CallFieldValue(methodName, String.valueOf(i), fieldParameter));
                      i++;
                    }

                    parent.renderEditor();
                    popup.hide();
                  }
                });
          }
        });

    popup.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop());
    popup.show();
  }
예제 #5
0
  /** Pops up the fact selector. */
  protected void showFactTypeSelector(final Widget w) {
    final ListBox box = new ListBox();
    DataModelOracle completions = this.getModeller().getSuggestionCompletions();
    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.addFactPattern(new FactPattern(box.getItemText(box.getSelectedIndex())));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
          }
        });

    final Button fromBtn = new Button(HumanReadableConstants.INSTANCE.From());
    final Button fromAccumulateBtn = new Button(HumanReadableConstants.INSTANCE.FromAccumulate());
    final Button fromCollectBtn = new Button(HumanReadableConstants.INSTANCE.FromCollect());
    ClickHandler btnsClickHandler =
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            Widget sender = (Widget) event.getSource();
            if (sender == fromBtn) {
              pattern.addFactPattern(new FromCompositeFactPattern());
            } else if (sender == fromAccumulateBtn) {
              pattern.addFactPattern(new FromAccumulateCompositeFactPattern());
            } else if (sender == fromCollectBtn) {
              pattern.addFactPattern(new FromCollectCompositeFactPattern());
            } else {
              throw new IllegalArgumentException("Unknown sender: " + sender);
            }

            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
          }
        };

    fromBtn.addClickHandler(btnsClickHandler);
    fromAccumulateBtn.addClickHandler(btnsClickHandler);
    fromCollectBtn.addClickHandler(btnsClickHandler);
    popup.addAttribute("", fromBtn);
    popup.addAttribute("", fromAccumulateBtn);
    popup.addAttribute("", fromCollectBtn);

    popup.show();
  }
    /** This is used when creating a new category */
    public CategoryEditor(final CategoryItem parent) {
      super.setTitle(getTitle(parent));
      this.parent = parent;

      addAttribute(Constants.INSTANCE.CategoryName(), name);

      Button ok = new Button(Constants.INSTANCE.OK());
      ok.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              ok();
            }
          });
      addAttribute("", ok);
    }