use of org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext in project kie-wb-common by kiegroup.
the class VFSSelectorFormProvider method getSelectorData.
@Override
public SelectorData getSelectorData(FormRenderingContext context) {
Map<String, String> values = new TreeMap<>();
if (context.getModel() instanceof EntityRelationField) {
FormEditorRenderingContext editorContext = (FormEditorRenderingContext) context;
FieldDefinition field = (FieldDefinition) context.getModel();
List<FormDefinition> forms;
if (field != null) {
forms = vfsFormFinderService.findFormsForType(field.getStandaloneClassName(), editorContext.getFormPath());
} else {
forms = vfsFormFinderService.findAllForms(editorContext.getFormPath());
}
for (FormDefinition form : forms) {
values.put(form.getId(), form.getName());
}
}
return new SelectorData(values, null);
}
use of org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext in project kie-wb-common by kiegroup.
the class FormEditorServiceImpl method constructContent.
@Override
protected FormModelerContent constructContent(Path path, Overview overview) {
try {
org.uberfire.java.nio.file.Path kiePath = Paths.convert(path);
FormDefinition form = findForm(kiePath);
FormModelerContent formModelConent = new FormModelerContent();
formModelConent.setDefinition(form);
formModelConent.setPath(path);
formModelConent.setOverview(overview);
FormEditorRenderingContext context = createRenderingContext(form, path);
formModelConent.setRenderingContext(context);
if (Optional.ofNullable(form.getModel()).isPresent()) {
FormModel formModel = form.getModel();
Optional<FormModelHandler> modelHandlerOptional = getHandlerForForm(form, path);
if (modelHandlerOptional.isPresent()) {
FormModelHandler formModelHandler = modelHandlerOptional.get();
FormModelSynchronizationResult synchronizationResult = formModelHandler.synchronizeFormModel();
formModel.getProperties().forEach(property -> {
Optional<FieldDefinition> fieldOptional = Optional.ofNullable(form.getFieldByBinding(property.getName()));
if (!fieldOptional.isPresent()) {
synchronizationResult.resolveConflict(property.getName());
}
});
formModelConent.setSynchronizationResult(synchronizationResult);
}
}
resourceOpenedEvent.fire(new ResourceOpenedEvent(path, sessionInfo));
return formModelConent;
} catch (Exception e) {
log.warn("Error loading form " + path.toURI(), e);
}
return null;
}
use of org.kie.workbench.common.forms.editor.service.shared.FormEditorRenderingContext in project kie-wb-common by kiegroup.
the class FormEditorServiceImpl method createRenderingContext.
protected FormEditorRenderingContext createRenderingContext(FormDefinition form, Path formPath) {
FormEditorRenderingContext context = new FormEditorRenderingContext(formPath);
context.setRootForm(form);
List<FormDefinition> allForms = vfsFormFinderService.findAllForms(formPath);
for (FormDefinition vfsForm : allForms) {
if (!vfsForm.getId().equals(form.getId())) {
context.getAvailableForms().put(vfsForm.getId(), vfsForm);
}
}
return context;
}
Aggregations