Search in sources :

Example 1 with AbstractNodeMouseEvent

use of com.ait.lienzo.client.core.event.AbstractNodeMouseEvent in project drools-wb by kiegroup.

the class ScenarioSimulationGridWidgetMouseEventHandler method handleHeaderCell.

@Override
public boolean handleHeaderCell(final GridWidget gridWidget, final Point2D relativeLocation, final int uiHeaderRowIndex, final int uiHeaderColumnIndex, final AbstractNodeMouseEvent event) {
    // Get column information
    final double cx = relativeLocation.getX();
    final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper();
    final BaseGridRendererHelper.ColumnInformation ci = rendererHelper.getColumnInformation(cx);
    final GridColumn<?> column = ci.getColumn();
    if (column == null) {
        return false;
    }
    final ScenarioHeaderMetaData headerMetaData = (ScenarioHeaderMetaData) column.getHeaderMetaData().get(uiHeaderRowIndex);
    final GridData gridData = gridWidget.getModel();
    if (!gridData.getSelectedHeaderCells().isEmpty() && editSupportedLocal(headerMetaData.getSupportedEditAction(), event)) {
        final GridData.SelectedCell firstSelectedHeaderCell = gridData.getSelectedHeaderCells().get(0);
        final Optional<GridColumn<?>> firstSelectedColumnOptional = gridData.getColumns().stream().filter(col -> col.getIndex() == firstSelectedHeaderCell.getColumnIndex()).findFirst();
        final int firstSelectedColumnPosition = gridData.getColumns().indexOf(firstSelectedColumnOptional.orElseThrow(IllegalStateException::new));
        return startEditLocal((ScenarioGrid) gridWidget, firstSelectedColumnPosition, (ScenarioGridColumn) column, uiHeaderRowIndex, true);
    }
    return true;
}
Also used : GridCellEditAction(org.uberfire.ext.wires.core.grids.client.model.GridCellEditAction) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) ScenarioGrid(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGrid) DefaultGridWidgetEditCellMouseEventHandler(org.uberfire.ext.wires.core.grids.client.widget.grid.impl.DefaultGridWidgetEditCellMouseEventHandler) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) AbstractNodeMouseEvent(com.ait.lienzo.client.core.event.AbstractNodeMouseEvent) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) Objects(java.util.Objects) ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) ScenarioGridColumn(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper) Point2D(com.ait.lienzo.client.core.types.Point2D) Optional(java.util.Optional) ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ScenarioGridColumn(org.drools.workbench.screens.scenariosimulation.client.widgets.ScenarioGridColumn) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

Aggregations

AbstractNodeMouseEvent (com.ait.lienzo.client.core.event.AbstractNodeMouseEvent)1 Point2D (com.ait.lienzo.client.core.types.Point2D)1 Objects (java.util.Objects)1 Optional (java.util.Optional)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 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)1 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)1 DefaultGridWidgetEditCellMouseEventHandler (org.uberfire.ext.wires.core.grids.client.widget.grid.impl.DefaultGridWidgetEditCellMouseEventHandler)1 BaseGridRendererHelper (org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)1