Search in sources :

Example 6 with RefreshFormPropertiesEvent

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

the class StunnerFormsHandlerTest method testRefreshCurrentSessionFormsByDomain.

@Test
@SuppressWarnings("unchecked")
public void testRefreshCurrentSessionFormsByDomain() {
    ClientSession session = mock(ClientSession.class);
    CanvasHandler handler = mock(CanvasHandler.class);
    Diagram diagram = mock(Diagram.class);
    Metadata metadata = mock(Metadata.class);
    when(sessionManager.getCurrentSession()).thenReturn(session);
    when(session.getCanvasHandler()).thenReturn(handler);
    when(handler.getDiagram()).thenReturn(diagram);
    when(diagram.getMetadata()).thenReturn(metadata);
    when(metadata.getDefinitionSetId()).thenReturn(BindableAdapterUtils.getDefinitionSetId(SomeDomain.class));
    tested.refreshCurrentSessionForms(SomeDomain.class);
    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 : CanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.CanvasHandler) ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) Diagram(org.kie.workbench.common.stunner.core.diagram.Diagram) Test(org.junit.Test)

Example 7 with RefreshFormPropertiesEvent

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

the class RuleLanguageFilterProvider method onFormFieldChanged.

void onFormFieldChanged(@Observes FormFieldChanged formFieldChanged) {
    final String ruleLanguageFieldName = BusinessRuleTask.EXECUTION_SET + "." + BusinessRuleTaskExecutionSet.RULE_LANGUAGE;
    if (!Objects.equals(formFieldChanged.getName(), ruleLanguageFieldName)) {
        return;
    }
    refreshFormPropertiesEvent.fire(new RefreshFormPropertiesEvent(sessionManager.getCurrentSession(), formFieldChanged.getUuid()));
}
Also used : RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent)

Example 8 with RefreshFormPropertiesEvent

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

the class BaseExpressionGridGeneralTest method testSelectHeaderCellWithDomainObjectInStunnerGraph.

@Test
public void testSelectHeaderCellWithDomainObjectInStunnerGraph() {
    grid.getModel().appendColumn(new RowNumberColumn());
    grid.getModel().appendColumn(new RowNumberColumn());
    // Mock graph to contain decision
    final Definition definition = mock(Definition.class);
    when(node.getUUID()).thenReturn(NODE_UUID);
    when(node.getContent()).thenReturn(definition);
    when(definition.getDefinition()).thenReturn(decision);
    // Mock grid to dispatch header selection as a DomainObject
    doAnswer(i -> {
        grid.fireDomainObjectSelectionEvent(decision);
        return null;
    }).when(grid).doAfterHeaderSelectionChange(anyInt(), anyInt());
    grid.selectHeaderCell(0, 1, false, false);
    assertHeaderSelection();
    verify(refreshFormPropertiesEvent).fire(refreshFormPropertiesEventCaptor.capture());
    final RefreshFormPropertiesEvent refreshFormPropertiesEvent = refreshFormPropertiesEventCaptor.getValue();
    assertThat(refreshFormPropertiesEvent.getUuid()).isEqualTo(NODE_UUID);
    assertThat(refreshFormPropertiesEvent.getSession()).isEqualTo(session);
}
Also used : RowNumberColumn(org.uberfire.ext.wires.core.grids.client.widget.grid.columns.RowNumberColumn) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent) Test(org.junit.Test)

Example 9 with RefreshFormPropertiesEvent

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

the class PropertiesPanelNotifier method refreshFormProperties.

void refreshFormProperties(final Node node) {
    final ClientSession currentSession = getCurrentSession().orElseThrow(UnsupportedOperationException::new);
    final String uuid = node.getUUID();
    getSelectedElementUUID().ifPresent(selectedElementUUID -> {
        if (Objects.equals(uuid, selectedElementUUID)) {
            refreshFormPropertiesEvent.fire(new RefreshFormPropertiesEvent(currentSession, uuid));
        }
    });
}
Also used : ClientSession(org.kie.workbench.common.stunner.core.client.session.ClientSession) RefreshFormPropertiesEvent(org.kie.workbench.common.stunner.forms.client.event.RefreshFormPropertiesEvent)

Example 10 with RefreshFormPropertiesEvent

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

the class NavigateToDRGEditorCommandTest method executeCanvasCommand.

@Test
@Override
public void executeCanvasCommand() {
    setup(false);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, command.getCanvasCommand(canvasHandler).execute(canvasHandler));
    verify(canvas).enableHandlers();
    verify(command).hidePaletteWidget(eq(false));
    verify(command).addDRGEditorToCanvasWidget();
    verify(sessionPresenterView).setCanvasWidget(view);
    verify(sessionPresenter).focus();
    verify(refreshFormPropertiesEvent).fire(refreshFormPropertiesEventCaptor.capture());
    final RefreshFormPropertiesEvent refreshFormPropertiesEvent = refreshFormPropertiesEventCaptor.getValue();
    assertEquals(NODE_UUID, refreshFormPropertiesEvent.getUuid());
}
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