Search in sources :

Example 1 with RenderMode

use of org.kie.workbench.common.forms.dynamic.service.shared.RenderMode in project kie-wb-common by kiegroup.

the class FormsContainerTest method testDestroyDiagramDisplayers.

@Test
public void testDestroyDiagramDisplayers() {
    // arbitrary render mode
    RenderMode renderMode = RenderMode.EDIT_MODE;
    FormDisplayer firstDisplayer = testRender(getNode(FIRST_ELEMENT_UUID), 1, 1, renderMode);
    FormDisplayer secondDisplayer = testRender(getNode(SECOND_ELEMENT_UUID), 2, 1, renderMode);
    formsContainer.clearDiagramDisplayers(GRAPH_UUID);
    verify(firstDisplayer, times(3)).hide();
    verify(view, times(1)).removeDisplayer(firstDisplayer);
    verify(displayersInstance, times(1)).destroy(firstDisplayer);
    verify(secondDisplayer, times(2)).hide();
    verify(view, times(1)).removeDisplayer(secondDisplayer);
    verify(displayersInstance, times(1)).destroy(secondDisplayer);
}
Also used : FormDisplayer(org.kie.workbench.common.stunner.forms.client.widgets.container.displayer.FormDisplayer) RenderMode(org.kie.workbench.common.forms.dynamic.service.shared.RenderMode) Test(org.junit.Test)

Example 2 with RenderMode

use of org.kie.workbench.common.forms.dynamic.service.shared.RenderMode in project kie-wb-common by kiegroup.

the class FormsContainerTest method testDestroyAllDisplayers.

@Test
public void testDestroyAllDisplayers() {
    // arbitrary render mode
    RenderMode renderMode = RenderMode.EDIT_MODE;
    testRender(getNode(FIRST_ELEMENT_UUID), 1, 1, renderMode);
    testRender(getNode(SECOND_ELEMENT_UUID), 2, 1, renderMode);
    formsContainer.destroyAll();
    verify(view, times(1)).clear();
    verify(displayersInstance, times(1)).destroyAll();
}
Also used : RenderMode(org.kie.workbench.common.forms.dynamic.service.shared.RenderMode) Test(org.junit.Test)

Example 3 with RenderMode

use of org.kie.workbench.common.forms.dynamic.service.shared.RenderMode in project kie-wb-common by kiegroup.

the class FormsContainerTest method testSecondRender.

@Test
public void testSecondRender() {
    // arbitrary render mode
    RenderMode renderMode = RenderMode.EDIT_MODE;
    testRender(getNode(FIRST_ELEMENT_UUID), 1, 1, renderMode);
    testRender(getNode(SECOND_ELEMENT_UUID), 2, 1, renderMode);
}
Also used : RenderMode(org.kie.workbench.common.forms.dynamic.service.shared.RenderMode) Test(org.junit.Test)

Example 4 with RenderMode

use of org.kie.workbench.common.forms.dynamic.service.shared.RenderMode in project kie-wb-common by kiegroup.

the class FormsContainerTest method testDestroyOneDisplayer.

@Test
public void testDestroyOneDisplayer() {
    // arbitrary render mode
    RenderMode renderMode = RenderMode.EDIT_MODE;
    NodeImpl firstNode = getNode(FIRST_ELEMENT_UUID);
    FormDisplayer firstDisplayer = testRender(firstNode, 1, 1, renderMode);
    NodeImpl secondNode = getNode(SECOND_ELEMENT_UUID);
    FormDisplayer secondDisplayer = testRender(secondNode, 2, 1, renderMode);
    formsContainer.clearFormDisplayer(GRAPH_UUID, FIRST_ELEMENT_UUID);
    verify(firstDisplayer, times(3)).hide();
    verify(view, times(1)).removeDisplayer(firstDisplayer);
    verify(displayersInstance, times(1)).destroy(firstDisplayer);
    verify(secondDisplayer, times(1)).hide();
    verify(view, never()).removeDisplayer(secondDisplayer);
    verify(displayersInstance, never()).destroy(secondDisplayer);
    formsContainer.clearFormDisplayer(GRAPH_UUID, SECOND_ELEMENT_UUID);
    verify(secondDisplayer, times(2)).hide();
    verify(view, times(1)).removeDisplayer(secondDisplayer);
    verify(displayersInstance, times(1)).destroy(secondDisplayer);
}
Also used : FormDisplayer(org.kie.workbench.common.stunner.forms.client.widgets.container.displayer.FormDisplayer) RenderMode(org.kie.workbench.common.forms.dynamic.service.shared.RenderMode) NodeImpl(org.kie.workbench.common.stunner.core.graph.impl.NodeImpl) Test(org.junit.Test)

Example 5 with RenderMode

use of org.kie.workbench.common.forms.dynamic.service.shared.RenderMode in project kie-wb-common by kiegroup.

the class FormPropertiesWidget method show.

private void show(final String graphUuid, final Element<? extends Definition<?>> element, final Command callback) {
    if (element != null) {
        if (isNode(element) && !isFiltered(element) && lastElement != null && lastElement.getUUID().equals(element.getUUID())) {
            lastPosition = GraphUtils.getComputedPosition((Node<?, ? extends Edge>) element);
            return;
        }
        final String elementUUID = element.getUUID();
        final Diagram<?, ?> diagram = formSessionHandler.getDiagram();
        if (Objects.isNull(diagram)) {
            return;
        }
        final Metadata metadata = diagram.getMetadata();
        if (Objects.isNull(metadata)) {
            return;
        }
        final Path diagramPath = metadata.getPath();
        final Definition content = element.getContent();
        if (Objects.isNull(content)) {
            return;
        }
        final Object definition = content.getDefinition();
        final RenderMode renderMode = formSessionHandler.getSession() instanceof EditorSession ? RenderMode.EDIT_MODE : RenderMode.READ_ONLY_MODE;
        formsContainer.render(graphUuid, elementUUID, definition, diagramPath, (fieldName, newValue) -> {
            try {
                formSessionHandler.executeUpdateProperty(element, fieldName, newValue);
            } catch (final Exception ex) {
                log(Level.SEVERE, "Something wrong happened refreshing the canvas for " + "field '" + fieldName + "': " + ex.getCause());
            } finally {
                if (null != callback) {
                    callback.execute();
                }
            }
        }, renderMode);
        final String elementName = definitionUtils.getName(definition);
        fireFormsPropertiesOpenedEvent(elementUUID, elementName);
        lastElement = element;
        if (isNode(element)) {
            lastPosition = GraphUtils.getComputedPosition((Node<?, ? extends Edge>) element);
        }
    }
}
Also used : Path(org.uberfire.backend.vfs.Path) RenderMode(org.kie.workbench.common.forms.dynamic.service.shared.RenderMode) Node(org.kie.workbench.common.stunner.core.graph.Node) Metadata(org.kie.workbench.common.stunner.core.diagram.Metadata) Definition(org.kie.workbench.common.stunner.core.graph.content.definition.Definition) DomainObject(org.kie.workbench.common.stunner.core.domainobject.DomainObject) EditorSession(org.kie.workbench.common.stunner.core.client.session.impl.EditorSession) Edge(org.kie.workbench.common.stunner.core.graph.Edge)

Aggregations

RenderMode (org.kie.workbench.common.forms.dynamic.service.shared.RenderMode)15 Test (org.junit.Test)12 FormDisplayer (org.kie.workbench.common.stunner.forms.client.widgets.container.displayer.FormDisplayer)3 EditorSession (org.kie.workbench.common.stunner.core.client.session.impl.EditorSession)2 Metadata (org.kie.workbench.common.stunner.core.diagram.Metadata)2 Definition (org.kie.workbench.common.stunner.core.graph.content.definition.Definition)2 NodeImpl (org.kie.workbench.common.stunner.core.graph.impl.NodeImpl)2 Path (org.uberfire.backend.vfs.Path)2 FormGroup (org.kie.workbench.common.forms.dynamic.client.rendering.formGroups.FormGroup)1 DefaultFormGroup (org.kie.workbench.common.forms.dynamic.client.rendering.formGroups.impl.def.DefaultFormGroup)1 DomainObject (org.kie.workbench.common.stunner.core.domainobject.DomainObject)1 Edge (org.kie.workbench.common.stunner.core.graph.Edge)1 Node (org.kie.workbench.common.stunner.core.graph.Node)1