Search in sources :

Example 16 with BaseGridCellValue

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project kie-wb-common by kiegroup.

the class EditableNameAndDataTypeColumnTest method setup.

@Before
public void setup() {
    when(gridWidget.getExpression()).thenReturn(Optional::empty);
    this.cell = new BaseGridCell<>(new BaseGridCellValue<>(HasNameAndDataTypeCell.wrap(informationItem)));
    this.column = spy(new EditableNameAndDataTypeColumn<ContextGrid>(headerMetaData, DMNGridColumn.DEFAULT_WIDTH, gridWidget, isEditable, clearValueConsumer, setValueConsumer, setTypeRefConsumer, translationService, cellEditorControls, editor) {

        @Override
        protected String getPopoverTitle() {
            return POPOVER_TITLE;
        }
    });
    when(context.getRelativeLocation()).thenReturn(Optional.of(new Point2D(RELATIVE_X, RELATIVE_Y)));
    when(context.getRowIndex()).thenReturn(UI_ROW_INDEX);
    when(context.getColumnIndex()).thenReturn(UI_COLUMN_INDEX);
    when(context.getAbsoluteCellX()).thenReturn(ABSOLUTE_CELL_X);
    when(context.getAbsoluteCellY()).thenReturn(ABSOLUTE_CELL_Y);
    when(gridWidget.getParentInformation()).thenReturn(new GridCellTuple(0, 0, gridWidget));
    when(translationService.getTranslation(Mockito.<String>any())).thenAnswer(i -> i.getArguments()[0]);
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Optional(java.util.Optional) Point2D(com.ait.lienzo.client.core.types.Point2D) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) Before(org.junit.Before)

Example 17 with BaseGridCellValue

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project kie-wb-common by kiegroup.

the class LiteralExpressionGridRowTest method testGetHeightWithHasDynamicHeightCell.

@Test
public void testGetHeightWithHasDynamicHeightCell() {
    final GridRow row = spy(new LiteralExpressionGridRow());
    final Map<Integer, GridCell> cells = new HashMap<Integer, GridCell>() {

        {
            put(0, new MockHasDynamicHeightCell<>(new BaseGridCellValue<>("cheese")));
            put(1, new BaseGridCell<>(new BaseGridCellValue<>("cheese")));
        }
    };
    doReturn(cells).when(row).getCells();
    assertThat(row.getHeight()).isEqualTo(CELL_HEIGHT);
}
Also used : HashMap(java.util.HashMap) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) BaseGridCell(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) Test(org.junit.Test)

Example 18 with BaseGridCellValue

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project kie-wb-common by kiegroup.

the class LiteralExpressionGridRowTest method testGetHeightWithoutHasDynamicHeightCell.

@Test
public void testGetHeightWithoutHasDynamicHeightCell() {
    final GridRow row = spy(new LiteralExpressionGridRow());
    final Map<Integer, GridCell> cells = new HashMap<Integer, GridCell>() {

        {
            put(0, new BaseGridCell<>(new BaseGridCellValue<>("cheese")));
        }
    };
    doReturn(cells).when(row).getCells();
    assertThat(row.getHeight()).isEqualTo(DEFAULT_HEIGHT);
}
Also used : HashMap(java.util.HashMap) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) BaseGridCell(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) Test(org.junit.Test)

Example 19 with BaseGridCellValue

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue 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));
                });
        }
    });
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) 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 20 with BaseGridCellValue

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project kie-wb-common by kiegroup.

the class InvocationUIModelMapper method toDMNModel.

@Override
@SuppressWarnings("unchecked")
public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) {
    dmnModel.get().ifPresent(invocation -> {
        switch(columnIndex) {
            case ROW_NUMBER_COLUMN_INDEX:
                break;
            case BINDING_PARAMETER_COLUMN_INDEX:
                invocation.getBinding().get(rowIndex).getParameter().getName().setValue(cell.get().orElse(new BaseGridCellValue<>("")).getValue().toString());
                break;
            case BINDING_EXPRESSION_COLUMN_INDEX:
                cell.get().ifPresent(v -> {
                    final ExpressionCellValue ecv = (ExpressionCellValue) v;
                    ecv.getValue().ifPresent(beg -> {
                        beg.getExpression().get().ifPresent(e -> invocation.getBinding().get(rowIndex).setExpression((Expression) e));
                    });
                });
        }
    });
}
Also used : Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)

Aggregations

BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)23 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)11 Before (org.junit.Before)7 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)7 Test (org.junit.Test)6 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)5 HasName (org.kie.workbench.common.dmn.api.definition.HasName)5 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)5 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)5 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)5 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)5 Optional (java.util.Optional)4 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)4 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)4 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)4 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)4 UpdateElementPropertyCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand)4 Element (org.kie.workbench.common.stunner.core.graph.Element)4 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)4 Iterator (java.util.Iterator)3