use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class InvocationGrid method clearExpressionType.
void clearExpressionType(final int uiRowIndex) {
final GridCellTuple gc = new GridCellTuple(uiRowIndex, InvocationUIModelMapper.BINDING_EXPRESSION_COLUMN_INDEX, this);
getExpression().get().ifPresent(invocation -> {
final HasExpression hasExpression = invocation.getBinding().get(uiRowIndex);
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new ClearExpressionTypeCommand(gc, hasExpression, uiModelMapper, () -> {
resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
selectExpressionEditorFirstCell(uiRowIndex, InvocationUIModelMapper.BINDING_EXPRESSION_COLUMN_INDEX);
}, () -> {
resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
selectExpressionEditorFirstCell(uiRowIndex, InvocationUIModelMapper.BINDING_EXPRESSION_COLUMN_INDEX);
}));
});
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class ListGrid method doAfterSelectionChange.
@Override
public void doAfterSelectionChange(final int uiRowIndex, final int uiColumnIndex) {
if (hasAnyHeaderCellSelected() || hasMultipleCellsSelected()) {
super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
return;
}
if (getExpression().get().isPresent()) {
final List list = getExpression().get().get();
final ListUIModelMapperHelper.ListSection section = ListUIModelMapperHelper.getSection(uiColumnIndex);
if (section == ListUIModelMapperHelper.ListSection.EXPRESSION) {
final HasExpression hasExpression = list.getExpression().get(uiRowIndex);
final Expression expression = hasExpression.getExpression();
if (expression instanceof DomainObject) {
final DomainObject domainObject = (DomainObject) expression;
fireDomainObjectSelectionEvent(domainObject);
return;
}
}
}
super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class ListGrid method clearExpressionType.
void clearExpressionType(final int uiRowIndex) {
final GridCellTuple gc = new GridCellTuple(uiRowIndex, ListUIModelMapperHelper.EXPRESSION_COLUMN_INDEX, this);
getExpression().get().ifPresent(list -> {
final HasExpression hasExpression = list.getExpression().get(uiRowIndex);
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new ClearExpressionTypeCommand(gc, hasExpression, uiModelMapper, () -> {
resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
selectExpressionEditorFirstCell(uiRowIndex, ListUIModelMapperHelper.EXPRESSION_COLUMN_INDEX);
}, () -> {
resize(BaseExpressionGrid.RESIZE_EXISTING_MINIMUM);
selectExpressionEditorFirstCell(uiRowIndex, ListUIModelMapperHelper.EXPRESSION_COLUMN_INDEX);
}));
});
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class ListUIModelMapper method fromDMNModel.
@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
dmnModel.get().ifPresent(list -> {
final ListUIModelMapperHelper.ListSection section = ListUIModelMapperHelper.getSection(columnIndex);
switch(section) {
case ROW_INDEX:
uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
break;
case EXPRESSION:
final HasExpression hasExpression = list.getExpression().get(rowIndex);
final Optional<Expression> expression = Optional.ofNullable(hasExpression.getExpression());
final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get();
final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
expressionEditorDefinition.ifPresent(ed -> {
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ed.getEditor(new GridCellTuple(rowIndex, columnIndex, gridWidget), Optional.empty(), hasExpression, Optional.empty(), isOnlyVisualChangeAllowed, nesting + 1);
uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new ExpressionCellValue(editor), listSelector));
});
}
});
}
use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.
the class ListPropertyConverterTest method testDMNFromWB.
@Test
public void testDMNFromWB() {
final List wb = new List();
final LiteralExpression literalExpression = new LiteralExpression();
final HasExpression hasExpression = HasExpression.wrap(wb, literalExpression);
literalExpression.getComponentWidths().set(0, 200.0);
literalExpression.getId().setValue(EXPRESSION_UUID);
wb.getId().setValue(LIST_UUID);
wb.getDescription().setValue(LIST_DESCRIPTION);
wb.setTypeRef(new org.kie.workbench.common.dmn.api.property.dmn.QName(org.kie.workbench.common.dmn.api.property.dmn.QName.NULL_NS_URI, LIST_QNAME_LOCALPART));
wb.getExpression().add(hasExpression);
final org.kie.dmn.model.api.List dmn = ListPropertyConverter.dmnFromWB(wb, componentWidthsConsumer);
assertThat(dmn).isNotNull();
assertThat(dmn.getId()).isNotNull();
assertThat(dmn.getId()).isEqualTo(LIST_UUID);
assertThat(dmn.getDescription()).isNotNull();
assertThat(dmn.getDescription()).isEqualTo(LIST_DESCRIPTION);
assertThat(dmn.getTypeRef()).isNotNull();
assertThat(dmn.getTypeRef().getLocalPart()).isEqualTo(LIST_QNAME_LOCALPART);
assertThat(dmn.getExpression()).isNotNull();
assertThat(dmn.getExpression().size()).isEqualTo(1);
assertThat(dmn.getExpression().get(0).getId()).isEqualTo(EXPRESSION_UUID);
verify(componentWidthsConsumer).accept(componentWidthsCaptor.capture());
final ComponentWidths componentWidths = componentWidthsCaptor.getValue();
assertThat(componentWidths).isNotNull();
assertThat(componentWidths.getDmnElementRef().getLocalPart()).isEqualTo(EXPRESSION_UUID);
assertThat(componentWidths.getWidths().size()).isEqualTo(literalExpression.getRequiredComponentWidthCount());
assertThat(componentWidths.getWidths().get(0)).isEqualTo(200.0);
}
Aggregations