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