Search in sources :

Example 41 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class DeleteRelationRowCommandTest method setup.

@Before
public void setup() {
    this.relation = new Relation();
    this.rowList = new List();
    this.relation.getRow().add(rowList);
    this.uiModel = new BaseGridData();
    this.uiModel.appendRow(new BaseGridRow());
    this.uiModel.appendColumn(uiRowNumberColumn);
    this.uiModelMapper = new RelationUIModelMapper(() -> uiModel, () -> Optional.of(relation), listSelector, DEFAULT_HEIGHT);
    makeCommand(0);
    doReturn(ruleManager).when(handler).getRuleManager();
    doReturn(0).when(uiRowNumberColumn).getIndex();
    doReturn(1).when(uiModelColumn).getIndex();
}
Also used : RelationUIModelMapper(org.kie.workbench.common.dmn.client.editors.expressions.types.relation.RelationUIModelMapper) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) List(org.kie.workbench.common.dmn.api.definition.model.List) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 42 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class SetKindCommandTest method setup.

@Before
public void setup() {
    this.function = new FunctionDefinition();
    this.function.setKind(originalKind);
    this.function.setExpression(originalExpression);
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(mockColumn);
    this.uiModel.appendRow(new BaseGridRow());
    this.uiModel.setCellValue(0, 0, new ExpressionCellValue(Optional.of(originalEditor)));
    doReturn(uiModel).when(gridWidget).getModel();
    doReturn(ruleManager).when(handler).getRuleManager();
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 43 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class BaseExpressionGridGeneralTest method testDeselect.

@Test
public void testDeselect() {
    final String expectedUUID = "0000-1111-2222";
    doReturn(Optional.of(expectedUUID)).when(grid).getNodeUUID();
    grid.getModel().appendRow(new BaseGridRow());
    appendColumns(GridColumn.class);
    // Select a cell so we can check deselection clears selections
    grid.getModel().selectCell(0, 0);
    assertFalse(grid.getModel().getSelectedCells().isEmpty());
    grid.deselect();
    assertTrue(grid.getModel().getSelectedCells().isEmpty());
    verify(grid).clearSelectedDomainObject();
    verify(editorSelectedEvent).fire(expressionEditorChangedArgumentCaptor.capture());
    assertEquals(expectedUUID, expressionEditorChangedArgumentCaptor.getValue().getNodeUUID());
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Test(org.junit.Test)

Example 44 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class BaseExpressionGridGeneralTest method testSelectFirstCellWithRowAndNonRowNumberColumn.

@Test
public void testSelectFirstCellWithRowAndNonRowNumberColumn() {
    grid.getModel().appendRow(new BaseGridRow());
    appendColumns(GridColumn.class);
    grid.selectFirstCell();
    assertThat(grid.getModel().getSelectedCells()).isNotEmpty();
    assertThat(grid.getModel().getSelectedCells()).contains(new GridData.SelectedCell(0, 0));
    verify(domainObjectSelectionEvent).fire(domainObjectSelectionEventCaptor.capture());
    final DomainObjectSelectionEvent domainObjectSelectionEvent = domainObjectSelectionEventCaptor.getValue();
    assertThat(domainObjectSelectionEvent.getDomainObject()).isInstanceOf(NOPDomainObject.class);
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Test(org.junit.Test)

Example 45 with BaseGridRow

use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.

the class BaseExpressionGridGeneralTest method testSelectCellWithPoint.

@Test
public void testSelectCellWithPoint() {
    grid.getModel().appendRow(new BaseGridRow());
    appendColumns(RowNumberColumn.class, GridColumn.class);
    final Point2D point = mock(Point2D.class);
    final double columnOffset = grid.getModel().getColumns().get(0).getWidth();
    final double columnWidth = grid.getModel().getColumns().get(1).getWidth() / 2;
    final double rowOffset = HEADER_HEIGHT + grid.getModel().getRow(0).getHeight() / 2;
    when(point.getX()).thenReturn(columnOffset + columnWidth);
    when(point.getY()).thenReturn(rowOffset);
    grid.selectCell(point, false, true);
    assertThat(grid.getModel().getSelectedCells()).isNotEmpty();
    assertThat(grid.getModel().getSelectedCells()).contains(new GridData.SelectedCell(0, 1));
    verify(domainObjectSelectionEvent).fire(domainObjectSelectionEventCaptor.capture());
    final DomainObjectSelectionEvent domainObjectSelectionEvent = domainObjectSelectionEventCaptor.getValue();
    assertThat(domainObjectSelectionEvent.getDomainObject()).isInstanceOf(NOPDomainObject.class);
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) Point2D(com.ait.lienzo.client.core.types.Point2D) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) DMNGridData(org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) Test(org.junit.Test)

Aggregations

BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)104 Test (org.junit.Test)57 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)25 Before (org.junit.Before)24 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)19 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)18 GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)18 List (org.kie.workbench.common.dmn.api.definition.model.List)14 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)14 GraphCommandExecutionContext (org.kie.workbench.common.stunner.core.graph.command.GraphCommandExecutionContext)11 Optional (java.util.Optional)10 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)10 InformationItem (org.kie.workbench.common.dmn.api.definition.model.InformationItem)10 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)9 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)9 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)9 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)9 RowNumberColumn (org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn)9 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)8 RuleViolation (org.kie.workbench.common.stunner.core.rule.RuleViolation)8