Search in sources :

Example 36 with ExpressionCellValue

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

the class RelationColumnTest method assertMinimumWidth.

private void assertMinimumWidth(final Optional<BaseExpressionGrid> peer, final double peerWidth, final double relationGridWidth, final double expectedMinimumWidth) {
    doReturn(peerWidth).when(peerExpressionEditor).getMinimumWidth();
    doReturn(relationGridWidth).when(gridWidget).getWidth();
    parentUiModel.setCellValue(1, 0, new ExpressionCellValue(peer));
    assertEquals(expectedMinimumWidth, column.getMinimumWidth(), 0.0);
}
Also used : ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 37 with ExpressionCellValue

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

the class FunctionGrid method doSetKind.

void doSetKind(final FunctionDefinition.Kind kind, final FunctionDefinition function, final Optional<Expression> expression, final Optional<BaseExpressionGrid> editor) {
    final GridCellValueTuple gcv = new GridCellValueTuple<>(0, 0, this, new ExpressionCellValue(editor));
    sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new SetKindCommand(gcv, function, kind, expression, () -> synchroniseViewWhenExpressionEditorChanged(this)));
}
Also used : SetKindCommand(org.kie.workbench.common.dmn.client.commands.expressions.types.function.SetKindCommand) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) GridCellValueTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellValueTuple)

Example 38 with ExpressionCellValue

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

the class ExpressionContainerGrid method getExistingEditor.

Optional<BaseExpressionGrid> getExistingEditor() {
    Optional<BaseExpressionGrid> beg = Optional.empty();
    final GridCell<?> cell = model.getRow(0).getCells().get(0);
    if (cell != null) {
        final GridCellValue<?> value = cell.getValue();
        if (value instanceof ExpressionCellValue) {
            final ExpressionCellValue ecv = (ExpressionCellValue) value;
            final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ecv.getValue();
            if (editor.isPresent()) {
                beg = Optional.of(editor.get());
            }
        }
    }
    return beg;
}
Also used : BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 39 with ExpressionCellValue

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

the class ExpressionContainerUIModelMapper method fromDMNModel.

@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
    final String uuid = nodeUUID.get();
    final GridData uiModel = this.uiModel.get();
    final Optional<Expression> expression = dmnModel.get();
    final Optional<HasName> hasName = this.hasName.get();
    final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get();
    final HasExpression hasExpression = this.hasExpression.get();
    final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitions.get().getExpressionEditorDefinition(expression);
    expressionEditorDefinition.ifPresent(definition -> {
        Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = expressionGridCache.get().getExpressionGrid(uuid);
        if (!editor.isPresent()) {
            final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> oEditor = definition.getEditor(parent, Optional.of(uuid), hasExpression, hasName, isOnlyVisualChangeAllowed, 0);
            expressionGridCache.get().putExpressionGrid(uuid, oEditor);
            editor = oEditor;
        }
        final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> _editor = editor;
        uiModel.setCell(0, 0, () -> new ContextGridCell<>(new ExpressionCellValue(_editor), listSelector));
    });
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) HasName(org.kie.workbench.common.dmn.api.definition.HasName) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) 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)

Example 40 with ExpressionCellValue

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

the class ExpressionContainerGridTest method testSetUndefinedExpression.

@Test
public void testSetUndefinedExpression() {
    grid.setExpression(NODE_UUID, hasExpression, Optional.of(hasName), false);
    final GridCellValue<?> gridCellValue = grid.getModel().getCell(0, 0).getValue();
    assertThat(gridCellValue).isInstanceOf(ExpressionCellValue.class);
    final ExpressionCellValue expressionCellValue = (ExpressionCellValue) gridCellValue;
    assertThat(expressionCellValue.getValue().isPresent()).isTrue();
    assertThat(expressionCellValue.getValue().get()).isSameAs(undefinedExpressionEditor);
    assertThat(grid.isOnlyVisualChangeAllowed()).isFalse();
    verify(undefinedExpressionEditor).selectFirstCell();
    verify(gridLayer).batch();
}
Also used : ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) Test(org.junit.Test)

Aggregations

ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)63 Test (org.junit.Test)28 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)22 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)21 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)17 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)14 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)12 ExpressionEditorColumn (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn)11 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)10 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)10 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)10 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)9 GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)9 Optional (java.util.Optional)8 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)8 BaseUIModelMapper (org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper)8 Before (org.junit.Before)6 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)6 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)6 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)6