Search in sources :

Example 1 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 GuidedDecisionTableSortGridWidgetMouseEventHandler 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 BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper();
    final BaseGridRendererHelper.ColumnInformation ci = rendererHelper.getColumnInformation(relativeLocation.getX());
    final GridColumn<?> column = ci.getColumn();
    sortConsumer.accept(column);
    return true;
}
Also used : BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

Example 2 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 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.getComputedLocation()).thenReturn(new Point2D(x, 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;
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Point2D(com.ait.lienzo.client.core.types.Point2D) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) GridRenderer(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.GridRenderer) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

Example 3 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 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();
}
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 4 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 ColumnHeaderPopOverImpl method getScreenX.

private int getScreenX(final GuidedDecisionTableModellerView modellerView, final GuidedDecisionTableView.Presenter dtPresenter, final int uiColumnIndex) {
    final GridWidget gridWidget = dtPresenter.getView();
    final GridColumn<?> uiColumn = gridWidget.getModel().getColumns().get(uiColumnIndex);
    final double gx = gridWidget.getX();
    final GridLayer layer = modellerView.getGridLayerView();
    final int containerX = layer.getDomElementContainer().getAbsoluteLeft();
    final double vx = layer.getVisibleBounds().getX();
    final Transform t = layer.getViewport().getTransform();
    final BaseGridRendererHelper rendererHelper = gridWidget.getRendererHelper();
    final BaseGridRendererHelper.RenderingInformation ri = rendererHelper.getRenderingInformation();
    final BaseGridRendererHelper.RenderingBlockInformation floatingBlockInformation = ri.getFloatingBlockInformation();
    final double offsetX = floatingBlockInformation.getColumns().contains(uiColumn) ? floatingBlockInformation.getX() : 0;
    final int screenX = containerX + (int) ((gx - vx + offsetX + rendererHelper.getColumnOffset(uiColumn) + uiColumn.getWidth() / 2) * t.getScaleX());
    return screenX;
}
Also used : GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) GridLayer(org.uberfire.ext.wires.core.grids.client.widget.layer.GridLayer) Transform(com.ait.lienzo.client.core.types.Transform) BaseGridRendererHelper(org.uberfire.ext.wires.core.grids.client.widget.grid.renderers.grids.impl.BaseGridRendererHelper)

Example 5 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 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

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