use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class BindingPropertyConverter method wbFromDMN.
public static Binding wbFromDMN(final JSITBinding dmn, final BiConsumer<String, HasComponentWidths> hasComponentWidthsConsumer) {
if (Objects.isNull(dmn)) {
return null;
}
final InformationItem parameter = InformationItemPropertyConverter.wbFromDMN(dmn.getParameter());
Expression expression = null;
final JSITExpression jsiWrapped = dmn.getExpression();
if (Objects.nonNull(jsiWrapped)) {
final JSITExpression jsiExpression = Js.uncheckedCast(JsUtils.getUnwrappedElement(jsiWrapped));
expression = ExpressionPropertyConverter.wbFromDMN(jsiExpression, Js.uncheckedCast(dmn), hasComponentWidthsConsumer);
}
final Binding result = new Binding();
if (Objects.nonNull(parameter)) {
parameter.setParent(result);
}
result.setParameter(parameter);
if (Objects.nonNull(expression)) {
expression.setParent(result);
}
result.setExpression(expression);
return result;
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class BaseGrid method getAndSetInitialWidth.
protected double getAndSetInitialWidth(final int uiColumnIndex, final double initialWidth) {
if (getExpression().get().isPresent()) {
final Expression e = getExpression().get().get();
final List<Double> componentWidths = e.getComponentWidths();
if (Objects.isNull(componentWidths.get(uiColumnIndex))) {
componentWidths.set(uiColumnIndex, initialWidth);
}
return componentWidths.get(uiColumnIndex);
}
throw new IllegalStateException("Unable to initialise column width if Expression has not been set.");
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class ExpressionEditorViewImplTest method testSetExpressionDoesUpdateExpressionTypeTextWhenHasExpressionIsNotEmpty.
@Test
public void testSetExpressionDoesUpdateExpressionTypeTextWhenHasExpressionIsNotEmpty() {
final Expression expression = new LiteralExpression();
final Optional<HasName> hasName = Optional.empty();
when(hasExpression.getExpression()).thenReturn(expression);
view.setExpression(NODE_UUID, hasExpression, hasName, false);
verify(expressionType).setTextContent(eq(LITERAL_EXPRESSION_DEFINITION_NAME));
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class ObserverBuilderControlTest method testUpdateExpressionFromDefinition.
@Test
public void testUpdateExpressionFromDefinition() {
final Element element = mock(Element.class);
final View elementContent = mock(View.class);
final HasExpression newHasExpression = mock(HasExpression.class);
final HasExpression hasExpression = mock(HasExpression.class);
final Expression expression = mock(Expression.class);
when(element.getContent()).thenReturn(elementContent);
when(elementContent.getDefinition()).thenReturn(newHasExpression);
when(hasExpression.getExpression()).thenReturn(expression);
observerBuilderControl.updateElementFromDefinition(element, hasExpression);
verify(newHasExpression).setExpression(expression);
}
use of org.kie.workbench.common.dmn.api.definition.model.Expression in project kie-wb-common by kiegroup.
the class RelationEditorDefinitionTest method testEditor.
@Test
public void testEditor() {
when(hasExpression.getExpression()).thenReturn(definition.getModelClass().get());
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.empty(), hasExpression, hasName, false, 0);
assertThat(oEditor).isPresent();
final GridWidget editor = oEditor.get();
assertThat(editor).isInstanceOf(RelationGrid.class);
}
Aggregations