Search in sources :

Example 1 with BaseGridRow

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

the class GuidedDecisionTablePresenter method initialiseRow.

private void initialiseRow(final List<BaseColumn> columns, final List<DTCellValue52> row) {
    final GridRow uiModelRow = new BaseGridRow(GuidedDecisionTableView.ROW_HEIGHT);
    final int rowIndex = uiModel.getRowCount();
    uiModel.appendRow(uiModelRow);
    for (int iModelColumn = 0; iModelColumn < row.size(); iModelColumn++) {
        final DTCellValue52 modelCell = row.get(iModelColumn);
        final BaseColumn modelColumn = columns.get(iModelColumn);
        // We cannot rely upon the values in the existing data as legacy tables aren't guaranteed to be sorted
        if (modelColumn instanceof RowNumberCol52) {
            modelCell.setNumericValue(uiModel.getRowCount());
        }
        // BaseGridData is sparsely populated; only add values if needed.
        if (modelCell.hasValue()) {
            uiModel.setCellValueInternal(rowIndex, iModelColumn, gridWidgetCellFactory.convertCell(modelCell, modelColumn, cellUtilities, columnUtilities));
            // Set-up SelectionManager for Row Number column, to select entire row.
            if (modelColumn instanceof RowNumberCol52) {
                uiModel.getCell(rowIndex, iModelColumn).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
            }
        }
    }
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)

Example 2 with BaseGridRow

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

the class RowSynchronizer method append.

@Override
public void append(final RowMetaData metaData) throws VetoException {
    if (!handlesAppend(metaData)) {
        return;
    }
    final List<DTCellValue52> modelRow = new ArrayList<DTCellValue52>();
    model.getData().add(modelRow);
    final GridRow uiModelRow = new BaseGridRow(GuidedDecisionTableView.ROW_HEIGHT);
    uiModel.appendRow(uiModelRow);
    final int rowIndex = uiModel.getRowCount() - 1;
    initialiseRowData(rowIndex);
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) ArrayList(java.util.ArrayList) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Example 3 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow 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 4 with BaseGridRow

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

the class GuidedDecisionTableModellerContextMenuSupportTest method makeDecisionTable.

private GuidedDecisionTableView.Presenter makeDecisionTable(final double x, final double y) {
    final GridData uiModel = spy(new BaseGridData());
    final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class);
    final GuidedDecisionTableView dtView = mock(GuidedDecisionTableView.class);
    final GridRenderer renderer = mock(GridRenderer.class);
    final BaseGridRendererHelper helper = mock(BaseGridRendererHelper.class);
    uiModel.appendRow(new BaseGridRow());
    when(dtPresenter.getView()).thenReturn(dtView);
    when(dtPresenter.getAccess()).thenReturn(mock(GuidedDecisionTablePresenter.Access.class));
    when(dtPresenter.getModel()).thenReturn(mock(GuidedDecisionTable52.class));
    when(dtView.getViewport()).thenReturn(viewport);
    when(dtView.getLayer()).thenReturn(layer);
    when(dtView.getLocation()).thenReturn(new Point2D(x, y));
    when(dtView.getAbsoluteX()).thenReturn(x);
    when(dtView.getAbsoluteY()).thenReturn(y);
    when(dtView.getWidth()).thenReturn(50.0);
    when(dtView.getHeight()).thenReturn(52.0);
    when(dtView.getModel()).thenReturn(uiModel);
    when(dtView.getRenderer()).thenReturn(renderer);
    when(renderer.getHeaderHeight()).thenReturn(32.0);
    when(dtView.getRendererHelper()).thenReturn(helper);
    when(helper.getColumnInformation(any(Double.class))).thenReturn(columnInformation);
    return dtPresenter;
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Point2D(com.ait.lienzo.client.core.types.Point2D) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

Example 5 with BaseGridRow

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

the class CellContextMenuTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    model = new GuidedDecisionTable52();
    uiModel = new GuidedDecisionTableUiModel(mock(ModelSynchronizer.class));
    clipboard = new DefaultClipboard();
    when(dtPresenter.getView()).thenReturn(dtPresenterView);
    when(dtPresenter.getModel()).thenReturn(model);
    when(dtPresenter.getAccess()).thenReturn(access);
    when(dtPresenterView.getModel()).thenReturn(uiModel);
    uiModel.appendColumn(new BaseGridColumn<String>(mock(GridColumn.HeaderMetaData.class), mock(GridColumnRenderer.class), 100));
    uiModel.appendColumn(new BaseGridColumn<String>(mock(GridColumn.HeaderMetaData.class), mock(GridColumnRenderer.class), 100));
    uiModel.appendColumn(new BaseGridColumn<String>(mock(GridColumn.HeaderMetaData.class), mock(GridColumnRenderer.class), 100));
    uiModel.appendRow(new BaseGridRow());
    menu = spy(new CellContextMenu(view, clipboard));
    menu.setup();
}
Also used : DefaultClipboard(org.drools.workbench.screens.guided.dtable.client.editor.clipboard.impl.DefaultClipboard) 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) BaseGridColumn(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) Before(org.junit.Before)

Aggregations

BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)27 Test (org.junit.Test)11 Before (org.junit.Before)9 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)8 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)7 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)6 GuidedDecisionTableUiModel (org.drools.workbench.screens.guided.dtable.client.widget.table.model.GuidedDecisionTableUiModel)5 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)4 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)4 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)3 DefaultClipboard (org.drools.workbench.screens.guided.dtable.client.editor.clipboard.impl.DefaultClipboard)3 DecisionRule (org.kie.workbench.common.dmn.api.definition.v1_1.DecisionRule)3 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)3 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)3 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)3 GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)3 BaseGridColumn (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridColumn)3 RowNumberColumn (org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn)3 Annotation (java.lang.annotation.Annotation)2 ArrayList (java.util.ArrayList)2