use of org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellEditContext in project kie-wb-common by kiegroup.
the class EditableHeaderUtilities method makeRenderContext.
public static GridBodyCellEditContext makeRenderContext(final GridWidget gridWidget, final BaseGridRendererHelper.RenderingInformation ri, final BaseGridRendererHelper.ColumnInformation ci, final Point2D rp, final int uiHeaderRowIndex) {
final GridColumn<?> column = ci.getColumn();
final GridRenderer renderer = gridWidget.getRenderer();
final Group header = gridWidget.getHeader();
final double headerRowsYOffset = ri.getHeaderRowsYOffset();
final double headerMinY = (header == null ? headerRowsYOffset : header.getY() + headerRowsYOffset);
final double headerRowHeight = renderer.getHeaderRowHeight() / column.getHeaderMetaData().size();
final double cellX = gridWidget.getAbsoluteX() + ci.getOffsetX();
final double cellY = gridWidget.getAbsoluteY() + headerMinY + (headerRowHeight * uiHeaderRowIndex);
final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = ri.getFloatingBlockInformation();
final double floatingX = floatingBlockInformation.getX();
final double floatingWidth = floatingBlockInformation.getWidth();
final double clipMinX = gridWidget.getAbsoluteX() + floatingX + floatingWidth;
final double clipMinY = gridWidget.getAbsoluteY();
// Check and adjust for blocks of columns sharing equal HeaderMetaData
double blockCellX = cellX;
double blockCellWidth = column.getWidth();
final List<GridColumn<?>> gridColumns = ri.getAllColumns();
final GridColumn.HeaderMetaData clicked = column.getHeaderMetaData().get(uiHeaderRowIndex);
// Walk backwards to block start
if (ci.getUiColumnIndex() > 0) {
int uiLeadColumnIndex = ci.getUiColumnIndex() - 1;
GridColumn<?> lead = gridColumns.get(uiLeadColumnIndex);
while (uiLeadColumnIndex >= 0 && isSameHeaderMetaData(clicked, lead.getHeaderMetaData(), uiHeaderRowIndex)) {
blockCellX = blockCellX - lead.getWidth();
blockCellWidth = blockCellWidth + lead.getWidth();
if (--uiLeadColumnIndex >= 0) {
lead = gridColumns.get(uiLeadColumnIndex);
}
}
}
// Walk forwards to block end
if (ci.getUiColumnIndex() < gridColumns.size() - 1) {
int uiTailColumnIndex = ci.getUiColumnIndex() + 1;
GridColumn<?> tail = gridColumns.get(uiTailColumnIndex);
while (uiTailColumnIndex < gridColumns.size() && isSameHeaderMetaData(clicked, tail.getHeaderMetaData(), uiHeaderRowIndex)) {
blockCellWidth = blockCellWidth + tail.getWidth();
tail = gridColumns.get(uiTailColumnIndex);
if (++uiTailColumnIndex < gridColumns.size()) {
tail = gridColumns.get(uiTailColumnIndex);
}
}
}
return new GridBodyCellEditContext(blockCellX, cellY, blockCellWidth, headerRowHeight, clipMinY, clipMinX, uiHeaderRowIndex, ci.getUiColumnIndex(), floatingBlockInformation.getColumns().contains(column), gridWidget.getViewport().getTransform(), renderer, Optional.of(rp));
}
use of org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellEditContext in project drools-wb by kiegroup.
the class ScenarioSimulationUtils method getCellHeight.
public static int getCellHeight(final GridWidget gridWidget, final GridColumn<?> column, boolean isHeader, final int uiRowIndex) {
final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper();
final BaseGridRendererHelper.RenderingInformation ri = rendererHelper.getRenderingInformation();
final double columnXCoordinate = rendererHelper.getColumnOffset(column) + column.getWidth() / 2;
final BaseGridRendererHelper.ColumnInformation ci = rendererHelper.getColumnInformation(columnXCoordinate);
final GridBodyCellEditContext context = isHeader ? CellContextUtilities.makeHeaderCellRenderContext(gridWidget, ri, ci, uiRowIndex) : CellContextUtilities.makeCellRenderContext(gridWidget, ri, ci, uiRowIndex);
return (int) context.getCellHeight();
}
use of org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellEditContext in project drools-wb by kiegroup.
the class CommonEditHandler method manageGivenExpectHeaderLeftClick.
/**
* This method manage the click happened on an <i>GIVEN</i> or <i>EXPECT</i> header, starting editing it if not already did.
* @param clickedScenarioHeaderMetadata
* @return
*/
protected static boolean manageGivenExpectHeaderLeftClick(ScenarioGrid scenarioGrid, ScenarioHeaderMetaData clickedScenarioHeaderMetadata, int uiColumnIndex, int uiHeaderRowIndex) {
final AbstractScesimGridModel<? extends AbstractScesimModel, ? extends AbstractScesimData> gridModel = scenarioGrid.getModel();
final GridColumn<?> column = gridModel.getColumns().get(uiColumnIndex);
final BaseGridRendererHelper rendererHelper = scenarioGrid.getRendererHelper();
final BaseGridRendererHelper.RenderingInformation ri = rendererHelper.getRenderingInformation();
final double columnXCoordinate = rendererHelper.getColumnOffset(column) + column.getWidth() / 2;
final BaseGridRendererHelper.ColumnInformation ci = rendererHelper.getColumnInformation(columnXCoordinate);
final GridBodyCellEditContext context = CellContextUtilities.makeHeaderCellRenderContext(scenarioGrid, ri, ci, null, uiHeaderRowIndex);
clickedScenarioHeaderMetadata.edit(context);
return true;
}
use of org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellEditContext in project kie-wb-common by kiegroup.
the class RuleAnnotationClauseColumnTest method testEdit.
@Test
public void testEdit() {
final GridCell<String> cell = mock(GridCell.class);
final GridBodyCellEditContext context = mock(GridBodyCellEditContext.class);
final Consumer callback = mock(Consumer.class);
final Consumer onDisplay = mock(Consumer.class);
final Consumer onCreation = mock(Consumer.class);
doReturn(onDisplay).when(column).getTextAreaDOMElementConsumerOnDisplay();
doReturn(onCreation).when(column).getTextAreaDOMElementConsumerOnCreation(cell);
column.edit(cell, context, callback);
verify(factory).attachDomElement(context, onCreation, onDisplay);
}
use of org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellEditContext in project kie-wb-common by kiegroup.
the class EditableTextHeaderMetaDataTest method checkEdit.
@Test
@SuppressWarnings("unchecked")
public void checkEdit() {
final GridBodyCellEditContext context = mock(GridBodyCellEditContext.class);
header.edit(context);
verify(factory).attachDomElement(eq(context), any(Consumer.class), any(Consumer.class));
}
Aggregations