コード例 #1
0
  protected void showAddFieldPopup(ClickEvent w) {
    final SuggestionCompletionEngine completions = this.getModeller().getSuggestionCompletions();
    final FormStylePopup popup =
        new FormStylePopup(DroolsGuvnorImages.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();
  }
コード例 #2
0
  private void render(final FixtureList retList, final FlexTable outer, final Scenario sc) {
    outer.clear();
    outer.getCellFormatter().setStyleName(0, 0, "modeller-fact-TypeHeader");
    outer
        .getCellFormatter()
        .setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
    outer.setStyleName("modeller-fact-pattern-Widget");
    outer.setWidget(0, 0, new SmallLabel(Constants.INSTANCE.ActivateRuleFlowGroup()));
    outer.getFlexCellFormatter().setColSpan(0, 0, 2);

    int row = 1;
    for (Fixture fixture : retList) {
      final ActivateRuleFlowGroup acticateRuleFlowGroup = (ActivateRuleFlowGroup) fixture;
      outer.setWidget(row, 0, new SmallLabel(acticateRuleFlowGroup.getName()));
      Image del =
          new ImageButton(
              DroolsGuvnorImages.INSTANCE.itemImages().deleteItemSmall(),
              Constants.INSTANCE.RemoveThisRuleFlowActivation(),
              new ClickHandler() {
                public void onClick(ClickEvent w) {
                  retList.remove(acticateRuleFlowGroup);
                  sc.getFixtures().remove(acticateRuleFlowGroup);
                  render(retList, outer, sc);
                  parent.renderEditor();
                }
              });
      outer.setWidget(row, 1, del);

      row++;
    }
  }
コード例 #3
0
  private Widget getSetterLabel() {
    HorizontalPanel horiz = new HorizontalPanel();

    if (model.state == ActionCallMethod.TYPE_UNDEFINED) {
      Image edit = DroolsGuvnorImages.INSTANCE.AddFieldToFact();
      edit.setAltText(Constants.INSTANCE.AddAnotherFieldToThisSoYouCanSetItsValue());
      edit.setTitle(Constants.INSTANCE.AddAnotherFieldToThisSoYouCanSetItsValue());
      edit.addClickHandler(
          new ClickHandler() {

            public void onClick(ClickEvent event) {
              Widget w = (Widget) event.getSource();
              showAddFieldPopup(w);
            }
          });
      horiz.add(
          new SmallLabel(
              HumanReadable.getActionDisplayName("call") + " [" + model.variable + "]")); // NON-NLS
      if (!this.readOnly) {
        horiz.add(edit);
      }
    } else {
      horiz.add(
          new SmallLabel(
              HumanReadable.getActionDisplayName("call")
                  + " ["
                  + model.variable
                  + "."
                  + model.methodName
                  + "]")); // NON-NLS
    }

    return horiz;
  }
コード例 #4
0
  private void doLayout() {
    layout.clear();

    for (int i = 0; i < model.fieldValues.length; i++) {
      ActionFieldValue val = model.fieldValues[i];

      layout.setWidget(i, 0, getSetterLabel());
      layout.setWidget(i, 1, fieldSelector(val));
      layout.setWidget(i, 2, valueEditor(val));
      final int idx = i;
      Image remove = DroolsGuvnorImages.INSTANCE.DeleteItemSmall();
      remove.addClickHandler(
          new ClickHandler() {

            public void onClick(ClickEvent event) {
              if (Window.confirm(Constants.INSTANCE.RemoveThisItem())) {
                model.removeField(idx);
                setModified(true);
                getModeller().refreshWidget();

                // Signal possible change in Template variables
                TemplateVariablesChangedEvent tvce =
                    new TemplateVariablesChangedEvent(getModeller().getModel());
                getEventBus().fireEventFromSource(tvce, getModeller().getModel());
              }
            }
          });
      if (!this.readOnly) {
        layout.setWidget(i, 3, remove);
      }
    }

    if (model.fieldValues.length == 0) {
      HorizontalPanel h = new HorizontalPanel();
      h.add(getSetterLabel());
      if (!this.readOnly) {
        Image image = GuvnorImages.INSTANCE.Edit();
        image.setAltText(Constants.INSTANCE.AddFirstNewField());
        image.setTitle(Constants.INSTANCE.AddFirstNewField());
        image.addClickHandler(
            new ClickHandler() {

              public void onClick(ClickEvent sender) {
                showAddFieldPopup(sender);
              }
            });
        h.add(image);
      }
      layout.setWidget(0, 0, h);
    }

    // layout.setWidget( 0, 1, inner );

  }
コード例 #5
0
ファイル: SnapshotView.java プロジェクト: nhenggeler/guvnor
 public static void rebuildBinaries() {
   if (Window.confirm(Constants.INSTANCE.SnapshotRebuildWarning())) {
     LoadingPopup.showMessage(
         Constants.INSTANCE.RebuildingSnapshotsPleaseWaitThisMayTakeSomeTime());
     ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
     moduleService.rebuildSnapshots(
         new GenericCallback<java.lang.Void>() {
           public void onSuccess(Void v) {
             LoadingPopup.close();
             Window.alert(Constants.INSTANCE.SnapshotsWereRebuiltSuccessfully());
           }
         });
   }
 }
コード例 #6
0
  private Widget getSetterLabel() {

    ClickHandler clk =
        new ClickHandler() {

          public void onClick(ClickEvent event) {
            // Widget w = (Widget)event.getSource();
            showAddFieldPopup(event);
          }
        };
    String modifyType = "set";
    if (this.model instanceof ActionUpdateField) {
      modifyType = "modify";
    }

    String type = this.getModeller().getModel().getLHSBindingType(model.variable);

    String descFact = (type != null) ? type + " <b>[" + model.variable + "]</b>" : model.variable;

    String sl =
        Constants.INSTANCE.setterLabel(HumanReadable.getActionDisplayName(modifyType), descFact);
    return new ClickableLabel(
        sl,
        clk,
        !this
            .readOnly); // HumanReadable.getActionDisplayName(modifyType) + " value of <b>[" +
                        // model.variable + "]</b>", clk);
  }
コード例 #7
0
ファイル: SnapshotView.java プロジェクト: nhenggeler/guvnor
  private Button getDeleteButton(final String snapshotName, final String moduleName) {
    Button btn = new Button(Constants.INSTANCE.Delete());
    btn.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            if (Window.confirm(
                Constants.INSTANCE.SnapshotDeleteConfirm(snapshotName, moduleName))) {
              ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
              moduleService.copyOrRemoveSnapshot(
                  moduleName,
                  snapshotName,
                  true,
                  null,
                  new GenericCallback<java.lang.Void>() {
                    public void onSuccess(Void v) {
                      Window.alert(Constants.INSTANCE.SnapshotWasDeleted());

                      eventBus.fireEvent(getCloseEvent(moduleName));
                    }
                  });
            }
          }
        });
    return btn;
  }
コード例 #8
0
  protected void showAddFieldPopup(Widget w) {

    final SuggestionCompletionEngine completions = this.getModeller().getSuggestionCompletions();

    final FormStylePopup popup =
        new FormStylePopup(
            DroolsGuvnorImages.INSTANCE.Wizard(), Constants.INSTANCE.ChooseAMethodToInvoke());
    final 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(Constants.INSTANCE.ChooseAMethodToInvoke(), box);
    box.addChangeHandler(
        new ChangeHandler() {

          public void onChange(ChangeEvent event) {
            model.state = ActionCallMethod.TYPE_DEFINED;

            String methodName = box.getItemText(box.getSelectedIndex());
            String methodNameWithParams = box.getValue(box.getSelectedIndex());

            model.methodName = methodName;
            List<String> fieldList = new ArrayList<String>();

            fieldList.addAll(completions.getMethodParams(variableClass, methodNameWithParams));

            int i = 0;
            for (String fieldParameter : fieldList) {
              model.addFieldValue(
                  new ActionFieldFunction(methodName, String.valueOf(i), fieldParameter));
              i++;
            }

            getModeller().refreshWidget();
            popup.hide();
          }
        });
    popup.setPopupPosition(w.getAbsoluteLeft(), w.getAbsoluteTop());
    popup.show();
  }
コード例 #9
0
ファイル: SnapshotView.java プロジェクト: nhenggeler/guvnor
  public static void showNewSnapshot(final Command refreshCmd) {
    final FormStylePopup pop =
        new FormStylePopup(
            DroolsGuvnorImages.INSTANCE.snapshot(), Constants.INSTANCE.NewSnapshot());
    final RulePackageSelector sel = new RulePackageSelector();

    pop.addAttribute(Constants.INSTANCE.ForPackage(), sel);
    Button ok = new Button(Constants.INSTANCE.OK());
    pop.addAttribute("", ok);
    pop.show();

    ok.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            pop.hide();
            String pkg = sel.getSelectedPackage();
            PackageBuilderWidget.showSnapshotDialog(pkg, refreshCmd);
          }
        });
  }
コード例 #10
0
ファイル: SnapshotView.java プロジェクト: nhenggeler/guvnor
 private Button getCopyButton(final String snapshotName, final String packageName) {
   final ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
   Button btn = new Button(Constants.INSTANCE.Copy());
   btn.addClickHandler(
       new ClickHandler() {
         public void onClick(ClickEvent event) {
           moduleService.listSnapshots(
               packageName, createGenericCallback(snapshotName, packageName, moduleService));
         }
       });
   return btn;
 }
コード例 #11
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");

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

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

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

    this.isFactTypeKnown = completions.containsFactType(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);
  }
コード例 #12
0
  // Actual drop-down
  private Widget getDropDown() {

    String selected = "";
    String selectedText = "";

    box = new ListBox();
    box.setEnabled(!isReadOnly);
    box.addItem(Constants.INSTANCE.noCEPWindow(), "");

    for (int i = 0; i < operators.size(); i++) {
      String op = operators.get(i);
      box.addItem(HumanReadable.getOperatorDisplayName(op), op);
      if (op.equals(hcw.getWindow().getOperator())) {
        selected = op;
        selectedText = HumanReadable.getOperatorDisplayName(op);
        box.setSelectedIndex(i + 1);
      }
    }
    selectItem(hcw.getWindow().getOperator());

    // Fire event to ensure parent Widgets correct their state depending on selection
    final HasValueChangeHandlers<OperatorSelection> source = this;
    final OperatorSelection selection = new OperatorSelection(selected, selectedText);
    Scheduler.get()
        .scheduleFinally(
            new Command() {

              public void execute() {
                operatorChanged(selection);
                ValueChangeEvent.fire(source, selection);
              }
            });

    // Signal parent Widget whenever a change happens
    box.addChangeHandler(
        new ChangeHandler() {

          public void onChange(ChangeEvent event) {
            String selected = box.getValue(box.getSelectedIndex());
            String selectedText = box.getItemText(box.getSelectedIndex());
            OperatorSelection selection = new OperatorSelection(selected, selectedText);
            operatorChanged(selection);
            ValueChangeEvent.fire(source, selection);
          }
        });

    return box;
  }
コード例 #13
0
 public ModifyFactWidget(
     String factType,
     FixtureList definitionList,
     Scenario scenario,
     SuggestionCompletionEngine suggestionCompletionEngine,
     ScenarioParentWidget parent,
     ExecutionTrace executionTrace) {
   super(
       factType,
       definitionList,
       scenario,
       suggestionCompletionEngine,
       parent,
       executionTrace,
       Constants.INSTANCE.modifyForScenario(factType));
 }
コード例 #14
0
ファイル: SnapshotView.java プロジェクト: nhenggeler/guvnor
  private Widget header() {
    FlexTable ft = new FlexTable();

    ft.setWidget(0, 0, new Label(Constants.INSTANCE.ViewingSnapshot()));
    ft.setWidget(0, 1, new HTML("<b>" + this.snapInfo.getName() + "</b>"));
    ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    ft.setWidget(1, 0, new Label(Constants.INSTANCE.ForPackage()));
    ft.setWidget(1, 1, new Label(this.parentConf.getName()));
    ft.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    HTML dLink =
        new HTML(
            "<a href='"
                + PackageBuilderWidget.getDownloadLink(this.parentConf)
                + "' target='_blank'>"
                + Constants.INSTANCE.clickHereToDownloadBinaryOrCopyURLForDeploymentAgent()
                + "</a>");
    ft.setWidget(2, 0, new Label(Constants.INSTANCE.DeploymentURL()));
    ft.setWidget(2, 1, dLink);
    ft.getFlexCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    ft.setWidget(3, 0, new Label(Constants.INSTANCE.SnapshotCreatedOn()));
    ft.getFlexCellFormatter().setHorizontalAlignment(3, 0, HasHorizontalAlignment.ALIGN_RIGHT);
    ft.setWidget(
        3,
        1,
        new Label(
            DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT)
                .format(parentConf.getLastModified())));
    ft.getFlexCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    ft.setWidget(4, 0, new Label(Constants.INSTANCE.CommentColon()));
    ft.setWidget(4, 1, new Label(parentConf.getCheckinComment()));
    ft.getFlexCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    HorizontalPanel actions = new HorizontalPanel();

    actions.add(getDeleteButton(this.snapInfo.getName(), this.parentConf.getName()));
    actions.add(getCopyButton(this.snapInfo.getName(), this.parentConf.getName()));

    ft.setWidget(5, 0, actions);

    ft.setWidget(6, 0, getCompareWidget(this.parentConf.getName(), this.snapInfo.getName()));
    ft.getFlexCellFormatter().setHorizontalAlignment(4, 0, HasHorizontalAlignment.ALIGN_RIGHT);

    ft.getFlexCellFormatter().setColSpan(5, 0, 2);

    return ft;
  }
コード例 #15
0
    public DeleteFieldRowButton(final Fact fact, final String fieldName) {
      super(DroolsGuvnorImages.INSTANCE.deleteItemSmall(), Constants.INSTANCE.RemoveThisRow());

      addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent event) {
              if (fact instanceof FactData) {
                if (Window.confirm(Constants.INSTANCE.AreYouSureYouWantToRemoveRow0(fieldName))) {
                  ScenarioHelper.removeFields(definitionList, fieldName);
                }
              } else if (fact instanceof Fact) {
                if (Window.confirm(Constants.INSTANCE.AreYouSureYouWantToRemoveRow0(fieldName))) {
                  fact.removeField(fieldName);
                }
              }

              parent.renderEditor();
            }
          });
    }
コード例 #16
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();
              }
            }
          });
    }
コード例 #17
0
  public WorkItemObjectParameterWidget(
      PortableObjectParameterDefinition ppd, IBindingProvider bindingProvider, boolean isReadOnly) {
    super(ppd, bindingProvider);

    // Setup widget to use bindings
    this.parameterName.setText(ppd.getName());
    Set<String> bindings = bindingProvider.getBindings(ppd.getClassName());
    if (bindings.size() > 0) {
      lstAvailableBindings.clear();
      lstAvailableBindings.addItem(Constants.INSTANCE.Choose());
      lstAvailableBindings.setEnabled(true && !isReadOnly);
      lstAvailableBindings.setVisible(true);
      int selectedIndex = 0;
      for (String binding : bindings) {
        lstAvailableBindings.addItem(binding);
        if (binding.equals(ppd.getBinding())) {
          selectedIndex = lstAvailableBindings.getItemCount() - 1;
        }
      }
      lstAvailableBindings.setSelectedIndex(selectedIndex);
    }
  }