Search in sources :

Example 16 with TextBox

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

the class FromEntryPointFactPatternWidget method getCompositeLabel.

@Override
protected Widget getCompositeLabel() {
    ClickHandler click = new ClickHandler() {

        public void onClick(ClickEvent event) {
            showFactTypeSelector();
        }
    };
    String lbl = "<div class='form-field'>" + HumanReadable.getCEDisplayName("from entry-point") + "</div>";
    FlexTable panel = new FlexTable();
    int r = 0;
    if (pattern.getFactPattern() == null) {
        panel.setWidget(r, 0, new ClickableLabel("<br> <font color='red'>" + GuidedRuleEditorResources.CONSTANTS.clickToAddPatterns() + "</font>", click, !this.readOnly));
        r++;
    }
    panel.setWidget(r, 0, new HTML(lbl));
    this.txtEntryPoint = new TextBox();
    this.txtEntryPoint.setText(getFromEntryPointPattern().getEntryPointName());
    this.txtEntryPoint.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            getFromEntryPointPattern().setEntryPointName(txtEntryPoint.getText());
            setModified(true);
        }
    });
    panel.setWidget(r, 1, this.txtEntryPoint);
    return panel;
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlexTable(com.google.gwt.user.client.ui.FlexTable) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) HTML(com.google.gwt.user.client.ui.HTML) TextBox(org.gwtbootstrap3.client.ui.TextBox)

Example 17 with TextBox

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

the class ExpressionBuilder method createWidgetForExpression.

// Render Widgets for the Expression. ExpressionMethodParameter and ExpressionText parts
// are represented by a TextBox to allow the User to edit the values, Updates are
// reflected in the model.
private Widget createWidgetForExpression() {
    final HorizontalPanel container = new HorizontalPanel();
    container.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    container.setStylePrimaryName(GuidedRuleEditorResources.INSTANCE.css().container());
    for (ExpressionPart expressionPart : expression.getParts()) {
        if (expressionPart instanceof ExpressionUnboundFact) {
            continue;
        } else if (this.readOnly) {
            container.add(new Label(expressionPart.getName()));
        } else if (expressionPart instanceof ExpressionMethod) {
            container.add(new Label(expressionPart.getName()));
            container.add(new Label("("));
            final ExpressionMethod em = (ExpressionMethod) expressionPart;
            final List<ExpressionFormLine> emParams = em.getOrderedParams();
            for (int index = 0; index < emParams.size(); index++) {
                final ExpressionFormLine paramValueHolder = emParams.get(index);
                final String paramDataType = em.getParameterDataType(paramValueHolder);
                final ExpressionMethodParameter paramValue = ((ExpressionMethodParameter) paramValueHolder.getRootExpression());
                final TextBox paramValueEditor = TextBoxFactory.getTextBox(paramDataType);
                paramValueEditor.addValueChangeHandler(new ValueChangeHandler<String>() {

                    @Override
                    public void onValueChange(ValueChangeEvent<String> event) {
                        paramValue.setText(event.getValue());
                    }
                });
                paramValueEditor.setText(paramValue.getName());
                container.add(paramValueEditor);
                if (index < emParams.size() - 1) {
                    container.add(new Label(", "));
                }
            }
            container.add(new Label(")"));
        } else if (!(expressionPart instanceof ExpressionText)) {
            container.add(new Label(expressionPart.getName()));
        } else {
            final TextBox tb = new TextBox();
            final ExpressionText expressionTextPart = (ExpressionText) expressionPart;
            tb.setText(expressionTextPart.getName());
            tb.addChangeHandler(new ChangeHandler() {

                @Override
                public void onChange(final ChangeEvent changeEvent) {
                    expressionTextPart.setText(tb.getText());
                }
            });
            container.add(tb);
        }
        container.add(new Label("."));
    }
    return container;
}
Also used : ExpressionMethodParameter(org.drools.workbench.models.datamodel.rule.ExpressionMethodParameter) ExpressionPart(org.drools.workbench.models.datamodel.rule.ExpressionPart) Label(com.google.gwt.user.client.ui.Label) ClickableLabel(org.uberfire.ext.widgets.common.client.common.ClickableLabel) SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ExpressionText(org.drools.workbench.models.datamodel.rule.ExpressionText) TextBox(org.gwtbootstrap3.client.ui.TextBox) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) ExpressionMethod(org.drools.workbench.models.datamodel.rule.ExpressionMethod) ExpressionFormLine(org.drools.workbench.models.datamodel.rule.ExpressionFormLine) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) ExpressionTypeChangeEvent(org.drools.workbench.screens.guided.rule.client.editor.ExpressionTypeChangeEvent) ExpressionChangeEvent(org.drools.workbench.screens.guided.rule.client.editor.ExpressionChangeEvent) ExpressionChangeHandler(org.drools.workbench.screens.guided.rule.client.editor.ExpressionChangeHandler) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ExpressionTypeChangeHandler(org.drools.workbench.screens.guided.rule.client.editor.ExpressionTypeChangeHandler) HorizontalPanel(com.google.gwt.user.client.ui.HorizontalPanel)

Example 18 with TextBox

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

the class ExpressionBuilder method showBindingPopUp.

private void showBindingPopUp() {
    final FormStylePopup popup = new FormStylePopup(GuidedRuleEditorResources.CONSTANTS.ExpressionEditor());
    final TextBox varName = new TextBox();
    if (expression.isBound()) {
        varName.setText(expression.getBinding());
    }
    popup.addAttribute(GuidedRuleEditorResources.CONSTANTS.BindTheExpressionToAVariable(), new InputGroup() {

        {
            add(varName);
            add(new InputGroupButton() {

                {
                    add(new Button(HumanReadableConstants.INSTANCE.Set()) {

                        {
                            addClickHandler(new ClickHandler() {

                                public void onClick(ClickEvent event) {
                                    String var = varName.getText();
                                    if (getModeller().isVariableNameUsed(var)) {
                                        Window.alert(GuidedRuleEditorResources.CONSTANTS.TheVariableName0IsAlreadyTaken(var));
                                        return;
                                    }
                                    expression.setBinding(var);
                                    getModeller().refreshWidget();
                                    popup.hide();
                                }
                            });
                        }
                    });
                }
            });
        }
    });
    popup.show();
}
Also used : InputGroup(org.gwtbootstrap3.client.ui.InputGroup) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) InputGroupButton(org.gwtbootstrap3.client.ui.InputGroupButton) Button(org.gwtbootstrap3.client.ui.Button) InputGroupButton(org.gwtbootstrap3.client.ui.InputGroupButton) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) TextBox(org.gwtbootstrap3.client.ui.TextBox)

Example 19 with TextBox

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

the class ConstraintValueEditorTest method defaultTextBoxHasHandlersAttachedInCorrectOrder.

@Test
public void defaultTextBoxHasHandlersAttachedInCorrectOrder() {
    final TextBox defaultTextBox = mock(TextBox.class);
    final ConstraintValueEditor editor = spy(createEditor(constraint));
    final InOrder inOrder = inOrder(editor);
    doReturn(defaultTextBox).when(editor).getDefaultTextBox(any(String.class));
    editor.getNewTextBox(DataType.TYPE_STRING);
    inOrder.verify(editor).setUpTextBoxStyleAndHandlers(eq(defaultTextBox), any(Command.class));
    verify(defaultTextBox, times(1)).setText(any(String.class));
    inOrder.verify(editor).attachDisplayLengthHandler(eq(defaultTextBox));
}
Also used : InOrder(org.mockito.InOrder) Command(com.google.gwt.user.client.Command) LiteralTextBox(org.kie.workbench.common.widgets.client.widget.LiteralTextBox) TextBox(org.gwtbootstrap3.client.ui.TextBox) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 20 with TextBox

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

the class GuidedScoreCardEditor method getCharacteristicFromTable.

private Characteristic getCharacteristicFromTable(FlexTable flexTable) {
    ListBox enumDropDown;
    final Characteristic characteristic = new Characteristic();
    characteristic.setName(((TextBox) flexTable.getWidget(0, 1)).getValue());
    // Characteristic Fact Type
    enumDropDown = (ListBox) flexTable.getWidget(2, 0);
    if (enumDropDown.getSelectedIndex() > -1) {
        final String simpleFactName = enumDropDown.getValue(enumDropDown.getSelectedIndex());
        characteristic.setFact(simpleFactName);
        oracle.getFieldCompletions(simpleFactName, new Callback<ModelField[]>() {

            @Override
            public void callback(final ModelField[] fields) {
                if (fields != null) {
                    for (ModelField mf : fields) {
                        if (mf.getType().equals(simpleFactName)) {
                            characteristic.setFact(mf.getClassName());
                            break;
                        }
                    }
                }
            }
        });
        // Characteristic Field (cannot be set if no Fact Type has been set)
        enumDropDown = (ListBox) flexTable.getWidget(2, 1);
        if (enumDropDown.getSelectedIndex() > -1) {
            String fieldName = enumDropDown.getValue(enumDropDown.getSelectedIndex());
            fieldName = fieldName.substring(0, fieldName.indexOf(":")).trim();
            characteristic.setField(fieldName);
        } else {
            characteristic.setField("");
        }
        getDataTypeForField(simpleFactName, characteristic.getField(), new Callback<String>() {

            @Override
            public void callback(final String result) {
                characteristic.setDataType(result);
            }
        });
    }
    // Characteristic Reason Code
    characteristic.setReasonCode(((TextBox) flexTable.getWidget(2, 3)).getValue());
    // Characteristic Base Line Score
    final String baselineScore = ((TextBox) flexTable.getWidget(2, 2)).getValue();
    try {
        characteristic.setBaselineScore(Double.parseDouble(baselineScore));
    } catch (Exception e) {
        characteristic.setBaselineScore(0.0d);
    }
    return characteristic;
}
Also used : ModelField(org.kie.soup.project.datamodel.oracle.ModelField) Characteristic(org.drools.workbench.models.guided.scorecard.shared.Characteristic) TextBox(org.gwtbootstrap3.client.ui.TextBox) 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