Search in sources :

Example 11 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 testSetValueConsumerWhenNotNestedAndUpdateStunnerTitle.

@Test
@SuppressWarnings("unchecked")
public void testSetValueConsumerWhenNotNestedAndUpdateStunnerTitle() {
    grid.fireDomainObjectSelectionEvent(decision);
    reset(domainObjectSelectionEvent);
    final String uuid = UUID.uuid();
    doReturn(Optional.of(uuid)).when(grid).getNodeUUID();
    when(index.get(uuid)).thenReturn(element);
    when(canvasCommandFactory.updatePropertyValue(element, NAME_ID, NAME)).thenReturn(updateElementPropertyCommand);
    doTestSetValueConsumer(true, SetHasValueCommand.class, UpdateElementPropertyCommand.class);
    verify(gridLayer).batch();
    verify(updateElementPropertyCommand).execute(eq(canvasHandler));
    verify(domainObjectSelectionEvent).fire(domainObjectSelectionEventCaptor.capture());
    final DomainObjectSelectionEvent domainObjectSelectionEvent = domainObjectSelectionEventCaptor.getValue();
    assertThat(domainObjectSelectionEvent.getDomainObject()).isEqualTo(decision);
    assertThat(domainObjectSelectionEvent.getCanvasHandler()).isEqualTo(canvasHandler);
}
Also used : DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) Test(org.junit.Test)

Example 12 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 testSelectFirstCellWithRowAndRowNumberColumnAndAnotherColumn.

@Test
public void testSelectFirstCellWithRowAndRowNumberColumnAndAnotherColumn() {
    grid.getModel().appendRow(new BaseGridRow());
    appendColumns(RowNumberColumn.class, GridColumn.class);
    grid.selectFirstCell();
    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) 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 13 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 testClearValueConsumerWhenNotNestedAndUpdateStunnerTitle.

@Test
@SuppressWarnings("unchecked")
public void testClearValueConsumerWhenNotNestedAndUpdateStunnerTitle() {
    grid.fireDomainObjectSelectionEvent(decision);
    reset(domainObjectSelectionEvent);
    final String uuid = UUID.uuid();
    final Name name = new Name();
    doReturn(Optional.of(uuid)).when(grid).getNodeUUID();
    when(index.get(uuid)).thenReturn(element);
    when(canvasCommandFactory.updatePropertyValue(element, NAME_ID, name)).thenReturn(updateElementPropertyCommand);
    doTestClearValueConsumer(true, DeleteHasValueCommand.class, UpdateElementPropertyCommand.class);
    verify(gridLayer).batch();
    verify(updateElementPropertyCommand).execute(eq(canvasHandler));
    verify(domainObjectSelectionEvent).fire(domainObjectSelectionEventCaptor.capture());
    final DomainObjectSelectionEvent domainObjectSelectionEvent = domainObjectSelectionEventCaptor.getValue();
    assertThat(domainObjectSelectionEvent.getDomainObject()).isEqualTo(decision);
    assertThat(domainObjectSelectionEvent.getCanvasHandler()).isEqualTo(canvasHandler);
}
Also used : DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) HasName(org.kie.workbench.common.dmn.api.definition.HasName) QName(org.kie.workbench.common.dmn.api.property.dmn.QName) Name(org.kie.workbench.common.dmn.api.property.dmn.Name) Test(org.junit.Test)

Example 14 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 Optional<CanvasHandler> canvasHandler = getCanvasHandler();
    if (!canvasHandler.isPresent()) {
        return;
    }
    final Optional<DomainObject> domainObject = getDomainObject();
    if (!domainObject.isPresent()) {
        domainObjectSelectionEvent.fire(new DomainObjectSelectionEvent(canvasHandler.get(), new NOPDomainObject()));
        return;
    }
    fireDomainObjectSelectionEvent(domainObject.get());
}
Also used : AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) NOPDomainObject(org.kie.workbench.common.dmn.api.definition.NOPDomainObject) DomainObject(org.kie.workbench.common.stunner.core.domainobject.DomainObject) NOPDomainObject(org.kie.workbench.common.dmn.api.definition.NOPDomainObject)

Example 15 with DomainObjectSelectionEvent

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

the class DecisionTableGridTest 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)

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