Search in sources :

Example 6 with RowNumberColumn

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());
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) ExpressionEditorColumn(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) Test(org.junit.Test)

Example 7 with RowNumberColumn

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);
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) ColumnDefinitionBuilder(org.drools.workbench.screens.guided.dtable.client.widget.table.popovers.definitions.ColumnDefinitionBuilder) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ArrayList(java.util.ArrayList) BaseHeaderMetaData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseHeaderMetaData) ColumnDefinitionFactory(org.drools.workbench.screens.guided.dtable.client.widget.table.popovers.definitions.ColumnDefinitionFactory) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper) Before(org.junit.Before)

Example 8 with RowNumberColumn

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);
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GuidedDecisionTableUiModel(org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel) Before(org.junit.Before)

Example 9 with RowNumberColumn

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));
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) 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) BaseGridColumn(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ContextMenuHandler(com.google.gwt.event.dom.client.ContextMenuHandler) Test(org.junit.Test)

Example 10 with RowNumberColumn

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();
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridColumn(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ContextMenuHandler(com.google.gwt.event.dom.client.ContextMenuHandler) Test(org.junit.Test)

Aggregations

RowNumberColumn (org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn)24 Test (org.junit.Test)17 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)11 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)9 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)9 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)9 ContextMenuHandler (com.google.gwt.event.dom.client.ContextMenuHandler)6 BaseGridColumn (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn)6 ArrayList (java.util.ArrayList)4 Before (org.junit.Before)4 ExpressionEditorColumn (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn)4 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)3 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)3 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)2 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)2 BaseGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseGrid)2 DMNGridLayer (org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer)2 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)2 Layer (com.ait.lienzo.client.core.shape.Layer)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1