Search in sources :

Example 21 with SmallLabel

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

the class ConstraintValueEditor method showTypeChoice.

/**
 * Show a list of possibilities for the value type.
 */
private void showTypeChoice(final BaseSingleFieldConstraint con) {
    CustomFormConfiguration customFormConfiguration = getWorkingSetManager().getCustomFormConfiguration(modeller.getPath(), factType, fieldName);
    if (customFormConfiguration != null) {
        if (!(con instanceof SingleFieldConstraint)) {
            Window.alert("Unexpected constraint type!");
            return;
        }
        final CustomFormPopUp customFormPopUp = new CustomFormPopUp(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.FieldValue(), customFormConfiguration);
        final SingleFieldConstraint sfc = (SingleFieldConstraint) con;
        customFormPopUp.addOkButtonHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                sfc.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
                sfc.setId(customFormPopUp.getFormId());
                sfc.setValue(customFormPopUp.getFormValue());
                doTypeChosen(customFormPopUp);
            }
        });
        customFormPopUp.show(sfc.getId(), sfc.getValue());
        return;
    }
    final FormStylePopup form = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), GuidedRuleEditorResources.CONSTANTS.FieldValue());
    Button lit = new Button(GuidedRuleEditorResources.CONSTANTS.LiteralValue());
    int litValueType = isDropDownDataEnum && dropDownData != null ? SingleFieldConstraint.TYPE_ENUM : SingleFieldConstraint.TYPE_LITERAL;
    lit.addClickHandler(getValueTypeFormOnClickHandler(con, form, litValueType));
    boolean showLiteralSelector = true;
    boolean showFormulaSelector = !OperatorsOracle.operatorRequiresList(con.getOperator());
    boolean showVariableSelector = !OperatorsOracle.operatorRequiresList(con.getOperator());
    boolean showExpressionSelector = !OperatorsOracle.operatorRequiresList(con.getOperator());
    if (con instanceof SingleFieldConstraint) {
        SingleFieldConstraint sfc = (SingleFieldConstraint) con;
        String fieldName = sfc.getFieldName();
        if (fieldName.equals(DataType.TYPE_THIS)) {
            showLiteralSelector = CEPOracle.isCEPOperator(sfc.getOperator());
            showFormulaSelector = showFormulaSelector && showLiteralSelector;
        }
    } else if (con instanceof ConnectiveConstraint) {
        ConnectiveConstraint cc = (ConnectiveConstraint) con;
        String fieldName = cc.getFieldName();
        if (fieldName.equals(DataType.TYPE_THIS)) {
            showLiteralSelector = CEPOracle.isCEPOperator(cc.getOperator());
            showFormulaSelector = showFormulaSelector && showLiteralSelector;
        }
    }
    // Literal value selector
    if (showLiteralSelector) {
        form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.LiteralValue(), GuidedRuleEditorResources.CONSTANTS.LiteralValue(), GuidedRuleEditorResources.CONSTANTS.LiteralValTip(), lit);
    }
    // Template key selector
    if (modeller.isTemplate()) {
        String templateKeyLabel = GuidedRuleEditorResources.CONSTANTS.TemplateKey();
        Button templateKeyButton = new Button(templateKeyLabel);
        templateKeyButton.addClickHandler(getValueTypeFormOnClickHandler(con, form, SingleFieldConstraint.TYPE_TEMPLATE));
        form.addAttributeWithHelp(templateKeyLabel, templateKeyLabel, GuidedRuleEditorResources.CONSTANTS.TemplateKeyTip(), templateKeyButton);
    }
    // Divider, if we have any advanced options
    if (showVariableSelector || showFormulaSelector || showExpressionSelector) {
        form.addRow(new HTML("<hr/>"));
        form.addRow(new SmallLabel(GuidedRuleEditorResources.CONSTANTS.AdvancedOptions()));
    }
    // Show variables selector, if there are any variables in scope
    if (showVariableSelector) {
        List<String> bindingsInScope = this.model.getBoundVariablesInScope(this.constraint);
        if (bindingsInScope.size() > 0 || DataType.TYPE_COLLECTION.equals(this.fieldType)) {
            final Button bindingButton = new Button(GuidedRuleEditorResources.CONSTANTS.BoundVariable());
            // This Set is used as a 1flag to know whether the button has been added; due to use of callbacks
            final Set<Button> bindingButtonContainer = new HashSet<Button>();
            for (String var : bindingsInScope) {
                helper.isApplicableBindingsInScope(var, new Callback<Boolean>() {

                    @Override
                    public void callback(final Boolean result) {
                        if (Boolean.TRUE.equals(result)) {
                            if (!bindingButtonContainer.contains(bindingButton)) {
                                bindingButtonContainer.add(bindingButton);
                                bindingButton.addClickHandler(getValueTypeFormOnClickHandler(con, form, SingleFieldConstraint.TYPE_VARIABLE));
                                form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.AVariable(), GuidedRuleEditorResources.CONSTANTS.ABoundVariable(), GuidedRuleEditorResources.CONSTANTS.BoundVariableTip(), bindingButton);
                            }
                        }
                    }
                });
            }
        }
    }
    // Formula selector
    if (showFormulaSelector) {
        Button formula = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
        formula.addClickHandler(getValueTypeFormOnClickHandler(con, form, SingleFieldConstraint.TYPE_RET_VALUE));
        form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.AFormula(), GuidedRuleEditorResources.CONSTANTS.AFormula(), GuidedRuleEditorResources.CONSTANTS.FormulaExpressionTip(), formula);
    }
    // Expression selector
    if (showExpressionSelector) {
        Button expression = new Button(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor());
        expression.addClickHandler(getValueTypeFormOnClickHandler(con, form, SingleFieldConstraint.TYPE_EXPR_BUILDER_VALUE));
        form.addAttributeWithHelp(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor(), GuidedRuleEditorResources.CONSTANTS.ExpressionEditor(), GuidedRuleEditorResources.CONSTANTS.ExpressionEditorTip(), expression);
    }
    form.show();
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CustomFormConfiguration(org.guvnor.common.services.workingset.client.factconstraints.customform.CustomFormConfiguration) ConnectiveConstraint(org.drools.workbench.models.datamodel.rule.ConnectiveConstraint) HTML(com.google.gwt.user.client.ui.HTML) ConnectiveConstraint(org.drools.workbench.models.datamodel.rule.ConnectiveConstraint) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Button(org.gwtbootstrap3.client.ui.Button) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) HashSet(java.util.HashSet)

Example 22 with SmallLabel

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

the class ConstraintValueEditor method returnValueEditor.

/**
 * An editor for the retval "formula" (expression).
 */
private Widget returnValueEditor() {
    TextBox box = new BoundTextBox(constraint);
    if (this.readOnly) {
        return new SmallLabel(box.getText());
    }
    String msg = GuidedRuleEditorResources.CONSTANTS.FormulaEvaluateToAValue();
    Image img = new Image(GuidedRuleEditorResources.INSTANCE.images().functionAssets());
    img.setTitle(msg);
    box.setTitle(msg);
    box.addValueChangeHandler(new ValueChangeHandler<String>() {

        public void onValueChange(final ValueChangeEvent event) {
            executeOnValueChangeCommand();
        }
    });
    Widget ed = widgets(img, box);
    return ed;
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) IsWidget(com.google.gwt.user.client.ui.IsWidget) Widget(com.google.gwt.user.client.ui.Widget) TextBox(org.gwtbootstrap3.client.ui.TextBox) Image(com.google.gwt.user.client.ui.Image)

Example 23 with SmallLabel

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

the class RuleModeller method renderOptions.

private void renderOptions(final int optionsRowIndex) {
    layout.setWidget(optionsRowIndex, 2, new SmallLabel(GuidedRuleEditorResources.CONSTANTS.optionsRuleModeller()));
    if (!isReadOnly) {
        layout.setWidget(optionsRowIndex, 4, getAddAttribute());
    }
    layout.setWidget(optionsRowIndex + 1, 3, new RuleAttributeWidget(this, this.model, isReadOnly));
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel)

Example 24 with SmallLabel

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

the class Connectives method connectiveOperatorDropDown.

private void connectiveOperatorDropDown(final ConnectiveConstraint cc, final Callback<Widget> callback) {
    if (!isReadOnly) {
        final String factType = cc.getFactType();
        final String fieldName = cc.getFieldName();
        this.getDataModelOracle().getConnectiveOperatorCompletions(factType, fieldName, new Callback<String[]>() {

            @Override
            public void callback(final String[] operators) {
                final CEPOperatorsDropdown dropdown = getDropdown(operators, cc);
                dropdown.addPlaceholder(GuidedRuleEditorResources.CONSTANTS.pleaseChoose(), "");
                dropdown.addValueChangeHandler(new ValueChangeHandler<OperatorSelection>() {

                    public void onValueChange(ValueChangeEvent<OperatorSelection> event) {
                        OperatorSelection selection = event.getValue();
                        String selected = selection.getValue();
                        cc.setOperator(selected);
                    }
                });
                callback.callback(dropdown);
            }
        });
    } else {
        final SmallLabel w = new SmallLabel("<b>" + (cc.getOperator() == null ? GuidedRuleEditorResources.CONSTANTS.pleaseChoose() : HumanReadable.getOperatorDisplayName(cc.getOperator())) + "</b>");
        callback.callback(w);
    }
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) OperatorSelection(org.drools.workbench.screens.guided.rule.client.editor.OperatorSelection) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) CEPOperatorsDropdown(org.drools.workbench.screens.guided.rule.client.editor.CEPOperatorsDropdown)

Example 25 with SmallLabel

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

the class ActionCallMethodWidget method getSetterLabel.

private Widget getSetterLabel() {
    HorizontalPanel horiz = new HorizontalPanel();
    if (model.getState() == ActionCallMethod.TYPE_UNDEFINED) {
        Image edit = GuidedRuleEditorImages508.INSTANCE.AddFieldToFact();
        edit.setAltText(GuidedRuleEditorResources.CONSTANTS.AddAnotherFieldToThisSoYouCanSetItsValue());
        edit.setTitle(GuidedRuleEditorResources.CONSTANTS.AddAnotherFieldToThisSoYouCanSetItsValue());
        edit.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                Widget w = (Widget) event.getSource();
                showAddFieldPopup(w);
            }
        });
        // NON-NLS
        horiz.add(new SmallLabel(HumanReadable.getActionDisplayName("call") + " [" + model.getVariable() + "]"));
        if (!this.readOnly) {
            horiz.add(edit);
        }
    } else {
        // NON-NLS
        horiz.add(new SmallLabel(HumanReadable.getActionDisplayName("call") + " [" + model.getVariable() + "." + model.getMethodName() + "]"));
    }
    return horiz;
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) Widget(com.google.gwt.user.client.ui.Widget) Image(com.google.gwt.user.client.ui.Image)

Aggregations

SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)32 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)13 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)13 Button (org.gwtbootstrap3.client.ui.Button)12 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)9 HTML (com.google.gwt.user.client.ui.HTML)8 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)7 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)7 Image (com.google.gwt.user.client.ui.Image)7 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)7 ListBox (org.gwtbootstrap3.client.ui.ListBox)6 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)5 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)5 TextBox (org.gwtbootstrap3.client.ui.TextBox)5 InfoPopup (org.uberfire.ext.widgets.common.client.common.InfoPopup)5 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)4 Widget (com.google.gwt.user.client.ui.Widget)3 CompositeFieldConstraint (org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint)3 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)3 ClickableLabel (org.uberfire.ext.widgets.common.client.common.ClickableLabel)3