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);
}
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();
}
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);
}
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);
}
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);
}
}
}
Aggregations