Search in sources :

Example 6 with DomainObjectSelectionEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent in project kie-wb-common by kiegroup.

the class ContextGridTest method assertNOPDomainObjectSelection.

private void assertNOPDomainObjectSelection() {
    verify(domainObjectSelectionEvent).fire(domainObjectSelectionEventCaptor.capture());
    final DomainObjectSelectionEvent domainObjectSelectionEvent = domainObjectSelectionEventCaptor.getValue();
    assertThat(domainObjectSelectionEvent.getDomainObject()).isInstanceOf(NOPDomainObject.class);
}
Also used : DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent)

Example 7 with DomainObjectSelectionEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent in project kie-wb-common by kiegroup.

the class ExpressionContainerGridTest method testSelectCellWithCoordinates.

@Test
public void testSelectCellWithCoordinates() {
    final int uiRowIndex = 0;
    final int uiColumnIndex = 1;
    final LiteralExpression domainObject = mock(LiteralExpression.class);
    when(hasExpression.asDMNModelInstrumentedBase()).thenReturn(domainObject);
    grid.setExpression(NODE_UUID, hasExpression, Optional.of(hasName), false);
    grid.selectCell(uiRowIndex, uiColumnIndex, false, true);
    verify(gridLayer).select(eq(grid));
    verify(domainObjectSelectionEvent).fire(domainObjectSelectionEventCaptor.capture());
    final DomainObjectSelectionEvent domainObjectSelectionEvent = domainObjectSelectionEventCaptor.getValue();
    assertThat(domainObjectSelectionEvent.getCanvasHandler()).isEqualTo(canvasHandler);
    assertThat(domainObjectSelectionEvent.getDomainObject()).isEqualTo(domainObject);
    verify(cellSelectionManager).selectCell(eq(uiRowIndex), eq(uiColumnIndex), eq(false), eq(true));
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) Test(org.junit.Test)

Example 8 with DomainObjectSelectionEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent in project kie-wb-common by kiegroup.

the class BaseExpressionGridGeneralTest method assertDomainObjectEventFiring.

private void assertDomainObjectEventFiring() {
    verify(domainObjectSelectionEvent).fire(domainObjectSelectionEventCaptor.capture());
    final DomainObjectSelectionEvent domainObjectSelectionEvent = domainObjectSelectionEventCaptor.getValue();
    assertThat(domainObjectSelectionEvent.getDomainObject()).isInstanceOf(NOPDomainObject.class);
}
Also used : DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent)

Example 9 with DomainObjectSelectionEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent 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 10 with DomainObjectSelectionEvent

use of org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent 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

DomainObjectSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent)47 Test (org.junit.Test)33 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)4 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)4 Decision (org.kie.workbench.common.dmn.api.definition.model.Decision)3 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)3 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)3 Point2D (com.ait.lienzo.client.core.types.Point2D)2 HasName (org.kie.workbench.common.dmn.api.definition.HasName)2 NOPDomainObject (org.kie.workbench.common.dmn.api.definition.NOPDomainObject)2 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)2 Name (org.kie.workbench.common.dmn.api.property.dmn.Name)2 CanvasClearSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.CanvasClearSelectionEvent)2 DomainObject (org.kie.workbench.common.stunner.core.domainobject.DomainObject)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Supplier (java.util.function.Supplier)1