Search in sources :

Example 11 with RefreshFormPropertiesEvent

use of org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent 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 12 with RefreshFormPropertiesEvent

use of org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent in project kie-wb-common by kiegroup.

the class FormsCanvasSessionHandlerTest method setup.

@Before
@SuppressWarnings("unchecked")
public void setup() {
    this.refreshFormPropertiesEvent = new RefreshFormPropertiesEvent(session, UUID);
    this.handler = spy(new FormsCanvasSessionHandler(definitionManager, commandFactory, sessionCommandManager) {

        @Override
        protected FormsCanvasSessionHandler.FormsDomainObjectCanvasListener getFormsDomainObjectCanvasListener() {
            return domainObjectCanvasListener;
        }
    });
    this.handler.setRenderer(formRenderer);
    when(session.getCanvasHandler()).thenReturn(abstractCanvasHandler);
    when(session.getSelectionControl()).thenReturn(selectionControl);
    when(abstractCanvasHandler.getGraphIndex()).thenReturn(index);
    when(abstractCanvasHandler.getDiagram()).thenReturn(diagram);
    when(index.get(eq(UUID))).thenReturn(element);
    when(diagram.getGraph()).thenReturn(graph);
    when(graph.getUUID()).thenReturn(GRAPH_UUID);
    when(definitionManager.adapters()).thenReturn(adapterManager);
    when(adapterManager.forProperty()).thenReturn(propertyAdapter);
    when(propertyAdapter.getId(any())).thenReturn(FIELD_PROPERTY_ID);
    when(commandFactory.updateDomainObjectPropertyValue(domainObject, FIELD_NAME, FIELD_VALUE)).thenReturn(updateDomainObjectPropertyCommand);
}
Also used : RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) Before(org.junit.Before)

Example 13 with RefreshFormPropertiesEvent

use of org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent in project kie-wb-common by kiegroup.

the class StunnerFormsHandlerTest method testRefreshCurrentSessionForms.

@Test
@SuppressWarnings("unchecked")
public void testRefreshCurrentSessionForms() {
    ClientSession session = mock(ClientSession.class);
    when(sessionManager.getCurrentSession()).thenReturn(session);
    tested.refreshCurrentSessionForms();
    ArgumentCaptor<RefreshFormPropertiesEvent> eventCaptor = ArgumentCaptor.forClass(RefreshFormPropertiesEvent.class);
    verify(refreshFormsEvent, times(1)).fire(eventCaptor.capture());
    RefreshFormPropertiesEvent event = eventCaptor.getValue();
    assertEquals(session, event.getSession());
    assertNull(event.getUuid());
}
Also used : ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) Test(org.junit.Test)

Example 14 with RefreshFormPropertiesEvent

use of org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent in project kie-wb-common by kiegroup.

the class DefaultImportsEditorWidget method addDataTypes.

public void addDataTypes(ImportsValue imports) {
    boolean updated = false;
    for (DefaultImport imported : imports.getDefaultImports()) {
        if (imported.getClassName() != null && !defaultTypes.contains(imported.getClassName())) {
            updated = true;
            dataTypeNamesService.add(imported.getClassName(), null);
        }
    }
    if (updated) {
        refreshFormsEvent.fire(new RefreshFormPropertiesEvent(sessionManager.getCurrentSession()));
    }
}
Also used : DefaultImport(org.kie.workbench.common.stunner.bpmn.definition.property.diagram.imports.DefaultImport) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent)

Example 15 with RefreshFormPropertiesEvent

use of org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent in project kie-wb-common by kiegroup.

the class BPMNDiagramFilterProviderTest method onFormFieldChanged.

@Test
public void onFormFieldChanged() {
    tested.onFormFieldChanged(formFieldChanged);
    final ArgumentCaptor<RefreshFormPropertiesEvent> refreshFormPropertiesArgumentCaptor = ArgumentCaptor.forClass(RefreshFormPropertiesEvent.class);
    verify(refreshFormPropertiesEvent).fire(refreshFormPropertiesArgumentCaptor.capture());
    RefreshFormPropertiesEvent refreshEvent = refreshFormPropertiesArgumentCaptor.getValue();
    assertEquals(refreshEvent.getUuid(), UUID);
    assertEquals(refreshEvent.getSession(), session);
}
Also used : RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) Test(org.junit.Test)

Aggregations

RefreshFormPropertiesEvent (org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent)16 Test (org.junit.Test)7 ClientSession (org.kie.workbench.common.stunner.core.client.session.ClientSession)5 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)3 CanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler)3 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)2 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)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 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Event (javax.enterprise.event.Event)1 Inject (javax.inject.Inject)1 TranslationService (org.jboss.errai.ui.client.local.spi.TranslationService)1 Before (org.junit.Before)1 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)1 HasName (org.kie.workbench.common.dmn.api.definition.HasName)1