Search in sources :

Example 1 with TextBox

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

the class MethodParameterCallValueEditor method refresh.

private void refresh() {
    root.clear();
    if (enums != null && (enums.getFixedList() != null || enums.getQueryExpression() != null)) {
        root.add(new EnumDropDown(methodParameter.value, new DropDownValueChanged() {

            public void valueChanged(String newText, String newValue) {
                methodParameter.value = newValue;
            }
        }, enums, oracle.getResourcePath()));
    } else {
        if (methodParameter.nature == FieldNatureType.TYPE_UNDEFINED) {
            // we have a blank slate..
            // have to give them a choice
            root.add(choice());
        } else {
            if (methodParameter.nature == FieldNatureType.TYPE_VARIABLE) {
                ListBox list = boundVariable(methodParameter);
                root.add(list);
            } else {
                TextBox box = boundTextBox(this.methodParameter);
                root.add(box);
            }
        }
    }
}
Also used : EnumDropDown(org.drools.workbench.screens.guided.rule.client.widget.EnumDropDown) TextBox(org.gwtbootstrap3.client.ui.TextBox) DropDownValueChanged(org.uberfire.ext.widgets.common.client.common.DropDownValueChanged) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 2 with TextBox

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

the class MethodParameterCallValueEditor method boundTextBox.

private TextBox boundTextBox(final CallFieldValue c) {
    final TextBox box = TextBoxFactory.getTextBox(methodParameter.type);
    box.setStyleName("constraint-value-Editor");
    if (c.value == null) {
        box.setText("");
    } else {
        if (c.value.trim().equals("")) {
            c.value = "";
        }
        box.setText(c.value);
    }
    if (c.value == null || c.value.length() < 5) {
        ((InputElement) box.getElement().cast()).setSize(6);
    } else {
        ((InputElement) box.getElement().cast()).setSize(c.value.length() - 1);
    }
    box.addValueChangeHandler(new ValueChangeHandler<String>() {

        public void onValueChange(final ValueChangeEvent<String> event) {
            c.value = event.getValue();
        }
    });
    box.addKeyUpHandler(new KeyUpHandler() {

        public void onKeyUp(KeyUpEvent event) {
            ((InputElement) box.getElement().cast()).setSize(box.getText().length());
        }
    });
    return box;
}
Also used : KeyUpEvent(com.google.gwt.event.dom.client.KeyUpEvent) TextBox(org.gwtbootstrap3.client.ui.TextBox) InputElement(com.google.gwt.dom.client.InputElement) KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler)

Example 3 with TextBox

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

the class VerifyRulesFiredWidget method render.

private FlexTable render(final FixtureList rfl, final Scenario sc) {
    FlexTable data = new FlexTable();
    for (int i = 0; i < rfl.size(); i++) {
        final VerifyRuleFired v = (VerifyRuleFired) rfl.get(i);
        if (showResults && v.getSuccessResult() != null) {
            if (!v.getSuccessResult().booleanValue()) {
                data.setWidget(i, 0, new Image(CommonImages.INSTANCE.warning()));
                data.setWidget(i, 4, new HTML(TestScenarioConstants.INSTANCE.ActualResult(v.getActualResult().toString())));
                data.getCellFormatter().addStyleName(i, 4, // NON-NLS
                "testErrorValue");
            } else {
                data.setWidget(i, 0, new Image(TestScenarioImages.INSTANCE.testPassed()));
            }
        }
        data.setWidget(i, 1, new SmallLabel(v.getRuleName() + ":"));
        data.getFlexCellFormatter().setAlignment(i, 1, HasHorizontalAlignment.ALIGN_RIGHT, HasVerticalAlignment.ALIGN_MIDDLE);
        final ListBox b = new ListBox();
        b.addItem(TestScenarioConstants.INSTANCE.firedAtLeastOnce(), "y");
        b.addItem(TestScenarioConstants.INSTANCE.didNotFire(), "n");
        b.addItem(TestScenarioConstants.INSTANCE.firedThisManyTimes(), "e");
        final TextBox num = new TextBox();
        ((InputElement) num.getElement().cast()).setSize(5);
        if (v.getExpectedFire() != null) {
            b.setSelectedIndex((v.getExpectedFire().booleanValue()) ? 0 : 1);
            num.setVisible(false);
        } else {
            b.setSelectedIndex(2);
            String xc = (v.getExpectedCount() != null) ? "" + v.getExpectedCount().intValue() : "0";
            num.setText(xc);
        }
        b.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                String s = b.getValue(b.getSelectedIndex());
                if (s.equals("y") || s.equals("n")) {
                    num.setVisible(false);
                    v.setExpectedFire((s.equals("y")) ? Boolean.TRUE : Boolean.FALSE);
                    v.setExpectedCount(null);
                } else {
                    num.setVisible(true);
                    v.setExpectedFire(null);
                    num.setText("1");
                    v.setExpectedCount(Integer.valueOf(1));
                }
            }
        });
        b.addItem(TestScenarioConstants.INSTANCE.ChooseDotDotDot());
        num.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                v.setExpectedCount(Integer.valueOf(num.getText()));
            }
        });
        HorizontalPanel h = new HorizontalPanel();
        h.add(b);
        h.add(num);
        data.setWidget(i, 2, h);
        Button del = new Button();
        del.setIcon(IconType.TRASH);
        del.setTitle(TestScenarioConstants.INSTANCE.RemoveThisRuleExpectation());
        del.addClickHandler(clickEvent -> {
            if (Window.confirm(TestScenarioConstants.INSTANCE.AreYouSureYouWantToRemoveThisRuleExpectation())) {
                rfl.remove(v);
                sc.removeFixture(v);
                outer.setWidget(1, 0, render(rfl, sc));
            }
        });
        data.setWidget(i, 3, del);
        // we only want numbers here...
        num.addKeyPressHandler(new KeyPressHandler() {

            public void onKeyPress(KeyPressEvent event) {
                if (Character.isLetter(event.getCharCode())) {
                    ((TextBox) event.getSource()).cancelKey();
                }
            }
        });
    }
    ScenarioUtils.addBottomAndRightPaddingToTableCells(data);
    return data;
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) VerifyRuleFired(org.drools.workbench.models.testscenarios.shared.VerifyRuleFired) FlexTable(com.google.gwt.user.client.ui.FlexTable) HTML(com.google.gwt.user.client.ui.HTML) TextBox(org.gwtbootstrap3.client.ui.TextBox) InputElement(com.google.gwt.dom.client.InputElement) Image(com.google.gwt.user.client.ui.Image) KeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) KeyPressEvent(com.google.gwt.event.dom.client.KeyPressEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(org.gwtbootstrap3.client.ui.Button) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 4 with TextBox

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

the class DTCellValueWidgetFactory method makeTextBox.

private TextBox makeTextBox(final DTCellValue52 value) {
    TextBox tb = new TextBox();
    tb.setValue(value.getStringValue());
    // Wire up update handler
    tb.setEnabled(!isReadOnly);
    if (!isReadOnly) {
        tb.addValueChangeHandler(new ValueChangeHandler<String>() {

            public void onValueChange(ValueChangeEvent<String> event) {
                value.setStringValue(event.getValue());
            }
        });
    }
    return tb;
}
Also used : NumericBigDecimalTextBox(org.uberfire.ext.widgets.common.client.common.NumericBigDecimalTextBox) AbstractRestrictedEntryTextBox(org.uberfire.ext.widgets.common.client.common.AbstractRestrictedEntryTextBox) NumericShortTextBox(org.uberfire.ext.widgets.common.client.common.NumericShortTextBox) NumericTextBox(org.uberfire.ext.widgets.common.client.common.NumericTextBox) NumericIntegerTextBox(org.uberfire.ext.widgets.common.client.common.NumericIntegerTextBox) TextBox(org.gwtbootstrap3.client.ui.TextBox) NumericLongTextBox(org.uberfire.ext.widgets.common.client.common.NumericLongTextBox) NumericDoubleTextBox(org.uberfire.ext.widgets.common.client.common.NumericDoubleTextBox) NumericFloatTextBox(org.uberfire.ext.widgets.common.client.common.NumericFloatTextBox) NumericByteTextBox(org.uberfire.ext.widgets.common.client.common.NumericByteTextBox) NumericBigIntegerTextBox(org.uberfire.ext.widgets.common.client.common.NumericBigIntegerTextBox)

Example 5 with TextBox

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

the class DefaultValueWidgetFactory method getDefaultValueWidget.

// BZ-996932: Added value change notifications.
public static Widget getDefaultValueWidget(final AttributeCol52 ac, final boolean isReadOnly, final DefaultValueChangedEventHandler defaultValueChangedEventHandler) {
    Widget editor = null;
    final String attributeName = ac.getAttribute();
    if (attributeName.equals(RuleAttributeWidget.RULEFLOW_GROUP_ATTR) || attributeName.equals(RuleAttributeWidget.AGENDA_GROUP_ATTR) || attributeName.equals(RuleAttributeWidget.ACTIVATION_GROUP_ATTR) || attributeName.equals(RuleAttributeWidget.TIMER_ATTR) || attributeName.equals(RuleAttributeWidget.CALENDARS_ATTR)) {
        final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
        if (ac.getDefaultValue() == null) {
            ac.setDefaultValue(new DTCellValue52(""));
        }
        final DTCellValue52 defaultValue = ac.getDefaultValue();
        tb.setValue(defaultValue.getStringValue());
        tb.setEnabled(!isReadOnly);
        if (!isReadOnly) {
            tb.addValueChangeHandler(new ValueChangeHandler<String>() {

                public void onValueChange(ValueChangeEvent<String> event) {
                    DTCellValue52 editedDefaultValue = defaultValue.cloneDefaultValueCell();
                    editedDefaultValue.setStringValue(tb.getValue());
                    defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, editedDefaultValue));
                }
            });
        }
        editor = tb;
    } else if (attributeName.equals(RuleAttributeWidget.SALIENCE_ATTR)) {
        final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_INTEGER);
        if (ac.getDefaultValue() == null) {
            ac.setDefaultValue(new DTCellValue52(0));
        } else {
            assertIntegerDefaultValue(ac.getDefaultValue());
        }
        final DTCellValue52 defaultValue = ac.getDefaultValue();
        final Integer numericValue = (Integer) defaultValue.getNumericValue();
        tb.setValue(numericValue == null ? "" : numericValue.toString());
        tb.setEnabled(!isReadOnly);
        if (!isReadOnly) {
            tb.addValueChangeHandler(new ValueChangeHandler<String>() {

                public void onValueChange(ValueChangeEvent<String> event) {
                    DTCellValue52 editedDefaultValue = defaultValue.cloneDefaultValueCell();
                    try {
                        editedDefaultValue.setNumericValue(Integer.valueOf(event.getValue()));
                    } catch (NumberFormatException nfe) {
                        editedDefaultValue.setNumericValue(0);
                        tb.setValue("0");
                    } finally {
                        defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, editedDefaultValue));
                    }
                }
            });
        }
        editor = tb;
    } else if (attributeName.equals(RuleAttributeWidget.DURATION_ATTR)) {
        final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_LONG);
        if (ac.getDefaultValue() == null) {
            ac.setDefaultValue(new DTCellValue52(0L));
        } else {
            assertLongDefaultValue(ac.getDefaultValue());
        }
        final DTCellValue52 defaultValue = ac.getDefaultValue();
        final Long numericValue = (Long) defaultValue.getNumericValue();
        tb.setValue(numericValue == null ? "" : numericValue.toString());
        tb.setEnabled(!isReadOnly);
        if (!isReadOnly) {
            tb.addValueChangeHandler(new ValueChangeHandler<String>() {

                public void onValueChange(ValueChangeEvent<String> event) {
                    DTCellValue52 editedDefaultValue = defaultValue.cloneDefaultValueCell();
                    try {
                        editedDefaultValue.setNumericValue(Long.valueOf(event.getValue()));
                    } catch (NumberFormatException nfe) {
                        editedDefaultValue.setNumericValue(0L);
                        tb.setValue("0");
                    } finally {
                        defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, editedDefaultValue));
                    }
                }
            });
        }
        editor = tb;
    } else if (attributeName.equals(RuleAttributeWidget.NO_LOOP_ATTR) || attributeName.equals(RuleAttributeWidget.LOCK_ON_ACTIVE_ATTR) || attributeName.equals(RuleAttributeWidget.AUTO_FOCUS_ATTR) || attributeName.equals(RuleAttributeWidget.ENABLED_ATTR) || attributeName.equals(GuidedDecisionTable52.NEGATE_RULE_ATTR)) {
        final CheckBox cb = new CheckBox();
        if (ac.getDefaultValue() == null) {
            ac.setDefaultValue(new DTCellValue52(Boolean.FALSE));
        } else {
            assertBooleanDefaultValue(ac.getDefaultValue());
        }
        final DTCellValue52 defaultValue = ac.getDefaultValue();
        final Boolean booleanValue = defaultValue.getBooleanValue();
        cb.setEnabled(!isReadOnly);
        if (booleanValue == null) {
            cb.setValue(false);
            defaultValue.setBooleanValue(Boolean.FALSE);
        } else {
            cb.setValue(booleanValue);
        }
        cb.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                DTCellValue52 editedDefaultValue = defaultValue.cloneDefaultValueCell();
                editedDefaultValue.setBooleanValue(cb.getValue());
                defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, editedDefaultValue));
            }
        });
        editor = cb;
    } else if (attributeName.equals(RuleAttributeWidget.DATE_EFFECTIVE_ATTR) || attributeName.equals(RuleAttributeWidget.DATE_EXPIRES_ATTR)) {
        if (ac.getDefaultValue() == null) {
            ac.setDefaultValue(new DTCellValue52(new Date()));
        } else {
            assertDateDefaultValue(ac.getDefaultValue());
        }
        final DTCellValue52 defaultValue = ac.getDefaultValue();
        if (isReadOnly) {
            final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
            tb.setValue(format.format(defaultValue.getDateValue()));
            tb.setEnabled(false);
        } else {
            final DatePicker datePicker = new DatePicker();
            // Wire up update handler
            datePicker.addChangeDateHandler((e) -> {
                DTCellValue52 editedDefaultValue = defaultValue.cloneDefaultValueCell();
                editedDefaultValue.setDateValue(datePicker.getValue());
                defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, editedDefaultValue));
            });
            final Date dateValue = defaultValue.getDateValue();
            datePicker.setFormat(DATE_FORMAT);
            datePicker.setValue(dateValue);
            editor = datePicker;
        }
    } else if (attributeName.equals(RuleAttributeWidget.DIALECT_ATTR)) {
        final ListBox lb = new ListBox();
        lb.addItem(RuleAttributeWidget.DIALECTS[0]);
        lb.addItem(RuleAttributeWidget.DIALECTS[1]);
        if (ac.getDefaultValue() == null) {
            ac.setDefaultValue(new DTCellValue52(RuleAttributeWidget.DIALECTS[1]));
        }
        final DTCellValue52 defaultValue = ac.getDefaultValue();
        final String stringValue = defaultValue.getStringValue();
        lb.setEnabled(!isReadOnly);
        if (!isReadOnly) {
            lb.addChangeHandler(new ChangeHandler() {

                @Override
                public void onChange(ChangeEvent event) {
                    final int selectedIndex = lb.getSelectedIndex();
                    if (selectedIndex < 0) {
                        return;
                    }
                    DTCellValue52 editedDefaultValue = defaultValue.cloneDefaultValueCell();
                    editedDefaultValue.setStringValue(lb.getValue(selectedIndex));
                    defaultValueChangedEventHandler.onDefaultValueChanged(new DefaultValueChangedEvent(defaultValue, editedDefaultValue));
                }
            });
        }
        if (stringValue == null || stringValue.isEmpty()) {
            lb.setSelectedIndex(1);
            defaultValue.setStringValue(RuleAttributeWidget.DIALECTS[1]);
        } else if (stringValue.equals(RuleAttributeWidget.DIALECTS[0])) {
            lb.setSelectedIndex(0);
        } else if (stringValue.equals(RuleAttributeWidget.DIALECTS[1])) {
            lb.setSelectedIndex(1);
        } else {
            lb.setSelectedIndex(1);
            defaultValue.setStringValue(RuleAttributeWidget.DIALECTS[1]);
        }
        editor = lb;
    }
    return editor;
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) RuleAttributeWidget(org.drools.workbench.screens.guided.rule.client.editor.RuleAttributeWidget) Widget(com.google.gwt.user.client.ui.Widget) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) TextBox(org.gwtbootstrap3.client.ui.TextBox) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) Date(java.util.Date) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CheckBox(org.gwtbootstrap3.client.ui.CheckBox) DatePicker(org.uberfire.ext.widgets.common.client.common.DatePicker) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Aggregations

TextBox (org.gwtbootstrap3.client.ui.TextBox)31 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)11 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)11 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)10 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)10 ListBox (org.gwtbootstrap3.client.ui.ListBox)9 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)7 Button (org.gwtbootstrap3.client.ui.Button)7 SmallLabel (org.uberfire.ext.widgets.common.client.common.SmallLabel)7 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)6 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)6 FlexTable (com.google.gwt.user.client.ui.FlexTable)5 Widget (com.google.gwt.user.client.ui.Widget)5 Date (java.util.Date)5 DatePicker (org.uberfire.ext.widgets.common.client.common.DatePicker)5 InputElement (com.google.gwt.dom.client.InputElement)4 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)4 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)4 HTML (com.google.gwt.user.client.ui.HTML)4 Image (com.google.gwt.user.client.ui.Image)3