use of org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper 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.grid.renderers.grids.impl.BaseGridRendererHelper in project kie-wb-common by kiegroup.
the class EditableHeaderGridWidgetMouseDoubleClickHandler method handleHeaderCellDoubleClick.
@Override
protected boolean handleHeaderCellDoubleClick(final NodeMouseDoubleClickEvent event) {
// Convert Canvas co-ordinate to Grid co-ordinate
final Point2D rp = CoordinateUtilities.convertDOMToGridCoordinate(gridWidget, new Point2D(event.getX(), event.getY()));
final double cx = rp.getX();
final double cy = rp.getY();
final Group header = gridWidget.getHeader();
final double headerRowsYOffset = getHeaderRowsYOffset();
final double headerMinY = (header == null ? headerRowsYOffset : header.getY() + headerRowsYOffset);
final double headerMaxY = (header == null ? renderer.getHeaderHeight() : renderer.getHeaderHeight() + header.getY());
if (cx < 0 || cx > gridWidget.getWidth()) {
return false;
}
if (cy < headerMinY || cy > headerMaxY) {
return false;
}
// Get column information
final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper();
final BaseGridRendererHelper.RenderingInformation ri = rendererHelper.getRenderingInformation();
if (ri == null) {
return false;
}
final BaseGridRendererHelper.ColumnInformation ci = rendererHelper.getColumnInformation(cx);
final GridColumn<?> column = ci.getColumn();
if (column == null) {
return false;
}
if (!hasEditableHeader(column)) {
return false;
}
// Get row index
final Integer uiHeaderRowIndex = EditableHeaderUtilities.getUiHeaderRowIndex(gridWidget, column, cy);
if (uiHeaderRowIndex == null) {
return false;
}
if (!isEditableHeader(column, uiHeaderRowIndex)) {
return false;
}
// Get rendering information
final EditableHeaderMetaData headerMetaData = (EditableHeaderMetaData) column.getHeaderMetaData().get(uiHeaderRowIndex);
final GridBodyCellEditContext context = EditableHeaderUtilities.makeRenderContext(gridWidget, ri, ci, rp, uiHeaderRowIndex);
headerMetaData.edit(context);
return true;
}
use of org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper in project drools-wb by kiegroup.
the class ScenarioSimulationGridHeaderUtilities method getGridColumn.
/**
* Retrieve the <code>GridColumn</code> of a <code>GridWidget</code> at a given point x.
* It returns <code>null</code> if none is present at that position.
* @param gridWidget
* @param cx
* @return
*/
public static GridColumn<?> getGridColumn(GridWidget gridWidget, double cx) {
// Get column information
final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper();
final BaseGridRendererHelper.RenderingInformation ri = rendererHelper.getRenderingInformation();
if (ri == null) {
return null;
}
final BaseGridRendererHelper.ColumnInformation ci = rendererHelper.getColumnInformation(cx);
return ci.getColumn();
}
use of org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper in project drools-wb by kiegroup.
the class ScenarioSimulationUtils method getMiddleXYCell.
/**
* Returns an array where the 0-element is middle x of given cell and 1-element is middle y
* @param gridWidget
* @param column
* @param isHeader
* @param uiRowIndex
* @param gridLayer
* @return
*/
public static Point2D getMiddleXYCell(final GridWidget gridWidget, final GridColumn<?> column, boolean isHeader, final int uiRowIndex, final GridLayer gridLayer) {
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);
final int cellXMiddle = (int) (context.getAbsoluteCellX() + context.getCellWidth() / 2 + gridLayer.getDomElementContainer().getAbsoluteLeft());
final int cellYMiddle = (int) (context.getAbsoluteCellY() + context.getCellHeight() / 2 + gridLayer.getDomElementContainer().getAbsoluteTop());
return new Point2D(cellXMiddle, cellYMiddle);
}
Aggregations