Search in sources :

Example 41 with BaseGridData

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

the class ExpressionContainerGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.expressionGridCache = new ExpressionGridCacheImpl();
    this.gridLayer = spy(new DMNGridLayer());
    this.grid = new ExpressionContainerGrid(gridLayer, cellEditorControls, translationService, listSelector, sessionManager, sessionCommandManager, canvasCommandFactory, expressionEditorDefinitionsSupplier, () -> expressionGridCache, onHasExpressionChanged, onHasNameChanged, refreshFormPropertiesEvent, domainObjectSelectionEvent) {

        @Override
        public CellSelectionManager getCellSelectionManager() {
            return cellSelectionManager;
        }
    };
    this.gridLayer.add(grid);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
    when(literalExpressionEditor.isCacheable()).thenReturn(true);
    when(literalExpressionEditor.getParentInformation()).thenReturn(parent);
    when(literalExpressionEditor.getModel()).thenReturn(new BaseGridData());
    when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
    when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
    when(undefinedExpressionEditor.getParentInformation()).thenReturn(parent);
    when(undefinedExpressionEditor.getModel()).thenReturn(new BaseGridData());
    when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
    when(undefinedExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(undefinedExpressionEditor));
    when(sessionManager.getCurrentSession()).thenReturn(session);
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(canvasHandler.getGraphExecutionContext()).thenReturn(graphExecutionContext);
    doReturn(mock(Bounds.class)).when(gridLayer).getVisibleBounds();
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getGraph()).thenReturn(graph);
    when(graph.nodes()).thenReturn(Collections.singletonList(node));
    when(parent.getGridWidget()).thenReturn(grid);
    when(parent.getRowIndex()).thenReturn(0);
    when(parent.getColumnIndex()).thenReturn(0);
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(Mockito.<String>any());
}
Also used : 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) Optional(java.util.Optional) Bounds(org.uberfire.ext.wires.core.grids.client.model.Bounds) ExpressionGridCacheImpl(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCacheImpl) CellSelectionManager(org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionManager) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) Before(org.junit.Before)

Example 42 with BaseGridData

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

the class ExpressionEditorViewImplTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.expressionGridCache = new ExpressionGridCacheImpl();
    this.gridPanelContainer = spy(new DMNGridPanelContainer());
    when(sessionManager.getCurrentSession()).thenReturn(session);
    when(session.getExpressionGridCache()).thenReturn(expressionGridCache);
    when(session.getGridPanel()).thenReturn(gridPanel);
    when(session.getGridLayer()).thenReturn(gridLayer);
    when(session.getCellEditorControls()).thenReturn(cellEditorControls);
    when(session.getMousePanMediator()).thenReturn(mousePanMediator);
    doReturn(viewport).when(gridPanel).getViewport();
    doReturn(viewportMediators).when(viewport).getMediators();
    doReturn(gridPanelElement).when(gridPanel).getElement();
    doReturn(Optional.of(editor)).when(editorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt());
    doReturn(new BaseGridData()).when(editor).getModel();
    this.view = spy(new ExpressionEditorViewImpl(returnToLink, expressionName, expressionType, gridPanelContainer, translationService, listSelector, sessionManager, sessionCommandManager, canvasCommandFactory, expressionEditorDefinitionsSupplier, refreshFormPropertiesEvent, domainObjectSelectionEvent));
    view.init(presenter);
    view.bind(session);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
    when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
    when(undefinedExpressionEditorDefinition.getName()).thenReturn(UNDEFINED_EXPRESSION_DEFINITION_NAME);
    when(undefinedExpressionEditor.getModel()).thenReturn(new BaseGridData());
    when(undefinedExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(undefinedExpressionEditor));
    when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(new LiteralExpression()));
    when(literalExpressionEditorDefinition.getName()).thenReturn(LITERAL_EXPRESSION_DEFINITION_NAME);
    when(literalExpressionEditor.getModel()).thenReturn(new BaseGridData());
    when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
    doAnswer((i) -> i.getArguments()[1]).when(translationService).format(Mockito.<String>any(), anyObject());
    doAnswer((i) -> i.getArguments()[0]).when(translationService).getTranslation(Mockito.<String>any());
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Optional(java.util.Optional) DMNGridPanelContainer(org.kie.workbench.common.dmn.client.widgets.panel.DMNGridPanelContainer) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) ExpressionGridCacheImpl(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCacheImpl) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 43 with BaseGridData

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

the class DecisionTableUIModelMapperTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new BaseGridRow());
    this.uiModel.appendRow(new BaseGridRow());
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModel.appendColumn(uiInputClauseColumn);
    this.uiModel.appendColumn(uiOutputClauseColumn);
    this.uiModel.appendColumn(uiAnnotationClauseColumn);
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiInputClauseColumn).getIndex();
    doReturn(2).when(uiOutputClauseColumn).getIndex();
    doReturn(3).when(uiAnnotationClauseColumn).getIndex();
    this.dtable = new DecisionTable();
    this.dtable.getInput().add(new InputClause());
    this.dtable.getOutput().add(new OutputClause());
    this.dtable.getAnnotations().add(new RuleAnnotationClause());
    this.dtable.getRule().add(new DecisionRule() {

        {
            getInputEntry().add(new UnaryTests() {

                {
                    getText().setValue("i1");
                }
            });
            getOutputEntry().add(new LiteralExpression() {

                {
                    getText().setValue("o1");
                }
            });
            getAnnotationEntry().add(new RuleAnnotationClauseText() {

                {
                    getText().setValue("a1");
                }
            });
        }
    });
    this.dtable.getRule().add(new DecisionRule() {

        {
            getInputEntry().add(new UnaryTests() {

                {
                    getText().setValue("i2");
                }
            });
            getOutputEntry().add(new LiteralExpression() {

                {
                    getText().setValue("o2");
                }
            });
            getAnnotationEntry().add(new RuleAnnotationClauseText() {

                {
                    getText().setValue("a2");
                }
            });
        }
    });
    this.mapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
}
Also used : OutputClause(org.kie.workbench.common.dmn.api.definition.model.OutputClause) DecisionTable(org.kie.workbench.common.dmn.api.definition.model.DecisionTable) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) RuleAnnotationClauseText(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClauseText) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) RuleAnnotationClause(org.kie.workbench.common.dmn.api.definition.model.RuleAnnotationClause) UnaryTests(org.kie.workbench.common.dmn.api.definition.model.UnaryTests) InputClause(org.kie.workbench.common.dmn.api.definition.model.InputClause) DecisionRule(org.kie.workbench.common.dmn.api.definition.model.DecisionRule) Before(org.junit.Before)

Example 44 with BaseGridData

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

the class EditableHeaderGridWidgetEditCellMouseEventHandlerTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.uiModel = new BaseGridData(false);
    this.uiModel.appendColumn(gridColumn);
    this.clickEvent = new NodeMouseClickEvent(nativeClickEvent);
    this.doubleClickEvent = new NodeMouseDoubleClickEvent(nativeDoubleClickEvent);
    when(gridWidget.getModel()).thenReturn(uiModel);
    when(gridWidget.getRendererHelper()).thenReturn(rendererHelper);
    when(gridWidget.getRenderer()).thenReturn(renderer);
    when(gridWidget.getHeader()).thenReturn(gridWidgetHeader);
    when(gridWidget.getViewport()).thenReturn(viewport);
    when(gridWidget.getComputedLocation()).thenReturn(computedLocation);
    when(gridWidget.getWidth()).thenReturn((double) MOUSE_EVENT_X);
    when(rendererHelper.getRenderingInformation()).thenReturn(renderingInformation);
    when(rendererHelper.getColumnInformation(anyDouble())).thenReturn(columnInformation);
    when(columnInformation.getColumn()).thenReturn(gridColumn);
    when(renderer.getHeaderHeight()).thenReturn((double) MOUSE_EVENT_Y);
    when(renderer.getHeaderRowHeight()).thenReturn((double) MOUSE_EVENT_Y);
    when(renderingInformation.getAllColumns()).thenReturn(uiModel.getColumns());
    when(renderingInformation.getBodyBlockInformation()).thenReturn(renderingBlockInformation);
    when(renderingInformation.getFloatingBlockInformation()).thenReturn(renderingBlockInformation);
    when(editableHeaderMetaData.getSupportedEditAction()).thenReturn(GridCellEditAction.SINGLE_CLICK);
    this.handler = new EditableHeaderGridWidgetEditCellMouseEventHandler();
}
Also used : BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) NodeMouseDoubleClickEvent(com.ait.lienzo.client.core.event.NodeMouseDoubleClickEvent) NodeMouseClickEvent(com.ait.lienzo.client.core.event.NodeMouseClickEvent) Before(org.junit.Before)

Example 45 with BaseGridData

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

the class DMNGridLayerTest method testSelectNestedGridWidget.

@Test
public void testSelectNestedGridWidget() {
    final GridWidget gridWidget = mock(GridWidget.class);
    final GridData gridData = new BaseGridData(false);
    gridData.appendRow(new BaseGridRow());
    gridData.appendColumn(mock(GridColumn.class));
    gridData.setCellValue(0, 0, new ExpressionCellValue(Optional.of(expressionGrid)));
    gridLayer.register(gridWidget);
    gridLayer.register(expressionGrid);
    assertThat(gridLayer.getSelectedGridWidget().isPresent()).isFalse();
    // Select nested grid
    when(gridWidget.getModel()).thenReturn(gridData);
    when(expressionGrid.getModel()).thenReturn(new BaseGridData(false));
    gridLayer.select(expressionGrid);
    assertThat(gridLayer.getSelectedGridWidget().isPresent()).isTrue();
    assertThat(gridLayer.getSelectedGridWidget().get()).isEqualTo(expressionGrid);
    verify(expressionGrid).select();
    verify(gridLayer).batch();
    // Select outer grid, deselecting nested grid
    reset(gridLayer, gridWidget, expressionGrid);
    when(gridWidget.getModel()).thenReturn(gridData);
    when(expressionGrid.getModel()).thenReturn(new BaseGridData(false));
    when(expressionGrid.isSelected()).thenReturn(true);
    gridLayer.select(gridWidget);
    assertThat(gridLayer.getSelectedGridWidget().isPresent()).isTrue();
    assertThat(gridLayer.getSelectedGridWidget().get()).isEqualTo(gridWidget);
    verify(gridWidget).select();
    verify(expressionGrid).deselect();
    verify(gridLayer).batch();
    // Reselect outer grid, there should be no change in selections and the GridLayer should not be redrawn
    reset(gridLayer, gridWidget, expressionGrid);
    when(gridWidget.getModel()).thenReturn(gridData);
    when(gridWidget.isSelected()).thenReturn(true);
    when(expressionGrid.getModel()).thenReturn(new BaseGridData(false));
    when(expressionGrid.isSelected()).thenReturn(false);
    gridLayer.select(gridWidget);
    verify(gridWidget, never()).select();
    verify(expressionGrid, never()).deselect();
    verify(gridLayer, never()).batch();
}
Also used : GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Test(org.junit.Test)

Aggregations

BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)56 Before (org.junit.Before)41 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)24 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)23 Optional (java.util.Optional)20 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)19 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)18 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)13 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)10 HasName (org.kie.workbench.common.dmn.api.definition.HasName)7 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)7 Element (org.kie.workbench.common.stunner.core.graph.Element)7 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)7 Test (org.junit.Test)6 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)6 UpdateElementPropertyCommand (org.kie.workbench.common.stunner.core.client.canvas.command.UpdateElementPropertyCommand)6 List (org.kie.workbench.common.dmn.api.definition.model.List)5 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)5 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)5 BaseBounds (org.uberfire.ext.wires.core.grids.client.model.impl.BaseBounds)5