Search in sources :

Example 1 with GridCellTuple

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

the class RelationColumn method getMinimumWidthOfPeers.

private double getMinimumWidthOfPeers() {
    final GridCellTuple parent = gridWidget.getParentInformation();
    final GridData parentUiModel = parent.getGridWidget().getModel();
    final int parentUiRowIndex = parent.getRowIndex();
    final int parentUiColumnIndex = parent.getColumnIndex();
    double minimumWidth = super.getMinimumWidth();
    for (int uiRowIndex = 0; uiRowIndex < parentUiModel.getRowCount(); uiRowIndex++) {
        if (uiRowIndex != parentUiRowIndex) {
            final GridRow row = parentUiModel.getRow(uiRowIndex);
            final GridCell<?> cell = row.getCells().get(parentUiColumnIndex);
            if (cell != null) {
                final GridCellValue<?> value = cell.getValue();
                if (value instanceof ExpressionCellValue) {
                    final ExpressionCellValue ecv = (ExpressionCellValue) value;
                    final Optional<BaseExpressionGrid> editor = ecv.getValue();
                    final double padding = editor.map(BaseExpressionGrid::getPadding).get();
                    minimumWidth = Math.max(minimumWidth, ecv.getMinimumWidth().orElse(0.0) + padding * 2);
                }
            }
        }
    }
    return minimumWidth;
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Example 2 with GridCellTuple

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

the class BaseContextUIModelMapperTest method testFromDMNModelUndefinedExpression.

@Test
public void testFromDMNModelUndefinedExpression() {
    mapper.fromDMNModel(0, 2);
    assertTrue(uiModel.getCell(0, 2).getValue() instanceof ExpressionCellValue);
    final ExpressionCellValue dcv0 = (ExpressionCellValue) uiModel.getCell(0, 2).getValue();
    assertEquals(undefinedExpressionEditor, dcv0.getValue().get());
    verify(undefinedExpressionEditorDefinition).getEditor(parentCaptor.capture(), eq(Optional.empty()), eq(context.getContextEntry().get(0)), eq(Optional.empty()), eq(Optional.of(context.getContextEntry().get(0).getVariable())), eq(1));
    final GridCellTuple parent = parentCaptor.getValue();
    assertEquals(0, parent.getRowIndex());
    assertEquals(2, parent.getColumnIndex());
    assertEquals(gridWidget, parent.getGridWidget());
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Test(org.junit.Test)

Example 3 with GridCellTuple

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

the class BaseContextUIModelMapperTest method testFromDMNModelLiteralExpression.

@Test
@SuppressWarnings("unchecked")
public void testFromDMNModelLiteralExpression() {
    mapper.fromDMNModel(1, 2);
    assertTrue(uiModel.getCell(1, 2).getValue() instanceof ExpressionCellValue);
    final ExpressionCellValue dcv1 = (ExpressionCellValue) uiModel.getCell(1, 2).getValue();
    assertEquals(literalExpressionEditor, dcv1.getValue().get());
    verify(literalExpressionEditorDefinition).getEditor(parentCaptor.capture(), eq(Optional.empty()), eq(context.getContextEntry().get(1)), eq(Optional.of(context.getContextEntry().get(1).getExpression())), eq(Optional.empty()), eq(1));
    final GridCellTuple parent = parentCaptor.getValue();
    assertEquals(1, parent.getRowIndex());
    assertEquals(2, parent.getColumnIndex());
    assertEquals(gridWidget, parent.getGridWidget());
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Test(org.junit.Test)

Example 4 with GridCellTuple

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

the class DecisionTableGridTest method testHeaderTextBoxFactoryWhenNotNested.

@Test
public void testHeaderTextBoxFactoryWhenNotNested() {
    setupGrid(makeHasNameForDecision(), 0);
    final GridCellTuple tupleWithoutValue = new GridCellTuple(0, 2, gridWidget);
    final GridCellValueTuple tupleWithValue = new GridCellValueTuple<>(0, 2, gridWidget, new BaseGridCellValue<>("value"));
    final TextBoxSingletonDOMElementFactory factory = grid.getHeaderTextBoxFactory();
    assertThat(factory.getHasNoValueCommand().apply(tupleWithoutValue)).isInstanceOf(DeleteHeaderValueCommand.class);
    assertThat(factory.getHasValueCommand().apply(tupleWithValue)).isInstanceOf(SetHeaderValueCommand.class);
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) TextBoxSingletonDOMElementFactory(org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextBoxSingletonDOMElementFactory) GridCellValueTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple) Test(org.junit.Test)

Example 5 with GridCellTuple

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

the class DecisionTableGridTest method testHeaderHasNameTextBoxFactoryWhenNotNested.

@Test
public void testHeaderHasNameTextBoxFactoryWhenNotNested() {
    setupGrid(makeHasNameForDecision(), 0);
    final GridCellTuple tupleWithoutValue = new GridCellTuple(0, 2, gridWidget);
    final GridCellValueTuple tupleWithValue = new GridCellValueTuple<>(0, 2, gridWidget, new BaseGridCellValue<>("value"));
    final TextBoxSingletonDOMElementFactory factory = grid.getHeaderHasNameTextBoxFactory();
    assertCommands(factory.getHasNoValueCommand().apply(tupleWithoutValue), DeleteHeaderValueCommand.class, UpdateElementPropertyCommand.class);
    assertCommands(factory.getHasValueCommand().apply(tupleWithValue), SetHeaderValueCommand.class, UpdateElementPropertyCommand.class);
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) TextBoxSingletonDOMElementFactory(org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextBoxSingletonDOMElementFactory) GridCellValueTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple) Test(org.junit.Test)

Aggregations

GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)57 Test (org.junit.Test)22 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)13 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)13 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)13 Before (org.junit.Before)12 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)11 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)11 GridCellValueTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple)11 Optional (java.util.Optional)10 HasName (org.kie.workbench.common.dmn.api.definition.HasName)9 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)9 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)8 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)8 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)7 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)6 TextBoxSingletonDOMElementFactory (org.kie.workbench.common.dmn.client.widgets.grid.columns.factory.TextBoxSingletonDOMElementFactory)6 BaseUIModelMapper (org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper)6 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)5 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)5