Search in sources :

Example 56 with ListBox

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

the class MethodParameterValueEditor method boundVariable.

private ListBox boundVariable() {
    BoundListBox boundListBox = new BoundListBox(modeller, methodParameter, new SuperTypeMatcher(oracle));
    boundListBox.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            ListBox w = (ListBox) event.getSource();
            setMethodParameterValue(w.getValue(w.getSelectedIndex()));
            refresh();
        }
    });
    return boundListBox;
}
Also used : ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) SuperTypeMatcher(org.drools.workbench.screens.guided.rule.client.editor.util.SuperTypeMatcher) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 57 with ListBox

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

the class MethodParameterCallValueEditor method boundVariable.

private ListBox boundVariable(final FieldNature c) {
    /*
         * If there is a bound variable that is the same type of the current
         * variable type, then propose a list
         */
    final ListBox listVariable = new ListBox();
    List<String> vars = model.getFactNamesInScope(ex, true);
    for (String v : vars) {
        FactData factData = (FactData) model.getFactTypes().get(v);
        if (factData.getType().equals(this.methodParameter.type)) {
            // First selection is empty
            if (listVariable.getItemCount() == 0) {
                listVariable.addItem("...");
            }
            listVariable.addItem("=" + v);
        }
    }
    if (methodParameter.value.equals("=")) {
        listVariable.setSelectedIndex(0);
    } else {
        for (int i = 0; i < listVariable.getItemCount(); i++) {
            if (listVariable.getItemText(i).equals(methodParameter.value)) {
                listVariable.setSelectedIndex(i);
            }
        }
    }
    if (listVariable.getItemCount() > 0) {
        listVariable.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                methodParameter.value = listVariable.getValue(listVariable.getSelectedIndex());
                refresh();
            }
        });
    }
    return listVariable;
}
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) FactData(org.drools.workbench.models.testscenarios.shared.FactData) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 58 with ListBox

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

the class CallMethodWidget method showAddFieldPopup.

protected void showAddFieldPopup(final Widget w) {
    final FormStylePopup popup = new FormStylePopup(TestScenarioAltedImages.INSTANCE.Wizard(), TestScenarioConstants.INSTANCE.ChooseAMethodToInvoke());
    ListBox box = new ListBox();
    box.addItem("...");
    for (int i = 0; i < fieldCompletionTexts.length; i++) {
        box.addItem(fieldCompletionTexts[i], fieldCompletionValues[i]);
    }
    box.setSelectedIndex(0);
    popup.addAttribute(TestScenarioConstants.INSTANCE.ChooseAMethodToInvoke(), box);
    box.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            mCall.setState(ActionCallMethod.TYPE_DEFINED);
            ListBox sourceW = (ListBox) event.getSource();
            final String methodName = sourceW.getItemText(sourceW.getSelectedIndex());
            final String methodNameWithParams = sourceW.getValue(sourceW.getSelectedIndex());
            mCall.setMethodName(methodName);
            oracle.getMethodParams(variableClass, methodNameWithParams, new Callback<List<String>>() {

                @Override
                public void callback(final List<String> fieldList) {
                    // String fieldType = oracle.getFieldType( variableClass, fieldName );
                    int i = 0;
                    for (String fieldParameter : fieldList) {
                        mCall.addFieldValue(new CallFieldValue(methodName, String.valueOf(i), fieldParameter));
                        i++;
                    }
                    parent.renderEditor();
                    popup.hide();
                }
            });
        }
    });
    popup.show();
}
Also used : Callback(org.uberfire.client.callbacks.Callback) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) FormStylePopup(org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup) List(java.util.List) ListBox(org.gwtbootstrap3.client.ui.ListBox) CallFieldValue(org.drools.workbench.models.testscenarios.shared.CallFieldValue)

Example 59 with ListBox

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

the class VerifyFactWidget method render.

private FlexTable render(final VerifyFact vf) {
    FlexTable data = new FlexTable();
    for (int i = 0; i < vf.getFieldValues().size(); i++) {
        final VerifyField fld = (VerifyField) vf.getFieldValues().get(i);
        data.setWidget(i, 1, new SmallLabel(fld.getFieldName() + ":"));
        data.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_RIGHT);
        final ListBox opr = new ListBox();
        opr.addItem(TestScenarioConstants.INSTANCE.equalsScenario(), "==");
        opr.addItem(TestScenarioConstants.INSTANCE.doesNotEqualScenario(), "!=");
        if (fld.getOperator().equals("==")) {
            opr.setSelectedIndex(0);
        } else {
            opr.setSelectedIndex(1);
        }
        opr.addChangeHandler(new ChangeHandler() {

            public void onChange(ChangeEvent event) {
                fld.setOperator(opr.getValue(opr.getSelectedIndex()));
            }
        });
        data.setWidget(i, 2, opr);
        Widget cellEditor = new VerifyFieldConstraintEditor(type, newValue -> fld.setExpected(newValue), fld, oracle, this.scenario, this.executionTrace);
        data.setWidget(i, 3, cellEditor);
        Button deleteButton = new Button();
        deleteButton.setIcon(IconType.TRASH);
        deleteButton.setTitle(TestScenarioConstants.INSTANCE.RemoveThisFieldExpectation());
        deleteButton.addClickHandler(clickEvent -> {
            if (Window.confirm(TestScenarioConstants.INSTANCE.AreYouSureYouWantToRemoveThisFieldExpectation(fld.getFieldName()))) {
                vf.getFieldValues().remove(fld);
                FlexTable renderedTableAfterDelete = render(vf);
                outer.setWidget(1, 0, renderedTableAfterDelete);
            }
        });
        data.setWidget(i, 4, deleteButton);
        if (showResults && fld.getSuccessResult() != null) {
            if (!fld.getSuccessResult().booleanValue()) {
                data.setWidget(i, 0, new Image(CommonImages.INSTANCE.warning()));
                data.setWidget(i, 5, new HTML(TestScenarioConstants.INSTANCE.ActualResult(fld.getActualResult())));
                data.getCellFormatter().addStyleName(i, 5, // NON-NLS
                "testErrorValue");
            } else {
                data.setWidget(i, 0, new Image(TestScenarioImages.INSTANCE.testPassed()));
            }
        }
    }
    ScenarioUtils.addBottomAndRightPaddingToTableCells(data);
    return data;
}
Also used : SmallLabel(org.uberfire.ext.widgets.common.client.common.SmallLabel) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) VerifyField(org.drools.workbench.models.testscenarios.shared.VerifyField) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Button(org.gwtbootstrap3.client.ui.Button) FlexTable(com.google.gwt.user.client.ui.FlexTable) Widget(com.google.gwt.user.client.ui.Widget) HTML(com.google.gwt.user.client.ui.HTML) Image(com.google.gwt.user.client.ui.Image) ListBox(org.gwtbootstrap3.client.ui.ListBox)

Example 60 with ListBox

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

the class DTCellValueWidgetFactoryTest method testGetWidgetEnumsForBRLColumn.

@Test
public void testGetWidgetEnumsForBRLColumn() throws Exception {
    BRLActionVariableColumn column = mock(BRLActionVariableColumn.class);
    doReturn("Person").when(column).getFactType();
    doReturn("name").when(column).getFactField();
    when(oracle.hasEnums("Person", "name")).thenReturn(true);
    IsWidget widget = factory.getWidget(column, cellValue);
    assertTrue(widget instanceof ListBox);
}
Also used : IsWidget(com.google.gwt.user.client.ui.IsWidget) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) ListBox(org.gwtbootstrap3.client.ui.ListBox) Test(org.junit.Test)

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