Search in sources :

Example 1 with DMNGridLayer

use of org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer in project kie-wb-common by kiegroup.

the class ExpressionContainerGridTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.expressionGridCache = new ExpressionGridCacheImpl();
    this.gridLayer = spy(new DMNGridLayer());
    this.grid = new ExpressionContainerGrid(gridLayer, cellEditorControls, translationService, listSelector, sessionManager, sessionCommandManager, canvasCommandFactory, expressionEditorDefinitionsSupplier, () -> expressionGridCache, onHasExpressionChanged, onHasNameChanged, refreshFormPropertiesEvent, domainObjectSelectionEvent) {

        @Override
        public CellSelectionManager getCellSelectionManager() {
            return cellSelectionManager;
        }
    };
    this.gridLayer.add(grid);
    final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
    expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
    expressionEditorDefinitions.add(literalExpressionEditorDefinition);
    when(expressionEditorDefinitionsSupplier.get()).thenReturn(expressionEditorDefinitions);
    when(literalExpressionEditor.isCacheable()).thenReturn(true);
    when(literalExpressionEditor.getParentInformation()).thenReturn(parent);
    when(literalExpressionEditor.getModel()).thenReturn(new BaseGridData());
    when(literalExpressionEditorDefinition.getModelClass()).thenReturn(Optional.of(literalExpression));
    when(literalExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(literalExpressionEditor));
    when(undefinedExpressionEditor.getParentInformation()).thenReturn(parent);
    when(undefinedExpressionEditor.getModel()).thenReturn(new BaseGridData());
    when(undefinedExpressionEditorDefinition.getModelClass()).thenReturn(Optional.empty());
    when(undefinedExpressionEditorDefinition.getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), anyBoolean(), anyInt())).thenReturn(Optional.of(undefinedExpressionEditor));
    when(sessionManager.getCurrentSession()).thenReturn(session);
    when(session.getCanvasHandler()).thenReturn(canvasHandler);
    when(canvasHandler.getGraphExecutionContext()).thenReturn(graphExecutionContext);
    doReturn(mock(Bounds.class)).when(gridLayer).getVisibleBounds();
    when(canvasHandler.getDiagram()).thenReturn(diagram);
    when(diagram.getGraph()).thenReturn(graph);
    when(graph.nodes()).thenReturn(Collections.singletonList(node));
    when(parent.getGridWidget()).thenReturn(grid);
    when(parent.getRowIndex()).thenReturn(0);
    when(parent.getColumnIndex()).thenReturn(0);
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).format(Mockito.<String>any());
}
Also used : ExpressionEditorDefinitions(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Optional(java.util.Optional) Bounds(org.uberfire.ext.wires.core.grids.client.model.Bounds) ExpressionGridCacheImpl(org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCacheImpl) CellSelectionManager(org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionManager) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) Before(org.junit.Before)

Example 2 with DMNGridLayer

use of org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer in project kie-wb-common by kiegroup.

the class DMNGridPanelControlImpl method bind.

@Override
public void bind(final DMNSession session) {
    final DMNGridLayer gridLayer = session.getGridLayer();
    final CellEditorControlsView.Presenter cellEditorControls = session.getCellEditorControls();
    final RestrictedMousePanMediator mousePanMediator = session.getMousePanMediator();
    final DMNGridPanelCellSelectionHandler selectionHandler = new DMNGridPanelCellSelectionHandlerImpl(gridLayer);
    final ContextMenuHandler contextMenuHandler = new DMNGridPanelContextMenuHandler(gridLayer, cellEditorControls, selectionHandler);
    this.panel = new DMNGridPanel(gridLayer, mousePanMediator, contextMenuHandler);
}
Also used : CellEditorControlsView(org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView) RestrictedMousePanMediator(org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.impl.RestrictedMousePanMediator) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer) ContextMenuHandler(com.google.gwt.event.dom.client.ContextMenuHandler)

Example 3 with DMNGridLayer

use of org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer in project kie-wb-common by kiegroup.

the class BaseDelegatingExpressionGrid method selectFirstCell.

@Override
public void selectFirstCell() {
    if (nesting == 0) {
        super.selectFirstCell();
        return;
    }
    final GridCellTuple parent = getParentInformation();
    final GridWidget parentGridWidget = parent.getGridWidget();
    final GridData parentGridData = parentGridWidget.getModel();
    parentGridData.clearSelections();
    parentGridData.selectCell(parent.getRowIndex(), parent.getColumnIndex());
    doAfterSelectionChange(0, 0);
    final DMNGridLayer gridLayer = (DMNGridLayer) getLayer();
    gridLayer.select(parentGridWidget);
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) GridWidget(org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) DMNGridLayer(org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer)

Aggregations

DMNGridLayer (org.kie.workbench.common.dmn.client.widgets.layer.DMNGridLayer)3 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)2 ContextMenuHandler (com.google.gwt.event.dom.client.ContextMenuHandler)1 Optional (java.util.Optional)1 Before (org.junit.Before)1 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)1 ExpressionEditorDefinitions (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinitions)1 ExpressionGridCacheImpl (org.kie.workbench.common.dmn.client.widgets.grid.ExpressionGridCacheImpl)1 CellEditorControlsView (org.kie.workbench.common.dmn.client.widgets.grid.controls.container.CellEditorControlsView)1 Bounds (org.uberfire.ext.wires.core.grids.client.model.Bounds)1 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)1 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)1 GridWidget (org.uberfire.ext.wires.core.grids.client.widget.grid.GridWidget)1 CellSelectionManager (org.uberfire.ext.wires.core.grids.client.widget.grid.selections.CellSelectionManager)1 RestrictedMousePanMediator (org.uberfire.ext.wires.core.grids.client.widget.layer.pinning.impl.RestrictedMousePanMediator)1