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;
}
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;
}
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();
}
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;
}
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);
}
Aggregations