Search in sources :

Example 36 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class BaseExpressionGridRenderingTest method setup.

@Before
@Override
public void setup() {
    super.setup();
    doReturn(false).when(context).isSelection();
    doReturn(new BaseBounds(0, 0, 1000, 1000)).when(gridLayer).getVisibleBounds();
    grid.getModel().appendColumn(new RowNumberColumn());
    grid.getModel().appendRow(new DMNGridRow());
    doReturn(renderSelectorCommand).when(renderer).renderSelector(anyDouble(), anyDouble(), any(BaseGridRendererHelper.RenderingInformation.class));
    doReturn(renderSelectedCellsCommand).when(renderer).renderSelectedCells(any(GridData.class), any(GridBodyRenderContext.class), any(BaseGridRendererHelper.class));
    final List<RendererCommand> renderHeaderCommands = new ArrayList<>();
    renderHeaderCommands.add(renderHeaderBackgroundCommand);
    renderHeaderCommands.add(renderHeaderGridLinesCommand);
    renderHeaderCommands.add(renderHeaderContentCommand);
    doReturn(renderHeaderCommands).when(renderer).renderHeader(any(GridData.class), any(GridHeaderRenderContext.class), any(BaseGridRendererHelper.class), any(BaseGridRendererHelper.RenderingInformation.class));
    final List<RendererCommand> renderBodyCommands = new ArrayList<>();
    renderBodyCommands.add(renderBodyGridBackgroundCommand);
    renderBodyCommands.add(renderBodyGridLinesCommand);
    renderBodyCommands.add(renderBodyGridContentCommand);
    doReturn(renderBodyCommands).when(renderer).renderBody(any(GridData.class), any(GridBodyRenderContext.class), any(BaseGridRendererHelper.class), any(BaseGridRendererHelper.RenderingInformation.class));
    doReturn(renderHeaderBodyDividerCommand).when(renderer).renderHeaderBodyDivider(anyDouble());
    doReturn(renderGridBoundaryCommand).when(renderer).renderGridBoundary(any(GridBoundaryRenderContext.class));
    doReturn(BaseExpressionGridRenderer.HEADER_HEIGHT).when(renderer).getHeaderHeight();
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) GridHeaderRenderContext(org.uberfire.ext.wires.core.grids.client.widget.context.GridHeaderRenderContext) RendererCommand(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer.RendererCommand) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) GridBodyRenderContext(org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyRenderContext) ArrayList(java.util.ArrayList) BaseBounds(org.uberfire.ext.wires.core.grids.client.model.impl.BaseBounds) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper) GridBoundaryRenderContext(org.uberfire.ext.wires.core.grids.client.widget.context.GridBoundaryRenderContext) Before(org.junit.Before)

Example 37 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class ContextGrid method initialiseUiModel.

@Override
public void initialiseUiModel() {
    expression.ifPresent(c -> {
        c.getContextEntry().stream().forEach(ce -> {
            model.appendRow(new DMNGridRow());
            uiModelMapper.fromDMNModel(model.getRowCount() - 1, 0);
            uiModelMapper.fromDMNModel(model.getRowCount() - 1, 1);
            uiModelMapper.fromDMNModel(model.getRowCount() - 1, 2);
        });
    });
}
Also used : DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)

Example 38 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class ContextGrid method addContextEntry.

void addContextEntry(final int index) {
    expression.ifPresent(c -> {
        final ContextEntry ce = new ContextEntry();
        ce.setVariable(new InformationItem());
        sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddContextEntryCommand(c, ce, model, new DMNGridRow(), index, uiModelMapper, this::synchroniseView));
    });
}
Also used : AddContextEntryCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.context.AddContextEntryCommand) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry)

Example 39 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class BaseContextUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendRow(new DMNGridRow());
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiNameColumn);
    this.uiModel.appendColumn(uiExpressionEditorColumn);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiNameColumn).getIndex();
    doReturn(2).when(uiExpressionEditorColumn).getIndex();
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(literalExpression)).when(literalExpressionEditor).getExpression();
    doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
    doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
    this.context = new Context();
    this.context.getContextEntry().add(new ContextEntry() {

        {
            setVariable(new InformationItem() {

                {
                    setName(new Name("ii1"));
                }
            });
        }
    });
    this.context.getContextEntry().add(new ContextEntry() {

        {
            setExpression(new LiteralExpression());
        }
    });
    this.mapper = getMapper();
    this.cellValueSupplier = Optional::empty;
}
Also used : Context(org.kie.workbench.common.dmn.api.definition.v1_1.Context) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Optional(java.util.Optional) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) ContextEntry(org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Example 40 with DMNGridRow

use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.

the class ExpressionEditorColumnTest method testMinimalWidthThreeCellsSumWithPadding.

/**
 * (10)[100](10)
 * (10)[50][60](10)
 * (10)[50][60][10](10)
 */
@Test
public void testMinimalWidthThreeCellsSumWithPadding() throws Exception {
    gridData.appendColumn(column);
    gridData.appendRow(new DMNGridRow());
    gridData.appendRow(new DMNGridRow());
    gridData.appendRow(new DMNGridRow());
    mockCellsWithPadding(0, 0, PADDING, 100);
    mockCellsWithPadding(1, 0, PADDING, 50, 60);
    mockCellsWithPadding(2, 0, PADDING, 50, 60, 10);
    Assertions.assertThat(column.getMinimumWidth()).isEqualTo(140);
}
Also used : DMNGridRow(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow) Test(org.junit.Test)

Aggregations

DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)67 Test (org.junit.Test)32 Before (org.junit.Before)16 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)13 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)12 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)12 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)12 List (org.kie.workbench.common.dmn.api.definition.v1_1.List)11 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)10 Optional (java.util.Optional)9 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)7 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)6 ContextEntry (org.kie.workbench.common.dmn.api.definition.v1_1.ContextEntry)6 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)6 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)6 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)6 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)6 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)5 Binding (org.kie.workbench.common.dmn.api.definition.v1_1.Binding)4 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)4