Search in sources :

Example 1 with ListBox

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

the class RuleAttributeWidget method getEditorWidget.

private Widget getEditorWidget(final RuleAttribute at, final int idx, final boolean isReadOnly) {
    Widget editor = null;
    final String attributeName = at.getAttributeName();
    if (attributeName.equals(RULEFLOW_GROUP_ATTR) || attributeName.equals(AGENDA_GROUP_ATTR) || attributeName.equals(ACTIVATION_GROUP_ATTR) || attributeName.equals(TIMER_ATTR) || attributeName.equals(CALENDARS_ATTR)) {
        final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
        tb.setEnabled(!isReadOnly);
        if (!isReadOnly) {
            tb.addValueChangeHandler(new ValueChangeHandler<String>() {

                public void onValueChange(ValueChangeEvent<String> event) {
                    at.setValue(tb.getValue());
                }
            });
        }
        tb.setValue(at.getValue());
        editor = tb;
    } else if (attributeName.equals(SALIENCE_ATTR)) {
        final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_INTEGER);
        tb.setEnabled(!isReadOnly);
        if (!isReadOnly) {
            tb.addValueChangeHandler(new ValueChangeHandler<String>() {

                public void onValueChange(ValueChangeEvent<String> event) {
                    at.setValue(tb.getValue());
                }
            });
        }
        tb.setValue(at.getValue());
        editor = tb;
    } else if (attributeName.equals(DURATION_ATTR)) {
        final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_NUMERIC_LONG);
        tb.setEnabled(!isReadOnly);
        if (!isReadOnly) {
            tb.addValueChangeHandler(new ValueChangeHandler<String>() {

                public void onValueChange(ValueChangeEvent<String> event) {
                    at.setValue(tb.getValue());
                }
            });
        }
        tb.setValue(at.getValue());
        editor = tb;
    } else if (attributeName.equals(NO_LOOP_ATTR) || attributeName.equals(LOCK_ON_ACTIVE_ATTR) || attributeName.equals(AUTO_FOCUS_ATTR) || attributeName.equals(ENABLED_ATTR)) {
        editor = checkBoxEditor(at, isReadOnly);
    } else if (attributeName.equals(DATE_EFFECTIVE_ATTR) || attributeName.equals(DATE_EXPIRES_ATTR)) {
        if (isReadOnly) {
            final TextBox tb = TextBoxFactory.getTextBox(DataType.TYPE_STRING);
            tb.setValue(at.getValue());
            tb.setEnabled(false);
        } else {
            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()));
                    at.setValue(sDate);
                }
            });
            datePicker.setFormat(DATE_FORMAT);
            datePicker.setValue(assertDateValue(at));
            editor = datePicker;
        }
    } else if (attributeName.equals(DIALECT_ATTR)) {
        final ListBox lb = new ListBox();
        lb.addItem(DIALECTS[0]);
        lb.addItem(DIALECTS[1]);
        lb.setEnabled(!isReadOnly);
        if (!isReadOnly) {
            lb.addChangeHandler(new ChangeHandler() {

                @Override
                public void onChange(ChangeEvent event) {
                    final int selectedIndex = lb.getSelectedIndex();
                    if (selectedIndex < 0) {
                        return;
                    }
                    at.setValue(lb.getValue(selectedIndex));
                }
            });
        }
        if (at.getValue() == null || at.getValue().isEmpty()) {
            lb.setSelectedIndex(1);
            at.setValue(DIALECTS[1]);
        } else if (at.getValue().equals(DIALECTS[0])) {
            lb.setSelectedIndex(0);
        } else if (at.getValue().equals(DIALECTS[1])) {
            lb.setSelectedIndex(1);
        } else {
            lb.setSelectedIndex(1);
            at.setValue(DIALECTS[1]);
        }
        editor = lb;
    }
    DirtyableHorizontalPane horiz = new DirtyableHorizontalPane();
    if (editor != null) {
        horiz.add(editor);
        if (!isReadOnly) {
            horiz.add(getRemoveIcon(idx));
        }
    }
    return horiz;
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) Widget(com.google.gwt.user.client.ui.Widget) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) TextBox(org.gwtbootstrap3.client.ui.TextBox) Date(java.util.Date) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) 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) DirtyableHorizontalPane(org.uberfire.ext.widgets.common.client.common.DirtyableHorizontalPane) DatePicker(org.uberfire.ext.widgets.common.client.common.DatePicker) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 2 with ListBox

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

the class RuleModellerConditionSelectorPopup method makeChoicesListBox.

private ListBox makeChoicesListBox() {
    choices = GWT.create(ListBox.class);
    choices.setMultipleSelect(true);
    choices.setPixelSize(getChoicesWidth(), getChoicesHeight());
    choices.addKeyUpHandler(new KeyUpHandler() {

        public void onKeyUp(com.google.gwt.event.dom.client.KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                selectSomething();
            }
        }
    });
    addDSLSentences();
    if (!onlyShowDSLStatements) {
        addFacts();
        addExistentialConditionalElements();
        addFromConditionalElements();
        addFreeFormDrl();
    }
    return choices;
}
Also used : KeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 3 with ListBox

use of org.gwtbootstrap3.client.ui.ListBox in project kie-wb-common by kiegroup.

the class EnumDropDownUtilitiesTest method testCommaSeparatedValuesWithBrackets.

@Test
public void testCommaSeparatedValuesWithBrackets() {
    final DropDownData downData = mock(DropDownData.class);
    doReturn(new String[] { "a", "\"b, c\"", "d" }).when(downData).getFixedList();
    final ListBox listBox = mock(ListBox.class);
    new EnumDropDownUtilities().setDropDownData(" ( \"a\",\"d\" )", downData, true, mock(Path.class), listBox);
    verify(listBox).clear();
    verify(listBox).addItem("a");
    verify(listBox).addItem("\"b, c\"");
    verify(listBox).addItem("d");
    verify(listBox).setItemSelected(0, true);
    verify(listBox, never()).setItemSelected(1, true);
    verify(listBox).setItemSelected(2, true);
}
Also used : Path(org.uberfire.backend.vfs.Path) DropDownData(org.kie.soup.project.datamodel.oracle.DropDownData) ListBox(org.gwtbootstrap3.client.ui.ListBox) Test(org.junit.Test)

Example 4 with ListBox

use of org.gwtbootstrap3.client.ui.ListBox 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 5 with ListBox

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

the class FieldDataConstraintEditor method variableEditor.

private Widget variableEditor() {
    List<String> vars = helper.getFactNamesInScope();
    final ListBox box = new ListBox();
    if (this.field.getValue() == null) {
        box.addItem(TestScenarioConstants.INSTANCE.Choose());
    }
    int j = 0;
    for (String var : vars) {
        if (helper.getFactTypeByVariableName(var).getType().equals(helper.resolveFieldType())) {
            if (box.getItemCount() == 0) {
                box.addItem("...");
                j++;
            }
            box.addItem("=" + var);
            if (this.field.getValue() != null && this.field.getValue().equals("=" + var)) {
                box.setSelectedIndex(j);
            }
            j++;
        }
    }
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            field.setValue(box.getItemText(box.getSelectedIndex()));
            valueHasChanged(field.getValue());
        }
    });
    return box;
}
Also used : 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) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Aggregations

ListBox (org.gwtbootstrap3.client.ui.ListBox)61 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)31 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)30 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)15 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)15 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)12 Widget (com.google.gwt.user.client.ui.Widget)11 Test (org.junit.Test)11 Button (org.gwtbootstrap3.client.ui.Button)10 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)10 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)9 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)9 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)7 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)7 TextBox (org.gwtbootstrap3.client.ui.TextBox)7 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)6 IsWidget (com.google.gwt.user.client.ui.IsWidget)6 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)6 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)6 DropDownData (org.kie.soup.project.datamodel.oracle.DropDownData)6