Search in sources :

Example 1 with FormStylePopup

use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.

the class MethodParameterCallValueEditor method showTypeChoice.

protected void showTypeChoice(final Widget w) {
    final FormStylePopup form = new FormStylePopup(TestScenarioAltedImages.INSTANCE.Wizard(), TestScenarioConstants.INSTANCE.FieldValue());
    Button lit = new Button(TestScenarioConstants.INSTANCE.LiteralValue());
    lit.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            methodParameter.nature = FieldData.TYPE_LITERAL;
            methodParameter.value = " ";
            refresh();
            form.hide();
        }
    });
    form.addAttribute(TestScenarioConstants.INSTANCE.LiteralValue() + ":", widgets(lit, new InfoPopup(TestScenarioConstants.INSTANCE.Literal(), TestScenarioConstants.INSTANCE.LiteralValTip())));
    form.addRow(new HTML("<hr/>"));
    form.addRow(new SmallLabel(TestScenarioConstants.INSTANCE.AdvancedSection()));
    /*
         * If there is a bound variable that is the same type of the current
         * variable type, then show a button
         */
    List<String> vars = model.getFactNamesInScope(ex, true);
    for (String v : vars) {
        boolean createButton = false;
        Button variable = new Button(TestScenarioConstants.INSTANCE.BoundVariable());
        FactData factData = (FactData) model.getFactTypes().get(v);
        if (factData.getType().equals(this.parameterType)) {
            createButton = true;
        }
        if (createButton == true) {
            form.addAttribute(TestScenarioConstants.INSTANCE.BoundVariable() + ":", variable);
            variable.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    methodParameter.nature = FieldData.TYPE_VARIABLE;
                    methodParameter.value = "=";
                    refresh();
                    form.hide();
                }
            });
            break;
        }
    }
    form.show();
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(org.gwtbootstrap3.client.ui.Button) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FactData(org.drools.workbench.models.testscenarios.shared.FactData) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) HTML(com.google.gwt.user.client.ui.HTML) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup)

Example 2 with FormStylePopup

use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.

the class AddFieldClickHandler method onClick.

@Override
public void onClick(final ClickEvent event) {
    final FormStylePopup pop = new FormStylePopup(TestScenarioConstants.INSTANCE.ChooseAFieldToAdd());
    final FactFieldSelector selector = createAddNewField(pop);
    pop.addAttribute(TestScenarioConstants.INSTANCE.ChooseAFieldToAdd(), selector);
    pop.add(new ModalFooterOKCancelButtons(new Command() {

        @Override
        public void execute() {
            SelectionEvent.fire(selector, selector.getSelectedText());
        }
    }, new Command() {

        @Override
        public void execute() {
            pop.hide();
        }
    }));
    pop.show();
}
Also used : Command(com.google.gwt.user.client.Command) ModalFooterOKCancelButtons(org.uberfire.ext.widgets.common.client.common.popups.footers.ModalFooterOKCancelButtons) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)

Example 3 with FormStylePopup

use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.

the class MethodParameterValueEditor method showTypeChoice.

protected void showTypeChoice() {
    final FormStylePopup form = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.FieldValue());
    // Literal values
    Button lit = new Button(GuidedRuleEditorResources.CONSTANTS.LiteralValue());
    lit.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            methodParameter.setNature(FieldNatureType.TYPE_LITERAL);
            methodParameter.setValue("");
            refresh();
            form.hide();
        }
    });
    form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.LiteralValue(), GuidedRuleEditorResources.CONSTANTS.LiteralValue(), GuidedRuleEditorResources.CONSTANTS.LiteralValTip(), lit);
    if (modeller.isTemplate()) {
        Button templateButton = new Button(GuidedRuleEditorResources.CONSTANTS.TemplateKey());
        templateButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                methodParameter.setNature(FieldNatureType.TYPE_TEMPLATE);
                methodParameter.setValue("");
                refresh();
                form.hide();
            }
        });
        form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.TemplateKey(), GuidedRuleEditorResources.CONSTANTS.TemplateKey(), GuidedRuleEditorResources.CONSTANTS.TemplateKeyTip(), templateButton);
    }
    canTheVariableButtonBeShown(new Callback<Boolean>() {

        @Override
        public void callback(Boolean result) {
            if (result) {
                addBoundVariableButton(form);
                form.addRow(new HTML("<hr/>"));
                form.addRow(new SmallLabel(GuidedRuleEditorResources.CONSTANTS.AdvancedSection()));
            }
            // Formulas
            Button formula = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
            formula.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    methodParameter.setNature(FieldNatureType.TYPE_FORMULA);
                    refresh();
                    form.hide();
                }
            });
            form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.AFormula(), GuidedRuleEditorResources.CONSTANTS.AFormula(), GuidedRuleEditorResources.CONSTANTS.FormulaExpressionTip(), formula);
            form.show();
        }
    });
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(org.gwtbootstrap3.client.ui.Button) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) HTML(com.google.gwt.user.client.ui.HTML)

Example 4 with FormStylePopup

use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.

the class ActionCallMethodWidget method showAddFieldPopup.

protected void showAddFieldPopup(Widget w) {
    final AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.ChooseAMethodToInvoke());
    final ListBox box = new ListBox();
    box.addItem("...");
    for (int i = 0; i < fieldCompletionTexts.length; i++) {
        box.addItem(fieldCompletionValues[i], fieldCompletionTexts[i]);
    }
    box.setSelectedIndex(0);
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ChooseAMethodToInvoke(), box);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            final String methodNameWithParams = box.getItemText(box.getSelectedIndex());
            oracle.getMethodParams(variableClass, methodNameWithParams, new Callback<List<String>>() {

                @Override
                public void callback(final List<String> methodParameters) {
                    final String methodName = box.getValue(box.getSelectedIndex());
                    model.setMethodName(methodName);
                    model.setState(ActionCallMethod.TYPE_DEFINED);
                    for (String methodParameter : methodParameters) {
                        model.addFieldValue(new ActionFieldFunction(methodName, null, methodParameter));
                    }
                    getModeller().refreshWidget();
                    popup.hide();
                }
            });
        }
    });
    popup.show();
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) Callback(org.uberfire.client.callbacks.Callback) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) ActionFieldFunction(org.drools.workbench.models.datamodel.rule.ActionFieldFunction) List(java.util.List) ListBox(org.gwtbootstrap3.client.ui.ListBox) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)

Example 5 with FormStylePopup

use of org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup in project drools-wb by kiegroup.

the class ActionInsertFactWidget method showAddFieldPopup.

protected void showAddFieldPopup(Widget w) {
    final AsyncPackageDataModelOracle oracle = this.getModeller().getDataModelOracle();
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.AddAField());
    final ListBox box = new ListBox();
    box.addItem("...");
    final ModelField[] availableFieldCompletions = ModelFieldUtil.getAvailableFieldCompletions(fieldCompletions, model);
    final boolean isEnabled = !isReadOnly() && availableFieldCompletions.length > 0;
    if (availableFieldCompletions.length > 0) {
        for (int i = 0; i < availableFieldCompletions.length; i++) {
            box.addItem(availableFieldCompletions[i].getName());
        }
    }
    box.setSelectedIndex(0);
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddField(), box);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            String fieldName = box.getItemText(box.getSelectedIndex());
            String fieldType = oracle.getFieldType(model.getFactType(), fieldName);
            model.addFieldValue(new ActionFieldValue(fieldName, "", fieldType));
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    });
    /*
         * Propose a textBox to the user to make him set a variable name
         */
    final HorizontalPanel vn = new HorizontalPanel();
    final TextBox varName = new TextBox();
    if (this.model.getBoundName() != null) {
        varName.setText(this.model.getBoundName());
    }
    final Button ok = new Button(HumanReadableConstants.INSTANCE.Set());
    vn.add(varName);
    vn.add(ok);
    ok.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            String var = varName.getText();
            if (getModeller().isVariableNameUsed(var) && ((model.getBoundName() != null && model.getBoundName().equals(var) == false) || model.getBoundName() == null)) {
                Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
                return;
            }
            model.setBoundName(var);
            setModified(true);
            getModeller().refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.BoundVariable(), vn);
    box.setEnabled(isEnabled);
    varName.setEnabled(isEnabled);
    ok.setEnabled(isEnabled);
    popup.show();
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) TextBox(org.gwtbootstrap3.client.ui.TextBox) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ModelField(org.kie.soup.project.datamodel.oracle.ModelField) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) Button(org.gwtbootstrap3.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Aggregations

FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)24 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)16 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)15 Button (org.gwtbootstrap3.client.ui.Button)15 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)12 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)12 ListBox (org.gwtbootstrap3.client.ui.ListBox)12 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)8 SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)8 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)7 HTML (com.google.gwt.user.client.ui.HTML)6 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)6 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)5 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)5 InfoPopup (org.uberfire.ext.widgets.common.client.common.InfoPopup)5 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)4 Widget (com.google.gwt.user.client.ui.Widget)4 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)4 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)4 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)4