Search in sources :

Example 6 with BaseGridRendererHelper

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;
}
Also used : GridBodyCellEditContext(org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellEditContext) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

Example 7 with BaseGridRendererHelper

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;
}
Also used : Group(com.ait.lienzo.client.core.shape.Group) Point2D(com.ait.lienzo.client.core.types.Point2D) GridBodyCellEditContext(org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellEditContext) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

Example 8 with BaseGridRendererHelper

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();
}
Also used : BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

Example 9 with BaseGridRendererHelper

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);
}
Also used : Point2D(com.ait.lienzo.client.core.types.Point2D) GridBodyCellEditContext(org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellEditContext) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

Aggregations

BaseGridRendererHelper (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)9 Point2D (com.ait.lienzo.client.core.types.Point2D)4 GridBodyCellEditContext (org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellEditContext)4 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)2 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)2 AbstractNodeMouseEvent (com.ait.lienzo.client.core.event.AbstractNodeMouseEvent)1 Group (com.ait.lienzo.client.core.shape.Group)1 Transform (com.ait.lienzo.client.core.types.Transform)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)1 ScenarioHeaderMetaData (org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData)1 ScenarioGrid (org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGrid)1 ScenarioGridColumn (org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn)1 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)1 GridCellEditAction (org.uberfire.ext.wires.core.grids.client.model.GridCellEditAction)1 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)1 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)1 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)1 DefaultGridWidgetEditCellMouseEventHandler (org.uberfire.ext.wires.core.grids.client.widget.grid.impl.DefaultGridWidgetEditCellMouseEventHandler)1