Search in sources :

Example 1 with DomainObject

use of org.kie.workbench.common.stunner.core.domainobject.DomainObject in project kie-wb-common by kiegroup.

the class RelationGrid method doAfterSelectionChange.

@Override
public void doAfterSelectionChange(final int uiRowIndex, final int uiColumnIndex) {
    if (hasAnyHeaderCellSelected() || hasMultipleCellsSelected()) {
        super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
        return;
    }
    if (getExpression().get().isPresent()) {
        final Relation relation = getExpression().get().get();
        final RelationUIModelMapperHelper.RelationSection section = RelationUIModelMapperHelper.getSection(relation, uiColumnIndex);
        if (section == RelationUIModelMapperHelper.RelationSection.INFORMATION_ITEM) {
            final int iiIndex = RelationUIModelMapperHelper.getInformationItemIndex(relation, uiColumnIndex);
            final HasExpression hasExpression = relation.getRow().get(uiRowIndex).getExpression().get(iiIndex);
            final Expression expression = hasExpression.getExpression();
            if (expression instanceof DomainObject) {
                final DomainObject domainObject = (DomainObject) expression;
                fireDomainObjectSelectionEvent(domainObject);
                return;
            }
        }
    }
    super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Relation(org.kie.workbench.common.dmn.api.definition.model.Relation) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) DomainObject(org.kie.workbench.common.stunner.core.domainobject.DomainObject)

Example 2 with DomainObject

use of org.kie.workbench.common.stunner.core.domainobject.DomainObject 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 3 with DomainObject

use of org.kie.workbench.common.stunner.core.domainobject.DomainObject in project kie-wb-common by kiegroup.

the class FormsCanvasSessionHandler method onDomainObjectSelectionEvent.

void onDomainObjectSelectionEvent(@Observes DomainObjectSelectionEvent event) {
    checkNotNull("event", event);
    if (checkCanvasHandler(event.getCanvasHandler())) {
        final DomainObject domainObject = event.getDomainObject();
        render(domainObject);
    }
}
Also used : DomainObject(org.kie.workbench.common.stunner.core.domainobject.DomainObject)

Example 4 with DomainObject

use of org.kie.workbench.common.stunner.core.domainobject.DomainObject in project kie-wb-common by kiegroup.

the class ListGrid method doAfterSelectionChange.

@Override
public void doAfterSelectionChange(final int uiRowIndex, final int uiColumnIndex) {
    if (hasAnyHeaderCellSelected() || hasMultipleCellsSelected()) {
        super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
        return;
    }
    if (getExpression().get().isPresent()) {
        final List list = getExpression().get().get();
        final ListUIModelMapperHelper.ListSection section = ListUIModelMapperHelper.getSection(uiColumnIndex);
        if (section == ListUIModelMapperHelper.ListSection.EXPRESSION) {
            final HasExpression hasExpression = list.getExpression().get(uiRowIndex);
            final Expression expression = hasExpression.getExpression();
            if (expression instanceof DomainObject) {
                final DomainObject domainObject = (DomainObject) expression;
                fireDomainObjectSelectionEvent(domainObject);
                return;
            }
        }
    }
    super.doAfterSelectionChange(uiRowIndex, uiColumnIndex);
}
Also used : HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.model.LiteralExpression) HasExpression(org.kie.workbench.common.dmn.api.definition.HasExpression) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) DomainObject(org.kie.workbench.common.stunner.core.domainobject.DomainObject) List(org.kie.workbench.common.dmn.api.definition.model.List) ArrayList(java.util.ArrayList)

Example 5 with DomainObject

use of org.kie.workbench.common.stunner.core.domainobject.DomainObject in project kie-wb-common by kiegroup.

the class PropertiesPanelNotifierTest method testOnDomainObjectSelectionEvent.

@Test
public void testOnDomainObjectSelectionEvent() {
    final DomainObjectSelectionEvent selectionEvent = mock(DomainObjectSelectionEvent.class);
    final DomainObject domainObject = mock(DomainObject.class);
    final String uuid = "uuid";
    when(selectionEvent.getDomainObject()).thenReturn(domainObject);
    when(domainObject.getDomainObjectUUID()).thenReturn(uuid);
    notifier.onDomainObjectSelectionEvent(selectionEvent);
    verify(notifier).setSelectedElementUUID(uuid);
}
Also used : DomainObjectSelectionEvent(org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent) DomainObject(org.kie.workbench.common.stunner.core.domainobject.DomainObject) Test(org.junit.Test)

Aggregations

DomainObject (org.kie.workbench.common.stunner.core.domainobject.DomainObject)6 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)2 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)2 DomainObjectSelectionEvent (org.kie.workbench.common.stunner.core.client.canvas.event.selection.DomainObjectSelectionEvent)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 NOPDomainObject (org.kie.workbench.common.dmn.api.definition.NOPDomainObject)1 List (org.kie.workbench.common.dmn.api.definition.model.List)1 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)1 Relation (org.kie.workbench.common.dmn.api.definition.model.Relation)1 DefinitionManager (org.kie.workbench.common.stunner.core.api.DefinitionManager)1 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)1 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)1 AdapterManager (org.kie.workbench.common.stunner.core.definition.adapter.AdapterManager)1 PropertyAdapter (org.kie.workbench.common.stunner.core.definition.adapter.PropertyAdapter)1 AdapterRegistry (org.kie.workbench.common.stunner.core.registry.definition.AdapterRegistry)1