Search in sources :

Example 11 with Button

use of org.gwtbootstrap3.client.ui.Button in project drools-wb by kiegroup.

the class ConstraintValueEditor method literalEditor.

private Widget literalEditor() {
    // Custom screen
    if (this.constraint instanceof SingleFieldConstraint) {
        final SingleFieldConstraint con = (SingleFieldConstraint) this.constraint;
        CustomFormConfiguration customFormConfiguration = getWorkingSetManager().getCustomFormConfiguration(modeller.getPath(), factType, fieldName);
        if (customFormConfiguration != null) {
            Button btnCustom = new Button(con.getValue(), new ClickHandler() {

                public void onClick(ClickEvent event) {
                    showTypeChoice(constraint);
                }
            });
            btnCustom.setEnabled(!this.readOnly);
            return btnCustom;
        }
    }
    // Label if read-only
    if (this.readOnly) {
        return new SmallLabel(getSanitizedValue());
    }
    // Enumeration (these support multi-select for "in" and "not in", so check before comma separated lists)
    if (this.dropDownData != null) {
        final String operator = constraint.getOperator();
        final boolean multipleSelect = OperatorsOracle.operatorRequiresList(operator);
        EnumDropDown enumDropDown = new EnumDropDown(constraint.getValue(), new DropDownValueChanged() {

            public void valueChanged(String newText, String newValue) {
                // Prevent recursion once value change has been applied
                if (!newValue.equals(constraint.getValue())) {
                    constraint.setValue(newValue);
                    executeOnValueChangeCommand();
                }
            }
        }, dropDownData, multipleSelect, modeller.getPath());
        return enumDropDown;
    }
    // Comma separated value list (this will become a dedicated Widget but for now a TextBox suffices)
    String operator = null;
    if (this.constraint instanceof SingleFieldConstraint) {
        SingleFieldConstraint sfc = (SingleFieldConstraint) this.constraint;
        operator = sfc.getOperator();
    }
    if (OperatorsOracle.operatorRequiresList(operator)) {
        return getNewTextBox(DataType.TYPE_STRING);
    }
    // Date picker
    boolean isCEPOperator = CEPOracle.isCEPOperator((this.constraint).getOperator());
    if (DataType.TYPE_DATE.equals(this.fieldType) || (DataType.TYPE_THIS.equals(this.fieldName) && isCEPOperator)) {
        if (this.readOnly) {
            return new SmallLabel(constraint.getValue());
        }
        final DatePicker datePicker = new DatePicker(false);
        // Wire up update handler
        datePicker.addValueChangeHandler(new ValueChangeHandler<Date>() {

            @Override
            public void onValueChange(final ValueChangeEvent<Date> event) {
                final Date date = datePicker.getValue();
                final String sDate = (date == null ? null : DATE_FORMATTER.format(datePicker.getValue()));
                boolean update = constraint.getValue() == null || !constraint.getValue().equals(sDate);
                constraint.setValue(sDate);
                if (update) {
                    executeOnValueChangeCommand();
                }
            }
        });
        datePicker.setFormat(DATE_FORMAT);
        datePicker.setValue(getSanitizedDateValue());
        return datePicker;
    }
    // Default editor for all other literals
    return getNewTextBox(fieldType);
}
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) Date(java.util.Date) 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) EnumDropDown(org.drools.workbench.screens.guided.rule.client.widget.EnumDropDown) DatePicker(org.uberfire.ext.widgets.common.client.common.DatePicker) DropDownValueChanged(org.uberfire.ext.widgets.common.client.common.DropDownValueChanged)

Example 12 with Button

use of org.gwtbootstrap3.client.ui.Button 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.addAttribute(GuidedRuleEditorResources.CONSTANTS.LiteralValue() + ":", widgets(lit, new InfoPopup(GuidedRuleEditorResources.CONSTANTS.Literal(), GuidedRuleEditorResources.CONSTANTS.LiteralValTip())));
    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.addAttribute(GuidedRuleEditorResources.CONSTANTS.AFormula() + ":", widgets(formula, new InfoPopup(GuidedRuleEditorResources.CONSTANTS.AFormula(), GuidedRuleEditorResources.CONSTANTS.FormulaExpressionTip())));
            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) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup)

Example 13 with Button

use of org.gwtbootstrap3.client.ui.Button in project drools-wb by kiegroup.

the class MethodParameterValueEditor method addBoundVariableButton.

private void addBoundVariableButton(final FormStylePopup form) {
    form.addRow(new HTML("<hr/>"));
    form.addRow(new SmallLabel(GuidedRuleEditorResources.CONSTANTS.AdvancedSection()));
    Button variableButton = new Button(GuidedRuleEditorResources.CONSTANTS.BoundVariable());
    form.addAttribute(GuidedRuleEditorResources.CONSTANTS.BoundVariable() + ":", variableButton);
    variableButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            methodParameter.setNature(FieldNatureType.TYPE_VARIABLE);
            methodParameter.setValue("=");
            refresh();
            form.hide();
        }
    });
}
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) HTML(com.google.gwt.user.client.ui.HTML)

Example 14 with Button

use of org.gwtbootstrap3.client.ui.Button in project drools-wb by kiegroup.

the class PopupCreator method showPatternPopup.

/**
 * This shows a popup allowing you to add field constraints to a pattern
 * (its a popup).
 */
public void showPatternPopup(final FactPattern fp, final SingleFieldConstraint con, final boolean isNested) {
    final String factType = getFactType(fp, con);
    String title = (con == null) ? GuidedRuleEditorResources.CONSTANTS.ModifyConstraintsFor0(fp.getFactType()) : GuidedRuleEditorResources.CONSTANTS.AddSubFieldConstraint();
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorImages508.INSTANCE.Wizard(), title);
    final ListBox box = new ListBox();
    box.addItem("...");
    this.oracle.getFieldCompletions(factType, FieldAccessorsAndMutators.ACCESSOR, new Callback<ModelField[]>() {

        @Override
        public void callback(final ModelField[] fields) {
            for (int i = 0; i < fields.length; i++) {
                // You can't use "this" in a nested accessor
                final String fieldName = fields[i].getName();
                if (!isNested || !fieldName.equals(DataType.TYPE_THIS)) {
                    box.addItem(fieldName);
                }
            }
        }
    });
    box.setSelectedIndex(0);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            String fieldName = box.getItemText(box.getSelectedIndex());
            if ("...".equals(fieldName)) {
                return;
            }
            String fieldType = oracle.getFieldType(factType, fieldName);
            fp.addConstraint(new SingleFieldConstraint(factType, fieldName, fieldType, con));
            modeller.refreshWidget();
            popup.hide();
        }
    });
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddARestrictionOnAField(), box);
    final ListBox composites = new ListBox();
    composites.addItem("...");
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AllOfAnd(), CompositeFieldConstraint.COMPOSITE_TYPE_AND);
    composites.addItem(GuidedRuleEditorResources.CONSTANTS.AnyOfOr(), CompositeFieldConstraint.COMPOSITE_TYPE_OR);
    composites.setSelectedIndex(0);
    composites.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            CompositeFieldConstraint comp = new CompositeFieldConstraint();
            comp.setCompositeJunctionType(composites.getValue(composites.getSelectedIndex()));
            fp.addConstraint(comp);
            modeller.refreshWidget();
            popup.hide();
        }
    });
    InfoPopup infoComp = new InfoPopup(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraints(), GuidedRuleEditorResources.CONSTANTS.MultipleConstraintsTip1());
    HorizontalPanel horiz = new HorizontalPanel();
    horiz.add(composites);
    horiz.add(infoComp);
    if (con == null) {
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.MultipleFieldConstraint(), horiz);
    }
    if (con == null) {
        // NON-NLS
        popup.addRow(new SmallLabel("<i>" + GuidedRuleEditorResources.CONSTANTS.AdvancedOptionsColon() + "</i>"));
        Button predicate = new Button(GuidedRuleEditorResources.CONSTANTS.NewFormula());
        predicate.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                SingleFieldConstraint con = new SingleFieldConstraint();
                con.setConstraintValueType(SingleFieldConstraint.TYPE_PREDICATE);
                fp.addConstraint(con);
                modeller.refreshWidget();
                popup.hide();
            }
        });
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.AddANewFormulaStyleExpression(), predicate);
        final Button expressionEditorButton = makeExpressionEditorButton(fp, popup);
        popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor(), expressionEditorButton);
        doBindingEditor(popup);
    }
    popup.show();
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CompositeFieldConstraint(org.drools.workbench.models.datamodel.rule.CompositeFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) 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) Button(org.gwtbootstrap3.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) InfoPopup(org.uberfire.ext.widgets.common.client.common.InfoPopup) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 15 with Button

use of org.gwtbootstrap3.client.ui.Button in project drools-wb by kiegroup.

the class PopupCreator method makeExpressionEditorButton.

Button makeExpressionEditorButton(final HasConstraints hasConstraints, final FormStylePopup popup) {
    final Button button = makeExpressionEditorButton();
    button.addClickHandler(onExpressionEditorButtonClick(hasConstraints, popup));
    return button;
}
Also used : Button(org.gwtbootstrap3.client.ui.Button)

Aggregations

Button (org.gwtbootstrap3.client.ui.Button)71 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)33 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)33 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)14 SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)12 HTML (com.google.gwt.user.client.ui.HTML)10 ListBox (org.gwtbootstrap3.client.ui.ListBox)10 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)9 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)9 InfoPopup (org.uberfire.ext.widgets.common.client.common.InfoPopup)9 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)7 TextBox (org.gwtbootstrap3.client.ui.TextBox)6 MenuItem (org.uberfire.workbench.model.menu.MenuItem)6 IsWidget (com.google.gwt.user.client.ui.IsWidget)5 Widget (com.google.gwt.user.client.ui.Widget)5 AnchorListItem (org.gwtbootstrap3.client.ui.AnchorListItem)5 ButtonGroup (org.gwtbootstrap3.client.ui.ButtonGroup)5 FlexTable (com.google.gwt.user.client.ui.FlexTable)4 ApplicationScoped (javax.enterprise.context.ApplicationScoped)4 Inject (javax.inject.Inject)4