Search in sources :

Example 11 with BaseGridCellValue

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

the class GridRowComparatorTest method testIntegerColumn.

@Test
public void testIntegerColumn() {
    baseGridData.appendColumn(mock(IntegerUiColumn.class));
    final BaseGridRow a = new BaseGridRow();
    baseGridData.appendRow(a);
    final BaseGridRow b = new BaseGridRow();
    baseGridData.appendRow(b);
    final BaseGridRow c = new BaseGridRow();
    baseGridData.appendRow(c);
    final BaseGridRow d = new BaseGridRow();
    baseGridData.appendRow(d);
    baseGridData.setCell(0, 0, () -> new BaseGridCell<>(new BaseGridCellValue<>(100)));
    baseGridData.setCell(1, 0, () -> new BaseGridCell<>(new BaseGridCellValue<>(100)));
    baseGridData.setCell(2, 0, () -> new BaseGridCell<>(new BaseGridCellValue<>(0)));
    baseGridData.setCell(3, 0, () -> new BaseGridCell<>(null));
    assertTrue(comparator.compare(a, b) == 0);
    assertTrue(comparator.compare(a, c) > 0);
    assertTrue(comparator.compare(c, a) < 0);
    assertTrue(comparator.compare(c, d) > 0);
    assertTrue(comparator.compare(d, c) < 0);
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) Test(org.junit.Test)

Example 12 with BaseGridCellValue

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

the class LiteralExpressionGridTest method setup.

@Before
public void setup() {
    tupleWithoutValue = new GridCellTuple(0, 0, gridWidget);
    tupleWithValue = new GridCellValueTuple<>(0, 0, gridWidget, new BaseGridCellValue<>("value"));
    definition = new LiteralExpressionEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService);
    final Decision decision = new Decision();
    decision.setName(new Name("name"));
    hasName = Optional.of(decision);
    expression = definition.getModelClass();
    expression.ifPresent(e -> e.setText(EXPRESSION_TEXT));
    doReturn(session).when(sessionManager).getCurrentSession();
    doReturn(canvasHandler).when(session).getCanvasHandler();
    doReturn(mock(Bounds.class)).when(gridLayer).getVisibleBounds();
    when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
    when(canvasHandler.getGraphIndex()).thenReturn(index);
    when(index.get(anyString())).thenReturn(element);
    when(element.getContent()).thenReturn(mock(Definition.class));
    when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
    when(canvasCommandFactory.updatePropertyValue(any(Element.class), anyString(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
    when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
    when(parent.getGridWidget()).thenReturn(parentGridWidget);
    when(parent.getRowIndex()).thenReturn(0);
    when(parent.getColumnIndex()).thenReturn(1);
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Bounds(org.uberfire.ext.wires.core.grids.client.model.Bounds) Element(org.kie.workbench.common.stunner.core.graph.Element) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Decision(org.kie.workbench.common.dmn.api.definition.v1_1.Decision) UpdateElementPropertyCommand(org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue) HasName(org.kie.workbench.common.dmn.api.definition.HasName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Before(org.junit.Before)

Example 13 with BaseGridCellValue

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

the class LiteralExpressionUIModelMapper method fromDMNModel.

@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
    dmnModel.get().ifPresent(literalExpression -> {
        uiModel.get().setCell(rowIndex, columnIndex, () -> new LiteralExpressionCell<>(new BaseGridCellValue<>(literalExpression.getText()), listSelector));
        uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy((final GridData model, final int uiRowIndex, final int uiColumnIndex, final boolean isShiftKeyDown, final boolean isControlKeyDown) -> {
            final GridData parentUiModel = parent.getGridWidget().getModel();
            return parentUiModel.getCell(parent.getRowIndex(), parent.getColumnIndex()).getSelectionStrategy().handleSelection(parentUiModel, parent.getRowIndex(), parent.getColumnIndex(), isShiftKeyDown, isControlKeyDown);
        });
    });
}
Also used : GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)

Example 14 with BaseGridCellValue

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

the class ContextUIModelMapper method fromDMNModel.

@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
    dmnModel.get().ifPresent(context -> {
        final boolean isLastRow = isLastRow(rowIndex);
        final ContextUIModelMapperHelper.ContextSection section = ContextUIModelMapperHelper.getSection(columnIndex);
        switch(section) {
            case ROW_INDEX:
                if (!isLastRow) {
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
                } else {
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new DMNGridCell<>(new BaseGridCellValue<>((Integer) null)));
                }
                uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
                break;
            case NAME:
                final InformationItem variable = context.getContextEntry().get(rowIndex).getVariable();
                uiModel.get().setCell(rowIndex, columnIndex, () -> new InformationItemCell(() -> InformationItemCell.HasNameAndDataTypeCell.wrap(variable, DEFAULT_ROW_CAPTION), listSelector));
                break;
            case EXPRESSION:
                final ContextEntry ce = context.getContextEntry().get(rowIndex);
                final Optional<Expression> expression = Optional.ofNullable(ce.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(), ce, Optional.ofNullable(ce.getVariable()), isOnlyVisualChangeAllowed, nesting + 1);
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new ExpressionCellValue(editor), listSelector));
                });
        }
    });
}
Also used : ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) ContextEntry(org.kie.workbench.common.dmn.api.definition.model.ContextEntry) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) 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) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)

Example 15 with BaseGridCellValue

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

the class BaseExpressionGridGeneralTest method setup.

@Override
public void setup() {
    super.setup();
    tupleWithoutValue = new GridCellTuple(0, 0, grid);
    tupleWithValue = new GridCellValueTuple<>(0, 0, grid, new BaseGridCellValue<>("value"));
    when(sessionManager.getCurrentSession()).thenReturn(session);
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getGraph()).thenReturn(graph);
    when(graph.nodes()).thenReturn(Collections.singletonList(node));
    when(canvasHandler.getGraphIndex()).thenReturn(index);
    when(element.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(DEFINITION);
    when(definitionUtils.getNameIdentifier(DEFINITION)).thenReturn(NAME_ID);
    when(updateElementPropertyCommand.execute(canvasHandler)).thenReturn(CanvasCommandResultBuilder.SUCCESS);
    when(grid.getHeader()).thenReturn(header);
    when(header.getY()).thenReturn(0.0);
    when(renderer.getHeaderHeight()).thenReturn(HEADER_HEIGHT);
    when(renderer.getHeaderRowHeight()).thenReturn(HEADER_HEIGHT);
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) 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