use of org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn in project kie-wb-common by kiegroup.
the class InvocationGridTest method testInitialSetupFromDefinition.
@Test
public void testInitialSetupFromDefinition() {
setupGrid(0);
final GridData uiModel = grid.getModel();
assertTrue(uiModel instanceof InvocationGridData);
assertEquals(3, uiModel.getColumnCount());
assertTrue(uiModel.getColumns().get(0) instanceof RowNumberColumn);
assertTrue(uiModel.getColumns().get(1) instanceof InvocationParameterColumn);
assertTrue(uiModel.getColumns().get(2) instanceof ExpressionEditorColumn);
assertEquals(1, uiModel.getRowCount());
assertEquals(1, uiModel.getCell(0, 0).getValue().getValue());
assertEquals(InvocationDefaultValueUtilities.PREFIX + "1", ((InformationItemCell.HasNameAndDataTypeCell) uiModel.getCell(0, 1).getValue().getValue()).getName().getValue());
assertTrue(uiModel.getCell(0, 2).getValue() instanceof ExpressionCellValue);
final ExpressionCellValue dcv0 = (ExpressionCellValue) uiModel.getCell(0, 2).getValue();
assertEquals(undefinedExpressionEditor, dcv0.getValue().get());
}
use of org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn in project drools-wb by kiegroup.
the class ColumnHeaderPopOverImplTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.model = new GuidedDecisionTable52();
this.model.getExpandedColumns().get(GuidedDecisionTable52.RULE_NUMBER_INDEX).setHeader("#");
this.model.getExpandedColumns().get(GuidedDecisionTable52.RULE_NAME_COLUMN_INDEX).setHeader("");
this.model.getExpandedColumns().get(GuidedDecisionTable52.RULE_DESCRIPTION_INDEX).setHeader("description");
this.uiColumn1 = new RowNumberColumn();
this.uiColumn2 = new BaseGridColumn<>(new BaseHeaderMetaData("rule name"), columnRenderer, 100.0);
this.uiColumn3 = new BaseGridColumn<>(new BaseHeaderMetaData("description"), columnRenderer, 100.0);
this.uiModel = new BaseGridData() {
{
setHeaderRowCount(2);
}
};
uiModel.appendColumn(uiColumn1);
uiModel.appendColumn(uiColumn2);
uiModel.appendColumn(uiColumn3);
serviceCaller = new CallerMock<>(service);
when(service.toSource(any(), any(GuidedDecisionTable52.class))).thenReturn("source");
final Instance<ColumnDefinitionBuilder> buildersInstance = makeBuildersInstance();
final ColumnDefinitionFactory columnDefinitionFactory = new ColumnDefinitionFactory(buildersInstance);
when(renderer.getHeaderHeight()).thenReturn(64.0);
when(renderer.getHeaderRowHeight()).thenReturn(32.0);
when(dtPresenter.getView()).thenReturn(gridWidget);
when(dtPresenter.getModel()).thenReturn(model);
when(dtPresenter.getDataModelOracle()).thenReturn(dmo);
when(modellerView.getGridLayerView()).thenReturn(gridLayer);
when(gridLayer.getDomElementContainer()).thenReturn(domElementContainer);
when(gridLayer.getVisibleBounds()).thenReturn(bounds);
when(gridLayer.getViewport()).thenReturn(viewport);
when(gridWidget.getModel()).thenReturn(uiModel);
when(gridWidget.getViewport()).thenReturn(viewport);
when(gridWidget.getRenderer()).thenReturn(renderer);
when(gridWidget.getRendererHelper()).thenReturn(rendererHelper);
when(gridWidget.getWidth()).thenReturn(150.0);
when(gridWidget.getHeight()).thenReturn(64.0);
when(gridWidget.getX()).thenReturn(50.0);
when(gridWidget.getY()).thenReturn(50.0);
when(domElementContainer.getAbsoluteLeft()).thenReturn(200);
when(viewport.getTransform()).thenReturn(transform);
when(rendererHelper.getColumnOffset(uiColumn1)).thenReturn(0.0);
when(rendererHelper.getColumnOffset(uiColumn2)).thenReturn(uiColumn1.getWidth());
when(rendererHelper.getColumnOffset(uiColumn3)).thenReturn(uiColumn1.getWidth());
final BaseGridRendererHelper.RenderingInformation ri = new BaseGridRendererHelper.RenderingInformation(bounds, uiModel.getColumns(), new BaseGridRendererHelper.RenderingBlockInformation(new ArrayList<GridColumn<?>>() {
{
add(uiColumn3);
}
}, 0.0, 0.0, 0.0, 100.0), new BaseGridRendererHelper.RenderingBlockInformation(new ArrayList<GridColumn<?>>() {
{
add(uiColumn1);
}
}, 25.0, 0.0, 0.0, 50.0), 0, 0, Collections.emptyList(), Collections.emptyList(), false, false, 2, 0, 0, 0);
when(rendererHelper.getRenderingInformation()).thenReturn(ri);
final ColumnHeaderPopOver wrapped = new ColumnHeaderPopOverImpl(view, columnDefinitionFactory);
this.popOver = spy(wrapped);
}
use of org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn in project drools-wb by kiegroup.
the class GuidedDecisionTableRendererTest method setup.
@Before
public void setup() {
this.uiModel = new GuidedDecisionTableUiModel(synchronizer);
this.uiColumn = new RowNumberColumn();
this.uiModel.appendColumn(uiColumn);
this.uiModel.appendRow(new BaseGridRow());
this.renderer = spy(new GuidedDecisionTableRenderer(uiModel, new GuidedDecisionTable52()));
when(renderingInformation.getVisibleRowOffsets()).thenReturn(Collections.singletonList(20.0));
when(renderingInformation.getAllRowHeights()).thenReturn(Collections.singletonList(20.0));
when(context.getBlockColumns()).thenReturn(Collections.singletonList(uiColumn));
when(renderingInformation.getBodyBlockInformation()).thenReturn(bodyBlockInformation);
when(bodyBlockInformation.getColumns()).thenReturn(Collections.singletonList(uiColumn));
when(renderingInformation.getFloatingBlockInformation()).thenReturn(floatingBlockInformation);
when(floatingBlockInformation.getColumns()).thenReturn(Collections.emptyList());
when(context.getRenderer()).thenReturn(renderer);
}
use of org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn in project drools-wb by kiegroup.
the class GuidedDecisionTableModellerContextMenuSupportTest method testContextMenuCellIsNotSelectedCell.
@Test
@SuppressWarnings("unchecked")
public void testContextMenuCellIsNotSelectedCell() {
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
final GridData uiModel = dtPresenter.getView().getModel();
final GridColumn uiColumn = new RowNumberColumn();
uiModel.appendColumn(uiColumn);
uiModel.appendRow(new BaseGridRow());
// Cell associated with Mock onContextMenu Event has indices (0,0)
uiModel.selectCells(1, 0, 1, 1);
when(columnInformation.getColumn()).thenReturn(uiColumn);
when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter);
}
});
when(uiModel.getCell(any(Integer.class), any(Integer.class))).thenReturn(uiCell);
final ContextMenuHandler handler = contextMenuSupport.getContextMenuHandler(modellerPresenter);
handler.onContextMenu(event);
// this method is called if the handler does a selectCell, which should occur for this test case
verify(cellSelectionStrategy, times(1)).handleSelection(any(GridData.class), eq(0), eq(0), eq(false), eq(false));
verify(rowContextMenu, times(1)).show(any(Integer.class), any(Integer.class));
verify(cellContextMenu, never()).show(any(Integer.class), any(Integer.class));
}
use of org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn in project drools-wb by kiegroup.
the class GuidedDecisionTableModellerContextMenuSupportTest method onContextMenuWithCellSelectionManagerWithChangeInSelection.
@Test
@SuppressWarnings("unchecked")
public void onContextMenuWithCellSelectionManagerWithChangeInSelection() {
final GuidedDecisionTableView.Presenter dtPresenter = makeDecisionTable();
final GridData uiModel = dtPresenter.getView().getModel();
final GridColumn uiColumn = new RowNumberColumn();
uiModel.appendColumn(uiColumn);
when(columnInformation.getColumn()).thenReturn(uiColumn);
when(modellerPresenter.getAvailableDecisionTables()).thenReturn(new HashSet<GuidedDecisionTableView.Presenter>() {
{
add(dtPresenter);
}
});
when(uiModel.getCell(any(Integer.class), any(Integer.class))).thenReturn(uiCell);
when(cellSelectionStrategy.handleSelection(any(GridData.class), any(Integer.class), any(Integer.class), any(Boolean.class), any(Boolean.class))).thenReturn(true);
final ContextMenuHandler handler = contextMenuSupport.getContextMenuHandler(modellerPresenter);
handler.onContextMenu(event);
verify(cellSelectionStrategy, times(1)).handleSelection(eq(uiModel), eq(0), eq(0), eq(false), eq(false));
verify(layer, times(1)).batch();
}
Aggregations