use of org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide in project drools-wb by kiegroup.
the class SingleFieldConstraintOperatorSelector method configure.
public void configure(final SingleFieldConstraint constraint, final Supplier<ConstraintValueEditor> constraintValueEditor, final Function<SingleFieldConstraint, ConstraintValueEditor> constraintValueEditorProducer, final FactPatternWidget parent, final HorizontalPanel placeholderForDropdown, final FlexTable constraintValueEditorWrapper, final int constraintValueEditorRowIndex, final int constraintValueEditorColumnIndex, final AsyncPackageDataModelOracle oracle) {
this.constraint = constraint;
this.constraintValueEditor = constraintValueEditor;
this.constraintValueEditorProducer = constraintValueEditorProducer;
this.parent = parent;
this.placeholderForDropdown = placeholderForDropdown;
this.constraintValueEditorWrapper = constraintValueEditorWrapper;
this.constraintValueEditorRowIndex = constraintValueEditorRowIndex;
this.constraintValueEditorColumnIndex = constraintValueEditorColumnIndex;
this.oracle = oracle;
String fieldName;
String factType;
// Connectives Operators are handled in class Connectives
if (constraint instanceof SingleFieldConstraintEBLeftSide) {
SingleFieldConstraintEBLeftSide sfexp = (SingleFieldConstraintEBLeftSide) constraint;
factType = sfexp.getExpressionLeftSide().getPreviousClassType();
if (factType == null) {
factType = sfexp.getExpressionLeftSide().getClassType();
}
fieldName = sfexp.getExpressionLeftSide().getFieldName();
} else {
factType = constraint.getFactType();
fieldName = constraint.getFieldName();
}
oracle.getOperatorCompletions(factType, fieldName, operators -> {
final CEPOperatorsDropdown operatorsDropdown = getNewOperatorDropdown(operators, constraint);
operatorsDropdown.addPlaceholder(GuidedRuleEditorResources.CONSTANTS.pleaseChoose(), "");
placeholderForDropdown.add(operatorsDropdown);
operatorsDropdown.addValueChangeHandler(event -> onDropDownValueChanged(event));
});
}
use of org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide in project drools-wb by kiegroup.
the class PopupCreatorTest method testMakeSingleFieldConstraintEBLeftSide.
@Test
public void testMakeSingleFieldConstraintEBLeftSide() {
final String expectedFactType = "factType";
final ExpressionFormLine expectedExpressionFormLine = mock(ExpressionFormLine.class);
final int expectedConstraintValueType = SingleFieldConstraint.TYPE_UNDEFINED;
doReturn(expectedExpressionFormLine).when(popupCreator).makeExpressionFormLine(expectedFactType);
final SingleFieldConstraintEBLeftSide constraint = popupCreator.makeSingleFieldConstraintEBLeftSide(expectedFactType);
assertEquals(expectedConstraintValueType, constraint.getConstraintValueType());
assertEquals(expectedExpressionFormLine, constraint.getExpressionLeftSide());
assertEquals(expectedFactType, constraint.getFactType());
}
Aggregations