Search in sources :

Example 6 with HasExpression

use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.

the class BaseExpressionGridRenderingTest method getGrid.

@Override
@SuppressWarnings("unchecked")
public BaseExpressionGrid getGrid() {
    final GridCellTuple parent = new GridCellTuple(0, 0, null);
    final HasExpression hasExpression = mock(HasExpression.class);
    final Optional<LiteralExpression> expression = Optional.of(mock(LiteralExpression.class));
    final Optional<HasName> hasName = Optional.of(mock(HasName.class));
    return new BaseExpressionGrid(parent, Optional.empty(), hasExpression, expression, hasName, gridPanel, gridLayer, new GridDataCache.CacheResult(new DMNGridData(), false), renderer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, 0) {

        @Override
        protected BaseUIModelMapper makeUiModelMapper() {
            return mapper;
        }

        @Override
        protected void initialiseUiColumns() {
        // Nothing for this test
        }

        @Override
        protected void initialiseUiModel() {
        // Nothing for this test
        }

        @Override
        protected boolean isHeaderHidden() {
            return isHeaderHidden;
        }
    };
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) HasName(org.kie.workbench.common.dmn.api.definition.HasName) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)

Example 7 with HasExpression

use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.

the class ExpressionContainerUIModelMapper method fromDMNModel.

@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
    final GridData uiModel = this.uiModel.get();
    final Optional<Expression> expression = dmnModel.get();
    final Optional<HasName> hasName = this.hasName.get();
    final HasExpression hasExpression = this.hasExpression.get();
    final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitions.get().getExpressionEditorDefinition(expression);
    expressionEditorDefinition.ifPresent(definition -> {
        final Optional<BaseExpressionGrid> oEditor = definition.getEditor(parent, Optional.of(nodeUUID.get()), hasExpression, expression, hasName, 0);
        uiModel.setCell(0, 0, () -> new ContextGridCell<>(new ExpressionCellValue(oEditor), listSelector));
        final GridColumn<?> uiColumn = uiModel.getColumns().get(columnIndex);
        uiColumn.setWidth(uiColumn.getMinimumWidth());
    });
}
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.v1_1.Expression) 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)

Example 8 with HasExpression

use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.

the class ContextGrid method clearExpressionType.

void clearExpressionType(final int uiRowIndex) {
    final GridCellTuple gc = new GridCellTuple(uiRowIndex, ContextUIModelMapperHelper.EXPRESSION_COLUMN_INDEX, this);
    final HasExpression hasExpression = expression.get().getContextEntry().get(uiRowIndex);
    sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new ClearExpressionTypeCommand(gc, hasExpression, uiModelMapper, () -> synchroniseViewWhenExpressionEditorChanged(this)));
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) ClearExpressionTypeCommand(org.kie.workbench.common.dmn.client.commands.general.ClearExpressionTypeCommand)

Example 9 with HasExpression

use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.

the class ExpressionEditorColumnTest method mockEditor.

@SuppressWarnings("unchecked")
private BaseExpressionGrid mockEditor(final double padding, final double... widthOfCells) {
    final GridColumn.HeaderMetaData headerMetaData = mock(GridColumn.HeaderMetaData.class);
    final GridColumnRenderer gridColumnRenderer = mock(GridColumnRenderer.class);
    final BaseExpressionGrid gridWidget = mock(BaseExpressionGrid.class);
    final GridCellTuple parent = new GridCellTuple(0, 0, null);
    final HasExpression hasExpression = mock(HasExpression.class);
    final Optional<LiteralExpression> expression = Optional.of(mock(LiteralExpression.class));
    final Optional<HasName> hasName = Optional.of(mock(HasName.class));
    return new BaseExpressionGrid(parent, Optional.empty(), hasExpression, expression, hasName, gridPanel, gridLayer, new GridDataCache.CacheResult(new DMNGridData(), false), renderer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService, 0) {

        @Override
        protected BaseUIModelMapper makeUiModelMapper() {
            return null;
        }

        @Override
        protected void initialiseUiColumns() {
            for (double width : widthOfCells) {
                model.appendColumn(new DMNGridColumn<GridWidget, Object>(headerMetaData, gridColumnRenderer, gridWidget) {

                    {
                        setMinimumWidth(width);
                        setWidth(width);
                    }
                });
            }
        }

        @Override
        protected void initialiseUiModel() {
        // Nothing for this test
        }

        @Override
        protected boolean isHeaderHidden() {
            return false;
        }

        @Override
        public double getPadding() {
            return padding;
        }
    };
}
Also used : GridColumnRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.columns.GridColumnRenderer) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) BaseGridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.impl.BaseGridWidget) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) HasName(org.kie.workbench.common.dmn.api.definition.HasName) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) GridDataCache(org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) DMNGridColumn(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridColumn)

Example 10 with HasExpression

use of org.kie.workbench.common.dmn.api.definition.HasExpression in project kie-wb-common by kiegroup.

the class InvocationGrid method clearExpressionType.

void clearExpressionType(final int uiRowIndex) {
    final GridCellTuple gc = new GridCellTuple(uiRowIndex, InvocationUIModelMapper.BINDING_EXPRESSION_COLUMN_INDEX, this);
    final HasExpression hasExpression = expression.get().getBinding().get(uiRowIndex);
    sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new ClearExpressionTypeCommand(gc, hasExpression, uiModelMapper, () -> synchroniseViewWhenExpressionEditorChanged(this)));
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) ClearExpressionTypeCommand(org.kie.workbench.common.dmn.client.commands.general.ClearExpressionTypeCommand)

Aggregations

HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)10 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)7 HasName (org.kie.workbench.common.dmn.api.definition.HasName)6 LiteralExpression (org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression)4 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)4 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)4 GridDataCache (org.kie.workbench.common.dmn.client.widgets.grid.model.GridDataCache)4 Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)3 Optional (java.util.Optional)2 ClearExpressionTypeCommand (org.kie.workbench.common.dmn.client.commands.general.ClearExpressionTypeCommand)2 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)2 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)2 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)2 DMNGridRow (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow)2 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)2 NodeMouseClickHandler (com.ait.lienzo.client.core.event.NodeMouseClickHandler)1 EventPropagationMode (com.ait.lienzo.shared.core.types.EventPropagationMode)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Supplier (java.util.function.Supplier)1