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());
}
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());
}
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);
}
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();
}
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();
}
Aggregations