Search in sources :

Example 1 with InformationItemCell

use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.InformationItemCell in project kie-wb-common by kiegroup.

the class InvocationUIModelMapper method fromDMNModel.

@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
    dmnModel.get().ifPresent(invocation -> {
        switch(columnIndex) {
            case ROW_NUMBER_COLUMN_INDEX:
                uiModel.get().setCell(rowIndex, columnIndex, () -> new InvocationGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
                uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
                break;
            case BINDING_PARAMETER_COLUMN_INDEX:
                final InformationItem variable = invocation.getBinding().get(rowIndex).getParameter();
                uiModel.get().setCell(rowIndex, columnIndex, () -> new InformationItemCell(() -> InformationItemCell.HasNameAndDataTypeCell.wrap(variable), listSelector));
                break;
            case BINDING_EXPRESSION_COLUMN_INDEX:
                final Binding binding = invocation.getBinding().get(rowIndex);
                final Optional<Expression> expression = Optional.ofNullable(binding.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(), binding, Optional.ofNullable(binding.getParameter()), isOnlyVisualChangeAllowed, nesting + 1);
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new InvocationGridCell<>(new ExpressionCellValue(editor), listSelector));
                });
        }
    });
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) InformationItemCell(org.kie.workbench.common.dmn.client.editors.expressions.types.context.InformationItemCell) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)

Example 2 with InformationItemCell

use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.InformationItemCell in project kie-wb-common by kiegroup.

the class RendererUtilsTest method testRenderHeaderContentWithInformationItemCell.

@Test
public void testRenderHeaderContentWithInformationItemCell() {
    final InformationItemCell.HasNameAndDataTypeCell informationItemCell = mock(InformationItemCell.HasNameAndDataTypeCell.class);
    final Name name = new Name(TITLE);
    when(informationItemCell.getName()).thenReturn(name);
    when(informationItemCell.getTypeRef()).thenReturn(TYPE_REF);
    when(informationItemCell.hasData()).thenReturn(true);
    RendererUtils.getNameAndDataTypeCellText(informationItemCell, bodyContext);
    assertHasNameAndDataTypeRendering();
}
Also used : InformationItemCell(org.kie.workbench.common.dmn.client.editors.expressions.types.context.InformationItemCell) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Test(org.junit.Test)

Aggregations

InformationItemCell (org.kie.workbench.common.dmn.client.editors.expressions.types.context.InformationItemCell)2 Test (org.junit.Test)1 Binding (org.kie.workbench.common.dmn.api.definition.model.Binding)1 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)1 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)1 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)1 QName (org.kie.workbench.common.dmn.api.property.dmn.QName)1 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)1 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)1 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)1 BaseUIModelMapper (org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper)1 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)1 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)1 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)1