Search in sources :

Example 36 with DomainObjectSelectionEvent

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

the class BaseGrid method fireDomainObjectSelectionEvent.

protected void fireDomainObjectSelectionEvent(final DomainObject domainObject) {
    final Optional<CanvasHandler> canvasHandler = getCanvasHandler();
    if (!canvasHandler.isPresent()) {
        return;
    }
    final Optional<Node> domainObjectNode = findDomainObjectNodeByDomainObject(domainObject);
    if (domainObjectNode.isPresent()) {
        refreshFormPropertiesEvent.fire(new RefreshFormPropertiesEvent(getCurrentSession(), domainObjectNode.get().getUUID()));
        selectedDomainObject = Optional.empty();
    } else {
        domainObjectSelectionEvent.fire(new DomainObjectSelectionEvent(canvasHandler.get(), domainObject));
        selectedDomainObject = Optional.of(domainObject);
    }
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) Node(org.kie.workbench.common.stunner.core.graph.Node) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent)

Example 37 with DomainObjectSelectionEvent

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

the class InvocationGridTest 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 38 with DomainObjectSelectionEvent

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

the class InvocationGridTest method assertDomainObjectSelection.

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

Example 39 with DomainObjectSelectionEvent

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

the class BaseLiteralExpressionGridTest method testSelectFirstCellWhenNotNested.

@Test
public void testSelectFirstCellWhenNotNested() {
    setupGrid(0);
    grid.selectFirstCell();
    final List<GridData.SelectedCell> selectedCells = grid.getModel().getSelectedCells();
    assertThat(selectedCells.size()).isEqualTo(1);
    assertThat(selectedCells.get(0).getRowIndex()).isEqualTo(0);
    assertThat(selectedCells.get(0).getColumnIndex()).isEqualTo(0);
    verify(gridLayer).select(grid);
    verify(domainObjectSelectionEvent).fire(domainObjectSelectionEventCaptor.capture());
    final DomainObjectSelectionEvent domainObjectSelectionEvent = domainObjectSelectionEventCaptor.getValue();
    assertThat(domainObjectSelectionEvent.getDomainObject()).isEqualTo(expression.get());
}
Also used : DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) Test(org.junit.Test)

Example 40 with DomainObjectSelectionEvent

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

the class RelationGridTest method testSelectSingleCellWithHeaderSelected.

@Test
@SuppressWarnings("unchecked")
public void testSelectSingleCellWithHeaderSelected() {
    setupGrid(0);
    grid.selectHeaderCell(0, RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT, false, false);
    verify(domainObjectSelectionEvent).fire(domainObjectSelectionEventCaptor.capture());
    final DomainObjectSelectionEvent event1 = domainObjectSelectionEventCaptor.getValue();
    assertThat(event1.getDomainObject()).isEqualTo(expression.get().getColumn().get(0));
    // Reset DomainObjectSelectionEvent tested above.
    reset(domainObjectSelectionEvent);
    grid.selectCell(0, RelationUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT, false, true);
    verify(domainObjectSelectionEvent).fire(domainObjectSelectionEventCaptor.capture());
    final DomainObjectSelectionEvent event2 = domainObjectSelectionEventCaptor.getValue();
    assertThat(event2.getDomainObject()).isEqualTo(expression.get().getRow().get(0).getExpression().get(0).getExpression());
}
Also used : DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) 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